Title: | Utilities for Interacting with the 'Posit Connect' Server API |
---|---|
Description: | Provides a helpful 'R6' class and methods for interacting with the 'Posit Connect' Server API along with some meaningful utility functions for regular tasks. API documentation varies by 'Posit Connect' installation and version, but the latest documentation is also hosted publicly at <https://docs.posit.co/connect/api/>. |
Authors: | Toph Allen [aut, cre], Neal Richardson [aut], Sean Lopp [aut], Cole Arendt [aut], Posit, PBC [cph, fnd] |
Maintainer: | Toph Allen <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.0.9000 |
Built: | 2024-11-21 18:30:15 UTC |
Source: | https://github.com/rstudio/connectapi |
audit_access_open(content, type = "all")
audit_access_open(content, type = "all")
content |
|
type |
One of "all" or "logged_in". If "all", return a list of apps whose access control is set to "Everyone". If "logged_in", return a list of apps whose access control is set to "All logged in users" |
Other audit functions:
audit_r_versions()
,
audit_runas()
,
vanity_is_available()
audit_r_versions(content)
audit_r_versions(content)
content |
|
A plot that shows the R version used by content over time and in aggregate.
Other audit functions:
audit_access_open()
,
audit_runas()
,
vanity_is_available()
audit_runas(content)
audit_runas(content)
content |
|
A data frame with the app name and the Run As user if the Run As user is not the default
Other audit functions:
audit_access_open()
,
audit_r_versions()
,
vanity_is_available()
Browse to different locations on Connect via utils::browseURL
browse_solo(content) browse_dashboard(content) browse_api_docs(connect) browse_connect(connect)
browse_solo(content) browse_dashboard(content) browse_api_docs(connect) browse_connect(connect)
content |
A R6 Content object |
connect |
A R6 Connect object |
The url that is opened in the browser
Bundle
Bundle
An R6 class that represents a bundle
path
The bundle path on disk.
size
The size of the bundle.
new()
Initialize this content bundle.
Bundle$new(path)
path
The bundle path on disk.
print()
Print this object.
Bundle$print(...)
...
Unused.
clone()
The objects of this class are cloneable with this method.
Bundle$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Content
,
ContentTask
,
Environment
,
PositConnect
,
Task
,
Vanity
,
Variant
,
VariantSchedule
,
VariantTask
Creates a bundle from a target directory.
bundle_dir( path = ".", filename = fs::file_temp(pattern = "bundle", ext = ".tar.gz") )
bundle_dir( path = ".", filename = fs::file_temp(pattern = "bundle", ext = ".tar.gz") )
path |
The path to the directory to be bundled |
filename |
The output bundle path |
Bundle A bundle object
Other deployment functions:
bundle_path()
,
bundle_static()
,
deploy()
,
download_bundle()
,
poll_task()
bundle_dir(system.file("tests/testthat/examples/shiny/", package = "connectapi"))
bundle_dir(system.file("tests/testthat/examples/shiny/", package = "connectapi"))
Define a bundle from a path (a path directly to a tar.gz file)
bundle_path(path)
bundle_path(path)
path |
The path to a .tar.gz file |
Bundle A bundle object
Other deployment functions:
bundle_dir()
,
bundle_static()
,
deploy()
,
download_bundle()
,
poll_task()
bundle_path(system.file("tests/testthat/examples/static.tar.gz", package = "connectapi"))
bundle_path(system.file("tests/testthat/examples/static.tar.gz", package = "connectapi"))
Defines a bundle from static files. It copies all files to a temporary directory, generates a basic manifest file (using the first file as the "primary"), and bundles the directory.
bundle_static( path, filename = fs::file_temp(pattern = "bundle", ext = ".tar.gz") )
bundle_static( path, filename = fs::file_temp(pattern = "bundle", ext = ".tar.gz") )
path |
The path to a file (or files) that will be used for the static bundle |
filename |
The output bundle path |
NOTE: the rsconnect
package is required for this function to work properly.
Bundle A bundle object
Other deployment functions:
bundle_dir()
,
bundle_path()
,
deploy()
,
download_bundle()
,
poll_task()
bundle_static(system.file("logo.png", package = "connectapi"))
bundle_static(system.file("logo.png", package = "connectapi"))
Creates a connection to Posit Connect using the server URL and an api key. Validates the connection and checks that the version of the server is compatible with the current version of the package.
connect( server = Sys.getenv(paste0(prefix, "_SERVER"), NA_character_), api_key = Sys.getenv(paste0(prefix, "_API_KEY"), NA_character_), prefix = "CONNECT", ..., .check_is_fatal = TRUE )
connect( server = Sys.getenv(paste0(prefix, "_SERVER"), NA_character_), api_key = Sys.getenv(paste0(prefix, "_API_KEY"), NA_character_), prefix = "CONNECT", ..., .check_is_fatal = TRUE )
server |
The URL for accessing Posit Connect. Defaults to environment variable CONNECT_SERVER |
api_key |
The API Key to authenticate to Posit Connect with. Defaults to environment variable CONNECT_API_KEY |
prefix |
The prefix used to determine environment variables |
... |
Additional arguments. Not used at present |
.check_is_fatal |
Whether to fail if "check" requests fail. Useful in rare cases where more http request customization is needed for requests to succeed. |
A Posit Connect R6 object that can be passed along to methods
## Not run: connect() ## End(Not run) # default is to read CONNECT_SERVER and CONNECT_API_KEY environment variables # this example will read TEST_1_SERVER and TEST_1_API_KEY connect(prefix = "TEST_1")
## Not run: connect() ## End(Not run) # default is to read CONNECT_SERVER and CONNECT_API_KEY environment variables # this example will read TEST_1_SERVER and TEST_1_API_KEY connect(prefix = "TEST_1")
Content
Content
An R6 class that represents content
connect
An R6 Connect object
content
The content details from Posit Connect
default_variant
The default variant for this object.
is_rendered
TRUE if this is a rendered content type, otherwise FALSE.
is_interactive
TRUE if this is a rendered content type, otherwise FALSE.
new()
Initialize this content.
Content$new(connect, content)
connect
The Connect
instance.
content
The content data.
get_connect()
Returns the Connect
instance.
Content$get_connect()
get_content()
Returns the underlying content data.
Content$get_content()
get_content_remote()
Obtain the content data from the Connect server.
Content$get_content_remote()
get_bundles()
Return the set of content bundles.
Content$get_bundles()
bundle_download()
Download the source archive for a content bundle.
Content$bundle_download( bundle_id, filename = tempfile(pattern = "bundle", fileext = ".tar.gz"), overwrite = FALSE )
bundle_id
The bundle identifer.
filename
Where to write the result.
overwrite
Overwrite an existing filename.
bundle_delete()
Delete a content bundle.
Content$bundle_delete(bundle_id)
bundle_id
The bundle identifer.
internal_content()
Get this (remote) content item.
Content$internal_content()
update()
Update this content item.
Content$update(...)
...
Content fields.
danger_delete()
Delete this content item.
Content$danger_delete()
get_url()
Return the URL for this content.
Content$get_url()
get_dashboard_url()
Return the URL for this content in the Posit Connect dashboard.
Content$get_dashboard_url(pane = "")
pane
The pane in the dashboard to link to.
jobs()
Return the jobs for this content.
Content$jobs()
job()
Return a single job for this content.
Content$job(key)
key
The job key.
variants()
Return the variants for this content.
Content$variants()
tag_set()
Set a tag for this content.
Content$tag_set(tag_id)
tag_id
The tag identifier.
tag_delete()
Remove a tag for this content.
Content$tag_delete(tag_id)
tag_id
The tag identifier.
tags()
The tags for this content.
Content$tags()
permissions_add()
Add a principal to the ACL for this content.
Content$permissions_add(principal_guid, principal_type, role)
principal_guid
GUID for the target user or group.
principal_type
Acting on user or group.
role
The kind of content access.
permissions_update()
Alter a principal in the ACL for this content.
Content$permissions_update(id, principal_guid, principal_type, role)
id
The target identifier.
principal_guid
GUID for the target user or group.
principal_type
Acting on user or group.
role
The kind of content access.
permissions_delete()
Remove an entry from the ACL for this content.
Content$permissions_delete(id)
id
The target identifier.
permissions()
Obtain some or all of the ACL for this content.
Content$permissions(id = NULL, add_owner = FALSE)
id
The target identifier.
add_owner
Include the content owner in the result set.
environment()
Return the environment variables set for this content.
Content$environment()
environment_set()
Adjust the environment variables set for this content.
Content$environment_set(...)
...
Environment variable names and values. Use NA
as the value
to unset variables.
environment_all()
Overwrite the environment variables set for this content.
Content$environment_all(...)
...
Environment variable names and values.
deploy()
Deploy this content
Content$deploy(bundle_id = NULL)
bundle_id
Target bundle identifier.
repo_enable()
Adjust Git polling.
Content$repo_enable(enabled = TRUE)
enabled
Polling enabled.
repo_set()
Adjust Git repository.
Content$repo_set(repository, branch, subdirectory)
repository
Git repository URL
branch
Git repository branch
subdirectory
Git repository directory
print()
Print this object.
Content$print(...)
...
Unused.
clone()
The objects of this class are cloneable with this method.
Content$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
ContentTask
,
Environment
,
PositConnect
,
Task
,
Vanity
,
Variant
,
VariantSchedule
,
VariantTask
Delete a content item. WARNING: This action deletes all history, configuration, logs, and resources about a content item. It cannot be undone.
content_delete(content, force = FALSE)
content_delete(content, force = FALSE)
content |
an R6 content item |
force |
Optional. A boolean that determines whether we should prompt in interactive sessions |
The R6 Content item. The item is deleted, but information about it is cached locally
Other content functions:
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Returns a single content item based on guid
content_item(connect, guid)
content_item(connect, guid)
connect |
A Connect object |
guid |
The GUID for the content item to be retrieved |
A Content object for use with other content endpoints
Other content functions:
content_delete()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
## Not run: connect() %>% content_item("some-guid") %>% content_update_access_type("all") ## End(Not run)
## Not run: connect() %>% content_item("some-guid") %>% content_update_access_type("all") ## End(Not run)
content_list_by_tag(src, tag)
content_list_by_tag(src, tag)
src |
An R6 Connect object |
tag |
A |
content_list_by_tag()
retrieves a content list by tag
These functions are experimental placeholders until the API supports this behavior.
content_list_with_permissions(src, ..., .p = NULL) content_list_guid_has_access(content_list, guid)
content_list_with_permissions(src, ..., .p = NULL) content_list_guid_has_access(content_list, guid)
src |
A Connect R6 object |
... |
Extra arguments. Currently not used |
.p |
Optional. A predicate function, passed as-is to |
content_list |
A "content list with permissions" as returned by |
guid |
A user or group GUID to filter the content list by whether they have access |
content_list_with_permissions
loops through content and retrieves
permissions for each item (with a progress bar). This can take a long time
for lots of content! Make sure to use the optional .p
argument as a predicate
function that filters the content list before it is transformed.
content_list_guid_has_access
works with a content_list_with_permissions
dataset by checking whether a given GUID (either user or group) has access to
the content by:
checking if the content has access_type == "all"
checking if the content has access_type == "logged_in"
checking if the provided guid is the content owner
checking if the provided guid is in the list of content permissions (in the "permissions" column)
Submit a request to render a content item. Once submitted, the server runs an asynchronous process to render the content. This might be useful if content needs to be updated after its source data has changed, especially if this doesn't happen on a regular schedule.
Only valid for rendered content (e.g., most Quarto documents, Jupyter notebooks, R Markdown reports).
content_render(content, variant_key = NULL)
content_render(content, variant_key = NULL)
content |
The content item you wish to render. |
variant_key |
If a variant key is provided, render that variant. Otherwise, render the default variant. |
A VariantTask object that can be used to track completion of the render.
## Not run: client <- connect() item <- content_item(client, "951bf3ad-82d0-4bca-bba8-9b27e35c49fa") task <- content_render(item) poll_task(task) ## End(Not run)
## Not run: client <- connect() item <- content_item(client, "951bf3ad-82d0-4bca-bba8-9b27e35c49fa") task <- content_render(item) poll_task(task) ## End(Not run)
Submit a request to restart a content item. Once submitted, the server performs an asynchronous request to kill all processes associated with the content item, starting new processes as needed. This might be useful if the application relies on data that is loaded at startup, or if its memory usage has grown over time.
Note that users interacting with certain types of applications may have their workflows interrupted.
Only valid for interactive content (e.g., applications, APIs).
content_restart(content)
content_restart(content)
content |
The content item you wish to restart. |
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") content_restart(item) ## End(Not run)
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") content_restart(item) ## End(Not run)
Return content title for a piece of content. If the content
is missing (deleted) or not visible, then returns the default
content_title(connect, guid, default = "Unknown Content")
content_title(connect, guid, default = "Unknown Content")
connect |
A Connect object |
guid |
The GUID for the content item to be retrieved |
default |
The default value returned for missing or not visible content |
character. The title of the requested content
Other content functions:
content_delete()
,
content_item()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Update settings for a content item. For a list of all settings, see the
latest documentation
or the documentation for your server via connectapi::browse_api_docs()
.
content_update(content, ...) content_update_access_type(content, access_type = c("all", "logged_in", "acl")) content_update_owner(content, owner_guid)
content_update(content, ...) content_update_access_type(content, access_type = c("all", "logged_in", "acl")) content_update_owner(content, owner_guid)
content |
An R6 content item |
... |
Settings up update that are passed along to Posit Connect |
access_type |
One of "all", "logged_in", or "acl" |
owner_guid |
The GUID of a user who is a publisher, so that they can become the new owner of the content |
Popular selections are content_update(access_type="all")
,
content_update(access_type="logged_in")
or
content_update(access_type="acl")
, process settings, title, description,
etc.
content_update_access_type()
is a helper to make it easier to change access_type
content_update_owner()
is a helper to make it easier to change owner
An R6 content item
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
ContentTask
ContentTask
An R6 class that represents a Task for a piece of Content
connectapi::Content
-> ContentTask
task
The task.
data
The task data.
connectapi::Content$bundle_delete()
connectapi::Content$bundle_download()
connectapi::Content$danger_delete()
connectapi::Content$deploy()
connectapi::Content$environment()
connectapi::Content$environment_all()
connectapi::Content$environment_set()
connectapi::Content$get_bundles()
connectapi::Content$get_connect()
connectapi::Content$get_content()
connectapi::Content$get_content_remote()
connectapi::Content$get_dashboard_url()
connectapi::Content$get_url()
connectapi::Content$internal_content()
connectapi::Content$job()
connectapi::Content$jobs()
connectapi::Content$permissions()
connectapi::Content$permissions_add()
connectapi::Content$permissions_delete()
connectapi::Content$permissions_update()
connectapi::Content$repo_enable()
connectapi::Content$repo_set()
connectapi::Content$tag_delete()
connectapi::Content$tag_set()
connectapi::Content$tags()
connectapi::Content$update()
connectapi::Content$variants()
new()
Initialize this task.
ContentTask$new(connect, content, task)
connect
The Connect
instance.
content
The Content
instance.
task
The task data.
get_task()
Return the underlying task.
ContentTask$get_task()
add_data()
Set the data.
ContentTask$add_data(data)
data
The data.
get_data()
Get the data.
ContentTask$get_data()
print()
Print this object.
ContentTask$print(...)
...
Unused.
clone()
The objects of this class are cloneable with this method.
ContentTask$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
Content
,
Environment
,
PositConnect
,
Task
,
Vanity
,
Variant
,
VariantSchedule
,
VariantTask
Creates a random name from the LETTERS dataset
create_random_name(length = 25)
create_random_name(length = 25)
length |
Optional. The length of the random name. Defaults to 25 |
The randomly generated name
connectapi::verify_content_name
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Returns the URL for the content dashboard (opened to the selected pane).
dashboard_url(content, pane = "")
dashboard_url(content, pane = "")
content |
Content A Content object |
pane |
character The pane in the dashboard to link to |
character The dashboard URL for the content provided
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Returns the URL for the content dashboard (opened to the selected pane). NOTE: this takes a character object for performance optimization.
dashboard_url_chr(connect_url, content_guid, pane = "")
dashboard_url_chr(connect_url, content_guid, pane = "")
connect_url |
character The base URL of the Connect server |
content_guid |
character The guid for the content item in question |
pane |
character The pane in the dashboard to link to |
character The dashboard URL for the content provided
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Delete a runtime cache from a Connect server. Requires Administrator privileges.
delete_runtime_cache( client, language, version, image_name = "Local", dry_run = FALSE )
delete_runtime_cache( client, language, version, image_name = "Local", dry_run = FALSE )
client |
A |
language |
The language of the cache, either "R" or "Python". |
version |
The version of the cache, e.g. "4.3.3". |
image_name |
Optional. The name of the off-host execution image for the cache, or "Local" (the default) for native execution caches. |
dry_run |
Optional, default |
A Task
object representing the deletion task. If dry_run
is
TRUE
, returns NULL
or throws an error if the deletion would fail.
Other server management functions:
get_runtime_caches()
## Not run: client <- connect() task <- delete_runtime_cache(client, "R", "4.3.3") poll_task(task) ## End(Not run)
## Not run: client <- connect() task <- delete_runtime_cache(client, "R", "4.3.3") poll_task(task) ## End(Not run)
Delete the thumbnail from a content item on Connect.
delete_thumbnail(content)
delete_thumbnail(content)
content |
A content item. |
The content item (invisibly).
Other thumbnail functions:
get_thumbnail()
,
has_thumbnail()
,
set_thumbnail()
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") thumbnail <- get_thumbnail(item) ## End(Not run)
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") thumbnail <- get_thumbnail(item) ## End(Not run)
Deletes the Vanity URL for a piece of content.
delete_vanity_url(content)
delete_vanity_url(content)
content |
A Content object |
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Deploys a bundle (tarball) to an Posit Connect server. If not provided,
name
(a unique identifier) will be an auto-generated alphabetic string. If
deploying to an existing endpoint, you can set name
or guid
to the
desired content.
deploy( connect, bundle, name = create_random_name(), title = name, guid = NULL, ..., .pre_deploy = { } ) deploy_current(content)
deploy( connect, bundle, name = create_random_name(), title = name, guid = NULL, ..., .pre_deploy = { } ) deploy_current(content)
connect |
A Connect object |
bundle |
A Bundle object |
name |
The unique name for the content on the server |
title |
optional The title to be used for the content on the server |
guid |
optional The GUID if the content already exists on the server |
... |
Additional arguments passed along to the content creation |
.pre_deploy |
An expression to execute before deploying the new bundle.
The variables |
content |
A Content object |
This function accepts the same arguments as connectapi::content_update()
.
deploy_current()
is a helper to easily redeploy the currently active bundle
for an existing content item.
Task A task object
connectapi::content_update
Other deployment functions:
bundle_dir()
,
bundle_path()
,
bundle_static()
,
download_bundle()
,
poll_task()
## Not run: client <- connect() # beware bundling big directories, like `renv/`, `data/`, etc. bnd <- bundle_dir(".") deploy(client, bnd) ## End(Not run) client <- connect(prefix = "TEST_1") bnd <- bundle_path(system.file("tests/testthat/examples/static.tar.gz", package = "connectapi")) deploy(client, bnd)
## Not run: client <- connect() # beware bundling big directories, like `renv/`, `data/`, etc. bnd <- bundle_dir(".") deploy(client, bnd) ## End(Not run) client <- connect(prefix = "TEST_1") bnd <- bundle_path(system.file("tests/testthat/examples/static.tar.gz", package = "connectapi")) deploy(client, bnd)
Deploy a git repository directly to Posit Connect, using Posit Connect's "pull-based" "git-polling" method of deployment.
deploy_repo( client, repository, branch, subdirectory, name = create_random_name(), title = name, ... ) deploy_repo_enable(content, enabled = TRUE) deploy_repo_update(content)
deploy_repo( client, repository, branch, subdirectory, name = create_random_name(), title = name, ... ) deploy_repo_enable(content, enabled = TRUE) deploy_repo_update(content)
client |
A Connect R6 object |
repository |
The git repository to deploy |
branch |
The git branch to deploy |
subdirectory |
The subdirectory to deploy (must contain a |
name |
The "name" / unique identifier for the content. Defaults to a random character string |
title |
The "title" of the content |
... |
Additional options for defining / specifying content attributes |
content |
An R6 Content object (i.e. the result of |
enabled |
Whether Connect will enable automatic polling for repository updates |
deploy_repo_enable()
enables (or disables) Posit Connect's git polling for a piece of content
deploy_repo_update()
triggers an update of the content from its git
repository, if any are present
A ContentTask object, for use with poll_task()
(if you want to follow the logs)
connectapi::poll_task, connectapi::repo_check_branches, connectapi::repo_check_manifest_dirs
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Downloads a Content item's active bundle, or (optionally) one of its other bundles.
download_bundle( content, filename = fs::file_temp(pattern = "bundle", ext = ".tar.gz"), bundle_id = NULL, overwrite = FALSE )
download_bundle( content, filename = fs::file_temp(pattern = "bundle", ext = ".tar.gz"), bundle_id = NULL, overwrite = FALSE )
content |
A Content object |
filename |
Optional. The output bundle path |
bundle_id |
Optional. A string representing the bundle_id to download. If NULL, will use the currently active bundle. |
overwrite |
Optional. Default FALSE. Whether to overwrite the target location if it already exists |
Bundle A bundle object
Other deployment functions:
bundle_dir()
,
bundle_path()
,
bundle_static()
,
deploy()
,
poll_task()
Environment
Environment
An R6 class that represents a Content's Environment Variables
connectapi::Content
-> Environment
env_raw
The (raw) set of environment variables.
env_vars
The set of environment variables.
connectapi::Content$bundle_delete()
connectapi::Content$bundle_download()
connectapi::Content$danger_delete()
connectapi::Content$deploy()
connectapi::Content$get_bundles()
connectapi::Content$get_connect()
connectapi::Content$get_content()
connectapi::Content$get_content_remote()
connectapi::Content$get_dashboard_url()
connectapi::Content$get_url()
connectapi::Content$internal_content()
connectapi::Content$job()
connectapi::Content$jobs()
connectapi::Content$permissions()
connectapi::Content$permissions_add()
connectapi::Content$permissions_delete()
connectapi::Content$permissions_update()
connectapi::Content$repo_enable()
connectapi::Content$repo_set()
connectapi::Content$tag_delete()
connectapi::Content$tag_set()
connectapi::Content$tags()
connectapi::Content$update()
connectapi::Content$variants()
new()
Initialize this set of environment variables.
Environment$new(connect, content)
connect
The Connect
instance.
content
The Content
instance.
environment()
Fetch the set of environment variables.
Environment$environment()
environment_set()
Update the set of environment variables.
Environment$environment_set(...)
...
Environment variable names and values.
environment_all()
Overwrite the set of environment variables.
Environment$environment_all(...)
...
Environment variable names and values.
env_refresh()
Fetch the set o environment variables.
Environment$env_refresh()
print()
Print this object.
Environment$print(...)
...
Unused.
clone()
The objects of this class are cloneable with this method.
Environment$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
Content
,
ContentTask
,
PositConnect
,
Task
,
Vanity
,
Variant
,
VariantSchedule
,
VariantTask
Get Audit Logs from Posit Connect Server
get_audit_logs(src, limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE)
get_audit_logs(src, limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE)
src |
The source object |
limit |
The number of records to return. |
previous |
Retrieve the previous page of Shiny application usage logs relative to the provided value. This value corresponds to an internal reference within the server and should be sourced from the appropriate attribute within the paging object of a previous response. |
nxt |
Retrieve the next page of Shiny application usage logs relative to the provided value. This value corresponds to an internal reference within the server and should be sourced from the appropriate attribute within the paging object of a previous response. |
asc_order |
Defaults to TRUE; Determines if the response records should be listed in ascending or descending order within the response. Ordering is by the started timestamp field. |
Please see https://docs.posit.co/connect/api/#get-/v1/audit_logs for more information.
A tibble with the following columns:
id
: ID of the audit action
time
: Timestamp in RFC3339 format when action was taken
user_id
: User ID of the actor who made the audit action
user_description
: Description of the actor
action
: Audit action taken
event_description
: Description of action
## Not run: library(connectapi) client <- connect() # get the last 20 audit logs get_audit_logs(client, limit = 20, asc_order = FALSE) ## End(Not run)
## Not run: library(connectapi) client <- connect() # get the last 20 audit logs get_audit_logs(client, limit = 20, asc_order = FALSE) ## End(Not run)
Lists bundles for a content item
get_bundles(content) delete_bundle(content, bundle_id)
get_bundles(content) delete_bundle(content, bundle_id)
content |
A R6 Content item, as returned by |
bundle_id |
A specific bundle ID for a content item |
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Get information about content on the Posit Connect server
get_content(src, guid = NULL, owner_guid = NULL, name = NULL, ..., .p = NULL)
get_content(src, guid = NULL, owner_guid = NULL, name = NULL, ..., .p = NULL)
src |
A Connect object |
guid |
The guid for a particular content item |
owner_guid |
The unique identifier of the user who owns the content |
name |
The content name specified when the content was created |
... |
Extra arguments. Currently not used. |
.p |
Optional. A predicate function, passed as-is to |
Please see https://docs.posit.co/connect/api/#get-/v1/content for more information.
A tibble with the following columns:
guid
: The unique identifier of this content item.
name
: A simple, URL-friendly identifier. Allows alpha-numeric
characters, hyphens ("-"), and underscores ("_").
title
: The title of this content.
description
: A rich description of this content
access_type
: Access type describes how this content manages its
viewers. It may have a value of all
, logged_in
or acl
.
The value all
is the most permissive; any visitor to Posit
Connect will be able to view this content. The value logged_in
indicates that all Posit Connect accounts may view the content. The
acl
value lets specifically enumerated users and groups view the
content. Users configured as collaborators may always view content.
connection_timeout
: Maximum number of seconds allowed without data
sent or received across a client connection. A value of 0 means
connections will never time-out (not recommended). When null, the
default Scheduler.ConnectionTimeout
is used. Applies only to content
types that are executed on demand.
read_timeout
: Maximum number of seconds allowed without data received
from a client connection. A value of 0 means a lack of client (browser)
interaction never causes the connection to close. When null, the default
Scheduler.ReadTimeout
is used. Applies only to content types that are
executed on demand.
init_timeout
: The maximum number of seconds allowed for an interactive
application to start. Posit Connect must be able to connect
to a newly launched Shiny application, for example, before this threshold
has elapsed. When null, the default Scheduler.InitTimeout
is
used. Applies only to content types that are executed on demand.
idle_timeout
: The maximum number of seconds a worker process
for an interactive application to remain alive after it goes idle (no
active connections). When null, the default Scheduler.IdleTimeout
is used. Applies only to content types that are executed on demand.
max_processes
: Specifies the total number of concurrent processes
allowed for a single interactive application. When null, the
default Scheduler.MaxProcesses
setting is used. Applies only to
content types that are executed on demand.
min_processes
: Specifies the minimum number of concurrent
processes allowed for a single interactive application. When null, the
default Scheduler.MinProcesses
is used. Applies only to content types
that are executed on demand.
max_conns_per_process
: Specifies the maximum number of
client connections allowed to an individual process. Incoming connections
which will exceed this limit are routed to a new process or rejected.
When null, the default Scheduler.MaxConnsPerProcess
is used. Applies
only to content types that are executed on demand.
load_factor
: Controls how aggressively new processes are spawned.
When null, the default Scheduler.LoadFactor
is used. Applies only to
content types that are executed on demand.
created_time
: The timestamp (RFC3339) indicating when this
content was created.
last_deployed_time
: The timestamp (RFC3339) indicating when
this content last had a successful bundle deployment performed.
bundle_id
: The identifier for the active deployment bundle.
Automatically assigned upon the successful deployment of that bundle.
app_mode
: The runtime model for this content. Has a value
of unknown
before data is deployed to this item. Automatically assigned
upon the first successful bundle deployment. Allowed: api
,
jupyter-static
, python-api
, python-bokeh
, python-dash
,
python-streamlit
, rmd-shiny
, rmd-static
, shiny
, static
,
tensorflow-saved-model
, unknown
.
content_category
: Describes the specialization of the content
runtime model. Automatically assigned upon the first successful bundle
deployment.
parameterized
: True when R Markdown rendered content
allows parameter configuration. Automatically assigned upon the first
successful bundle deployment. Applies only to content with an app_mode
of rmd-static.
r_version
: The version of the R interpreter associated
with this content. The value null represents that an R interpreter is
not used by this content or that the R package environment has not been
successfully restored. Automatically assigned upon the successful
deployment of a bundle.
py_version
: The version of the Python interpreter
associated with this content. The value null represents that a Python
interpreter is not used by this content or that the Python package
environment has not been successfully restored. Automatically assigned
upon the successful deployment of a bundle.
run_as
: The UNIX user that executes this content.
When null, the default Applications.RunAs is used. Applies
only to executable content types - not static.
run_as_current_user
: Indicates if this content is allowed
to execute as the logged-in user when using PAM authentication.
Applies only to executable content types - not static.
owner_guid
: The unique identifier for the owner
content_url
: The URL associated with this content. Computed
from the associated vanity URL or GUID for this content.
dashboard_url
: The URL within the Connect dashboard where
this content can be configured. Computed from the GUID for this content.
role
: The relationship of the accessing user to this
content. A value of owner is returned for the content owner. editor
indicates a collaborator. The viewer value is given to users who are
permitted to view the content. A none role is returned for
administrators who cannot view the content but are permitted to view
its configuration. Computed at the time of the request.
id
: The internal numeric identifier of this content item
## Not run: library(connectapi) client <- connect() get_content(client) ## End(Not run)
## Not run: library(connectapi) client <- connect() get_content(client) ## End(Not run)
Manage Environment Variables for a piece of content.
get_environment(content) set_environment_new(env, ...) set_environment_remove(env, ...) set_environment_all(env, ...)
get_environment(content) set_environment_new(env, ...) set_environment_remove(env, ...) set_environment_all(env, ...)
content |
An R6 Content object as returned by |
env |
An R6 Environment object as returned by |
... |
name = value pairs of environment variable names and values |
get_environment()
returns an Environment object for use with "setter" methods
set_environment_new()
updates environment values (either creating new
values or updating existing). Set NA
as the value to remove a variable.
set_environment_remove()
is a wrapper on set_environment_new()
that
allows removing named / listed variables quickly
set_environment_all()
sets all environment variable values (will remove
variables not specified)
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Get users within a specific group
get_group_members(src, guid)
get_group_members(src, guid)
src |
The source object |
guid |
A group GUID identifier |
Please see https://docs.posit.co/connect/api/#get-/v1/groups/-group_guid-/members for more information.
A tibble with the following columns:
email
: The user's email
username
: The user's username
first_name
: The user's first name
last_name
: The user's last name
user_role
: The user's role. It may have a value of administrator,
publisher or viewer.
created_time
: The timestamp (in RFC3339 format) when the user
was created in the Posit Connect server
updated_time
: The timestamp (in RFC3339 format) when the user
was last updated in the Posit Connect server
active_time
: The timestamp (in RFC3339 format) when the user
was last active on the Posit Connect server
confirmed
: When false, the created user must confirm their
account through an email. This feature is unique to password
authentication.
locked
: Whether or not the user is locked
guid
: The user's GUID, or unique identifier, in UUID RFC4122 format
## Not run: library(connectapi) client <- connect() # get the first 20 groups groups <- get_groups(client) group_guid <- groups$guid[1] get_group_members(client, guid = group_guid) ## End(Not run)
## Not run: library(connectapi) client <- connect() # get the first 20 groups groups <- get_groups(client) group_guid <- groups$guid[1] get_group_members(client, guid = group_guid) ## End(Not run)
Get group information from the Posit Connect server
get_groups(src, page_size = 500, prefix = NULL, limit = Inf)
get_groups(src, page_size = 500, prefix = NULL, limit = Inf)
src |
The source object. |
page_size |
The number of records to return per page (max 500). |
prefix |
Filters groups by prefix (group name). The filter is case insensitive. |
limit |
The number of groups to retrieve before paging stops.
|
Please see https://docs.posit.co/connect/api/#get-/v1/groups for more information.
A tibble with the following columns:
guid
: The unique identifier of the group
name
: The group name
owner_guid
: The group owner's unique identifier. When using LDAP or
Proxied authentication with group provisioning enabled this property
will always be null.
## Not run: library(connectapi) client <- connect() # get all groups get_groups(client, limit = Inf) ## End(Not run)
## Not run: library(connectapi) client <- connect() # get all groups get_groups(client, limit = Inf) ## End(Not run)
Please use get_thumbnail
,
delete_thumbnail
, and has_thumbnail
instead.
get_image
saves the content image to the given path (default: temp file).
delete_image
removes the image (optionally saving to the given path)
has_image
returns whether the content has an image
get_image(content, path = NULL) delete_image(content, path = NULL) has_image(content)
get_image(content, path = NULL) delete_image(content, path = NULL) has_image(content)
content |
A content object |
path |
optional. The path to the image on disk |
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Retrieve details about jobs associated with a content_item
.
"Jobs" in Posit Connect are content executions
get_jobs(content) get_job(content, key)
get_jobs(content) get_job(content, key)
content |
A Content object, as returned by |
key |
The key for a job |
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Perform an OAuth credential exchange to obtain a viewer's OAuth access token.
get_oauth_credentials(connect, user_session_token)
get_oauth_credentials(connect, user_session_token)
connect |
A Connect R6 object. |
user_session_token |
The content viewer's session token. This token can only be obtained when the content is running on a Connect server. The token identifies the user who is viewing the content interactively on the Connect server. Read this value from the HTTP header: |
Please see https://docs.posit.co/connect/user/oauth-integrations/#obtaining-a-viewer-oauth-access-token for more information.
The OAuth credential exchange response.
## Not run: library(connectapi) library(plumber) client <- connect() #* @get /do function(req) { user_session_token <- req$HTTP_POSIT_CONNECT_USER_SESSION_TOKEN credentials <- get_oauth_credentials(client, user_session_token) # ... do something with `credentials$access_token` ... "done" } ## End(Not run)
## Not run: library(connectapi) library(plumber) client <- connect() #* @get /do function(req) { user_session_token <- req$HTTP_POSIT_CONNECT_USER_SESSION_TOKEN credentials <- get_oauth_credentials(client, user_session_token) # ... do something with `credentials$access_token` ... "done" } ## End(Not run)
This returns real-time process data from the Posit Connect API. It requires administrator privileges to use. NOTE that this only returns data for the server that responds to the request (i.e. in a Highly Available cluster)
get_procs(src)
get_procs(src)
src |
The source object |
A tibble with the following columns:
pid
: The PID of the current process
appId
: The application ID
appGuid
: The application GUID
appName
: The application name
appUrl
: The application URL
appRunAs
: The application RunAs user
type
: The type of process
cpuCurrent
: The current CPU usage
cpuTotal
: The total CPU usage
ram
: The current RAM usage
View the runtime caches on a Connect server. Requires Administrator privileges.
get_runtime_caches(client)
get_runtime_caches(client)
client |
A |
A tibble of runtime caches on the server, showing language
,
version
and image_name
. For Connect servers not using off-host execution,
image_name
is "Local"
.
Other server management functions:
delete_runtime_cache()
## Not run: client <- connect() get_runtime_caches(client) ## End(Not run)
## Not run: client <- connect() get_runtime_caches(client) ## End(Not run)
Get a table showing available versions of R, Python, Quarto, and Tensorflow on the Connect server.
get_runtimes(client, runtimes = NULL)
get_runtimes(client, runtimes = NULL)
client |
A |
runtimes |
Optional. A character vector of runtimes to include. Must be
some combination of |
A tibble with columns for runtime
, version
, and cluster_name
and image_name
. Cluster name and image name are only meaningful on Connect
instances running off-host execution.
## Not run: library(connectapi) client <- connect() get_runtimes(client, runtimes = c("r", "python", "tensorflow")) ## End(Not run)
## Not run: library(connectapi) client <- connect() get_runtimes(client, runtimes = c("r", "python", "tensorflow")) ## End(Not run)
Tag manipulation and assignment functions
get_tags(src) get_tag_data(src) create_tag(src, name, parent = NULL) create_tag_tree(src, ...) delete_tag(src, tag) get_content_tags(content) set_content_tag_tree(content, ...) set_content_tags(content, ...) filter_tag_tree_id(tags, ids) filter_tag_tree_chr(tags, pattern)
get_tags(src) get_tag_data(src) create_tag(src, name, parent = NULL) create_tag_tree(src, ...) delete_tag(src, tag) get_content_tags(content) set_content_tag_tree(content, ...) set_content_tags(content, ...) filter_tag_tree_id(tags, ids) filter_tag_tree_chr(tags, pattern)
src |
The source object |
name |
The name of the tag to create |
parent |
optional. A |
... |
Additional arguments Manage tags (requires Administrator role):
Manage content tags:
Search a tag tree:
|
tag |
A |
content |
An R6 Content object, as returned by |
tags |
A |
ids |
A list of |
pattern |
A regex to filter the tag tree by (it is passed to |
Download the thumbnail for a content item on Connect to a file on your computer.
get_thumbnail(content, path = NULL)
get_thumbnail(content, path = NULL)
content |
A content item. |
path |
Optional. A path to a file used to write the thumbnail image. If no path is provided, a temporary file with the correct file extension is created. |
The path to the downloaded image file, if content
has a thumbnail; otherwise NA
.
Other thumbnail functions:
delete_thumbnail()
,
has_thumbnail()
,
set_thumbnail()
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") thumbnail <- get_thumbnail(item) ## End(Not run)
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") thumbnail <- get_thumbnail(item) ## End(Not run)
Get the available timezones from the server.
get_timezones(connect)
get_timezones(connect)
connect |
An R6 Connect object |
A TimeZone vector to be used for setting time zones
Other schedule functions:
get_variant_schedule()
,
set_schedule()
Get usage information for deployed shiny applications
get_usage_shiny( src, content_guid = NULL, min_data_version = NULL, from = NULL, to = NULL, limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE )
get_usage_shiny( src, content_guid = NULL, min_data_version = NULL, from = NULL, to = NULL, limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE )
src |
the source object |
content_guid |
Filter results by content GUID |
min_data_version |
Filter by data version. Records with a data version lower than the given value will be excluded from the set of results. |
from |
The timestamp that starts the time window of interest. Any usage information that ends prior to this timestamp will not be returned. Individual records may contain a starting time that is before this if they end after it or have not finished. Must be of class Date or POSIX |
to |
The timestamp that ends the time window of interest. Any usage information that starts after this timestamp will not be returned. Individual records may contain an ending time that is after this (or no ending time) if they start before it. Must be of class Date or POSIX |
limit |
The number of records to return. |
previous |
Retrieve the previous page of Shiny application usage logs relative to the provided value. This value corresponds to an internal reference within the server and should be sourced from the appropriate attribute within the paging object of a previous response. |
nxt |
Retrieve the next page of Shiny application usage logs relative to the provided value. This value corresponds to an internal reference within the server and should be sourced from the appropriate attribute within the paging object of a previous response. |
asc_order |
Defaults to TRUE; Determines if the response records should be listed in ascending or descending order within the response. Ordering is by the started timestamp field. |
Please see https://docs.posit.co/connect/api/#get-/v1/instrumentation/shiny/usage for more information.
A tibble with the following columns:
content_guid
: The GUID, in RFC4122 format, of the
Shiny application this information pertains to.
user_guid
: The GUID, in RFC4122 format, of the user
that visited the application.
started
: The timestamp, in RFC3339 format, when the
user opened the application.
ended
: The timestamp, in RFC3339 format, when the
user left the application.
data_version
: The data version the record was recorded
with. The Shiny Application Events section of the Posit Connect Admin
Guide explains how to interpret data_version values.
## Not run: library(connectapi) client <- connect() from <- Sys.Date() - lubridate::days(5) get_usage_shiny(client, limit = 20, from = from) ## End(Not run)
## Not run: library(connectapi) client <- connect() from <- Sys.Date() - lubridate::days(5) get_usage_shiny(client, limit = 20, from = from) ## End(Not run)
This function retrieves usage information from static content on the Posit Connect server (e.g. Rmarkdown, Jupyter Notebooks)
get_usage_static( src, content_guid = NULL, min_data_version = NULL, from = NULL, to = NULL, limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE )
get_usage_static( src, content_guid = NULL, min_data_version = NULL, from = NULL, to = NULL, limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE )
src |
the source object |
content_guid |
Filter results by content GUID |
min_data_version |
Filter by data version. Records with a data version lower than the given value will be excluded from the set of results. |
from |
The timestamp that starts the time window of interest. Any usage information that ends prior to this timestamp will not be returned. Individual records may contain a starting time that is before this if they end after it or have not finished. Must be of class Date or POSIX |
to |
The timestamp that ends the time window of interest. Any usage information that starts after this timestamp will not be returned. Individual records may contain an ending time that is after this (or no ending time) if they start before it. Must be of class Date or POSIX |
limit |
The number of records to return. |
previous |
Retrieve the previous page of Shiny application usage logs relative to the provided value. This value corresponds to an internal reference within the server and should be sourced from the appropriate attribute within the paging object of a previous response. |
nxt |
Retrieve the next page of Shiny application usage logs relative to the provided value. This value corresponds to an internal reference within the server and should be sourced from the appropriate attribute within the paging object of a previous response. |
asc_order |
Defaults to TRUE; Determines if the response records should be listed in ascending or descending order within the response. Ordering is by the started timestamp field. |
Please see https://docs.posit.co/connect/api/#get-/v1/instrumentation/content/visits for more information.
A tibble with the following columns:
content_guid
: The GUID, in RFC4122 format, of the Shiny
application this information pertains to.
user_guid
: The GUID, in RFC4122 format, of the user that
visited the application.
variant_key
: The key of the variant the user visited.
This will be null for static content.
time
: The timestamp, in RFC3339 format, when the user
visited the content.
rendering_id
: The ID of the rendering the user visited.
This will be null for static content.
bundle_id
: The ID of the particular bundle used.
data_version
: The data version the record was recorded
with. The Rendered and Static Content Visit Events section of the
Posit Connect Admin Guide explains how to interpret data_version
values.
## Not run: library(connectapi) client <- connect() from <- Sys.Date() - lubridate::days(5) get_usage_static(client, limit = 20, from = from) ## End(Not run)
## Not run: library(connectapi) client <- connect() from <- Sys.Date() - lubridate::days(5) get_usage_static(client, limit = 20, from = from) ## End(Not run)
Get user information from the Posit Connect server
get_users( src, page_size = 500, prefix = NULL, limit = Inf, user_role = NULL, account_status = NULL )
get_users( src, page_size = 500, prefix = NULL, limit = Inf, user_role = NULL, account_status = NULL )
src |
The source object |
page_size |
the number of records to return per page (max 500) |
prefix |
Filters users by prefix (username, first name, or last name). The filter is case insensitive. |
limit |
The max number of records to return |
user_role |
Optionally filter by user role ("administrator",
"publisher", "viewer"). Pass in a vector of multiple roles to match any value
(boolean OR). When |
account_status |
Optionally filter by account status ("locked",
"licensed", "inactive"). Pass a vector of multiple statuses to match any
value (boolean OR). When |
Please see https://docs.posit.co/connect/api/#get-/v1/users for more information.
A tibble with the following columns:
email
: The user's email
username
: The user's username
first_name
: The user's first name
last_name
: The user's last name
user_role
: The user's role. It may have a value of administrator,
publisher or viewer.
created_time
: The timestamp (in RFC3339 format) when the user was
created in the Posit Connect server
updated_time
: The timestamp (in RFC3339 format) when the user was last
updated in the Posit Connect server
active_time
: The timestamp (in RFC3339 format) when the user was last
active on the Posit Connect server
confirmed
: When false, the created user must confirm their account
through an email. This feature is unique to password authentication.
locked
: Whether or not the user is locked
guid
: The user's GUID, or unique identifier, in UUID RFC4122 format
## Not run: library(connectapi) client <- connect() # Get all users get_users(client) # Get all licensed users get_users(client, account_status = "licensed") # Get all users who are administrators or publishers get_users(client, user_role = c("administrator", "publisher")) ## End(Not run)
## Not run: library(connectapi) client <- connect() # Get all users get_users(client) # Get all licensed users get_users(client, account_status = "licensed") # Get all users who are administrators or publishers get_users(client, user_role = c("administrator", "publisher")) ## End(Not run)
Gets the Vanity URL for a piece of content.
get_vanity_url(content)
get_vanity_url(content)
content |
A Content object |
A character string (or NULL if not defined)
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Get details about renderings (i.e. render history) or execute a variant on demand
get_variant_renderings(variant) variant_render(variant)
get_variant_renderings(variant) variant_render(variant)
variant |
An R6 Variant object. As returned by |
get_variant_renderings()
returns all renderings / content for a particular variant. Returns a tibble
variant_render()
executes a variant on demand. Returns a VariantTask
object
Other variant functions:
get_variants()
Gets the schedule associated with a Variant.
get_variant_schedule(variant)
get_variant_schedule(variant)
variant |
A Variant object, as returned by |
A VariantSchedule object
Other schedule functions:
get_timezones()
,
set_schedule()
get_variants(content) get_variant(content, key) get_variant_default(content)
get_variants(content) get_variant(content, key) get_variant_default(content)
content |
An R6 Content object. Returned from |
key |
The Variant key for a specific variant |
get_variants()
returns a tibble
with variant data for a content_item
get_variant_default()
returns the default variant for a content_item
get_variant()
returns a specific variant for a content_item
(specified by key
)
Other variant functions:
get_variant_renderings()
Other variant functions:
get_variant_renderings()
Other variant functions:
get_variant_renderings()
These functions help use Posit Connect's
configured authorization to query available branches and subdirectories for
deployment using deploy_repo()
repo_check_account(client, host) repo_check_branches(client, repository) repo_check_branches_ref(client, repository) repo_check_manifest_dirs(client, repository, branch)
repo_check_account(client, host) repo_check_branches(client, repository) repo_check_branches_ref(client, repository) repo_check_manifest_dirs(client, repository, branch)
client |
A Connect R6 object |
host |
The git repository host (with schema). For example, "https://github.com" |
repository |
The git repository to explore or consider deploying |
branch |
The git branch to explore for subdirectories |
repo_check_account()
messages whether an account is in use, and then returns that account
repo_check_branches()
retrieves which branches are available, returning in a named list
repo_check_manifest_dirs()
retrieves which directories contain a
manifest.json
, returning in a named list
connectapi::deploy_repo
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Create a Remote Group
groups_create_remote(connect, prefix, expect = 1, check = TRUE, exact = FALSE)
groups_create_remote(connect, prefix, expect = 1, check = TRUE, exact = FALSE)
connect |
An R6 Connect object. |
prefix |
character. The prefix of the user name to search for. |
expect |
number. Optional. The number of responses to expect for this search. |
check |
boolean. Optional. Whether to check for local existence first. |
exact |
boolean. Optional. Whether to only create groups whose name
exactly matches the provided |
The results of creating the groups.
Check whether a content item has a thumbnail.
has_thumbnail(content)
has_thumbnail(content)
content |
A content item. |
TRUE
if the content item has a thumbnail, otherwise FALSE
.
Throws an error if you do not have permission to view the thumbnail.
Other thumbnail functions:
delete_thumbnail()
,
get_thumbnail()
,
set_thumbnail()
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") has_thumbnail(item) ## End(Not run)
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") has_thumbnail(item) ## End(Not run)
Helper functions that make paging easier in the Posit Connect Server API.
Helper functions that make paging easier in the Posit Connect Server API.
page_cursor(client, req, limit = Inf) page_offset(client, req, limit = Inf)
page_cursor(client, req, limit = Inf) page_offset(client, req, limit = Inf)
client |
A Connect client object |
req |
The request that needs to be paged |
limit |
A row limit |
The aggregated results from all requests
The aggregated results from all requests
Get or set content permissions for a content item
content_add_user(content, guid, role = c("viewer", "owner")) content_add_group(content, guid, role = c("viewer", "owner")) content_delete_user(content, guid) content_delete_group(content, guid) get_user_permission(content, guid, add_owner = TRUE) get_my_permission(content, add_owner = TRUE) get_group_permission(content, guid) get_content_permissions(content, add_owner = TRUE)
content_add_user(content, guid, role = c("viewer", "owner")) content_add_group(content, guid, role = c("viewer", "owner")) content_delete_user(content, guid) content_delete_group(content, guid) get_user_permission(content, guid, add_owner = TRUE) get_my_permission(content, add_owner = TRUE) get_group_permission(content, guid) get_content_permissions(content, add_owner = TRUE)
content |
An R6 content object |
guid |
The guid associated with either a user (for |
role |
The role to assign to a user. Either "viewer" or "owner." Defaults to "viewer" |
add_owner |
Optional. Whether to include the owner in returned permission sets. Default is TRUE. The owner will have an NA_character_ permission "id" |
Permission modification:
content_add_*
adds a permission to the content
content_delete_*
removes a permission from the content
Permission retrieval:
get_content_permissions()
lists permissions
get_my_permission()
gets the permission associated with the caller.
get_user_permission()
gets the permissions associated with a given user.
It does not evaluate group memberships
get_group_permission()
gets the permissions associated with a given
group.
NOTE: by default, the owner is injected with an "NA_character_" permission id. This makes it easier to find / isolate this record.
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Polls a task, waiting for information about a deployment. If the task has
results, the output will be a modified "Task" object with task$get_data()
available to retrieve the results.
poll_task(task, wait = 1, callback = message)
poll_task(task, wait = 1, callback = message)
task |
A Task object |
wait |
The interval to wait between polling |
callback |
A function to be called for each message received. Set to NULL for no callback |
For a simple way to silence messages, set callback = NULL
Task The Task object that was input
Other deployment functions:
bundle_dir()
,
bundle_path()
,
bundle_static()
,
deploy()
,
download_bundle()
Class representing a Connect API client
Class representing a Connect API client
client <- Connect$new(server = 'connect.example.com', apiKey = 'mysecretkey') client$get_apps() client$get_tags()
This class allows a user to interact with a Connect server via the Connect API. Authentication is done by providing an API key.
server
The base URL of your Posit Connect server.
api_key
Your Posit Connect API key.
tags
The initial set of tags.
tag_map
The initial tag map.
httr_additions
An initial set of httr
configuration added to each HTTP call.
using_auth
Indicates that the API key is added to each HTTP call.
version
The server version.
get_connect()
Return this connect.
Connect$get_connect()
new()
Initialize a new connect.
Connect$new(server, api_key)
server
The base URL of your Posit Connect server.
api_key
Your Posit Connect API key.
httr_config()
Set additional httr
configuration that is added to each HTTP call.
Connect$httr_config(...)
...
Set of httr configurations.
print()
Print details about this instance.
Connect$print(...)
...
Ignored.
raise_error()
Raise an error when the HTTP result is an HTTP error.
Connect$raise_error(res)
res
HTTP result.
add_auth()
Returns HTTP authorization headers, or NULL when none are used.
Connect$add_auth()
api_url()
Build a URL relative to the API root
Connect$api_url(...)
...
path segments
server_url()
Build a URL relative to the server root
Connect$server_url(...)
...
path segments
request()
General wrapper around httr
verbs
Connect$request(method, url, ..., parser = "parsed")
method
HTTP request method
url
URL to request
...
Additional arguments passed to the request function
parser
How the response is parsed. If NULL
, the httr_response
will be returned. Otherwise, the argument is forwarded to
httr::content(res, as = parser)
.
GET()
Perform an HTTP GET request of the named API path.
Connect$GET(path, ..., url = self$api_url(path), parser = "parsed")
path
API path relative to the server's /__api__
root.
...
Arguments to httr::GET()
url
Target URL. Default uses path
, but provide url
to request
a server resource that is not under /__api__
parser
How the response is parsed. If NULL
, the httr_response
will be returned. Otherwise, the argument is forwarded to
httr::content(res, as = parser)
.
PUT()
Perform an HTTP PUT request of the named API path.
Connect$PUT( path, body = "{}", ..., url = self$api_url(path), encode = "json", parser = "parsed" )
path
API path relative to the server's /__api__
root.
body
The HTTP payload.
...
Arguments to httr::PUT()
url
Target URL. Default uses path
, but provide url
to request
a server resource that is not under /__api__
encode
How the payload is encoded.
parser
How the response is parsed. If NULL
, the httr_response
will be returned. Otherwise, the argument is forwarded to
httr::content(res, as = parser)
.
HEAD()
Perform an HTTP HEAD request of the named API path.
Connect$HEAD(path, ..., url = self$api_url(path))
path
API path relative to the server's /__api__
root.
...
Arguments to httr::HEAD()
url
Target URL. Default uses path
, but provide url
to request
a server resource that is not under /__api__
httr::content(res, as = parser)
.
DELETE()
Perform an HTTP DELETE request of the named API path. Returns the HTTP response object.
Connect$DELETE(path, ..., url = self$api_url(path), parser = NULL)
path
API path relative to the server's /__api__
root.
...
Arguments to httr::DELETE()
url
Target URL. Default uses path
, but provide url
to request
a server resource that is not under /__api__
parser
How the response is parsed. If NULL
, the httr_response
will be returned. Otherwise, the argument is forwarded to
httr::content(res, as = parser)
.
PATCH()
Perform an HTTP PATCH request of the named API path.
Connect$PATCH( path, body = "{}", ..., url = self$api_url(path), encode = "json", parser = "parsed" )
path
API path relative to the server's /__api__
root.
body
The HTTP payload.
...
Arguments to httr::PATCH()
url
Target URL. Default uses path
, but provide url
to request
a server resource that is not under /__api__
encode
How the payload is encoded.
parser
How the response is parsed. If NULL
, the httr_response
will be returned. Otherwise, the argument is forwarded to
httr::content(res, as = parser)
.
POST()
Perform an HTTP POST request of the named API path.
Connect$POST( path, body = "{}", ..., url = self$api_url(path), encode = "json", parser = "parsed" )
path
API path relative to the server's /__api__
root.
body
The HTTP payload.
...
Arguments to httr::POST()
url
Target URL. Default uses path
, but provide url
to request
a server resource that is not under /__api__
encode
How the payload is encoded.
parser
How the response is parsed. If NULL
, the httr_response
will be returned. Otherwise, the argument is forwarded to
httr::content(res, as = parser)
.
me()
Perform an HTTP GET request of the "me" server endpoint.
Connect$me()
get_dashboard_url()
Return the base URL of the Connect server.
Connect$get_dashboard_url()
get_tags()
Return all tags.
Connect$get_tags(use_cache = FALSE)
use_cache
Indicates that a cached set of tags is used.
get_tag_id()
Get the identifier for the named tag.
Connect$get_tag_id(tagname)
tagname
The name of the tag.
get_tag_tree()
Get the tag tree.
Connect$get_tag_tree()
tag_create_safe()
Create a tag.
Connect$tag_create_safe(name, parent_id = NULL)
name
The tag name.
parent_id
The parent identifier.
tag_create()
Create a tag.
Connect$tag_create(name, parent_id = NULL)
name
The tag name.
parent_id
The parent identifier.
tag()
Get a tag.
Connect$tag(id = NULL)
id
The tag identifier.
tag_delete()
Delete a tag.
Connect$tag_delete(id)
id
The tag identifier.
get_apps()
Get content items.
Connect$get_apps(filter = NULL, .collapse = "&", .limit = Inf, page_size = 25)
filter
Named list containing filter conditions.
.collapse
How multiple filters are combined.
.limit
The limit.
page_size
The page size.
get_schedule()
Get a schedule.
Connect$get_schedule(schedule_id)
schedule_id
The schedule identifier.
content_create()
Create content.
Connect$content_create(name, title = name, ...)
name
The content name.
title
The content title.
...
Other content fields.
content_upload()
Upload a content bundle.
Connect$content_upload(bundle_path, guid)
bundle_path
The path to the bundle archive.
guid
The content GUID.
content_deploy()
Deploy a content bundle.
Connect$content_deploy(guid, bundle_id)
guid
The content GUID.
bundle_id
The bundle identifier.
content()
Get a content item.
Connect$content( guid = NULL, owner_guid = NULL, name = NULL, include = "tags,owner" )
guid
The content GUID.
owner_guid
The target content owner.
name
The target name.
include
Additional response fields.
task()
Get a task.
Connect$task(task_id, first = 0, wait = 5)
task_id
The task identifier.
first
The initial status position.
wait
Maximum time to wait for update.
set_content_tag()
Set a tag for a content item.
Connect$set_content_tag(content_id, tag_id)
content_id
The content identifier.
tag_id
The tag identifier.
remove_content_tag()
Remove a tag from a content item.
Connect$remove_content_tag(content_id, tag_id)
content_id
The content identifier.
tag_id
The tag identifier.
user()
Get user details.
Connect$user(guid)
guid
The user GUID.
users()
Get users.
Connect$users( page_number = 1, prefix = NULL, page_size = 500, user_role = NULL, account_status = NULL )
page_number
The page number.
prefix
The search term.
page_size
The page size.
user_role
Filter by user role.
account_status
Filter by account status.
users_remote()
Get remote users.
Connect$users_remote(prefix)
prefix
The search term.
users_create()
Create a user.
Connect$users_create( username, email, first_name = NULL, last_name = NULL, password = NULL, user_must_set_password = NULL, user_role = NULL, unique_id = NULL )
username
The username.
email
Email address.
first_name
First name.
last_name
Last name.
password
The password.
user_must_set_password
Indicates that user sets password on first login.
user_role
Role for user.
unique_id
Identifier for user.
users_create_remote()
Create a remote user.
Connect$users_create_remote(temp_ticket)
temp_ticket
Ticket identifying target remote user.
users_lock()
Lock a user.
Connect$users_lock(user_guid)
user_guid
User GUID.
users_unlock()
Unlock a user.
Connect$users_unlock(user_guid)
user_guid
User GUID.
users_update()
Update a user.
Connect$users_update(user_guid, ...)
user_guid
User GUID.
...
User fields.
groups()
Get groups.
Connect$groups(page_number = 1, prefix = NULL, page_size = 500)
page_number
The page number.
prefix
The search term.
page_size
The page size.
group_members()
Get group members.
Connect$group_members(guid)
guid
The group GUID.
group_member_add()
Add a group member.
Connect$group_member_add(group_guid, user_guid)
group_guid
The group GUID.
user_guid
The user GUID.
group_member_remove()
Remove a group member.
Connect$group_member_remove(group_guid, user_guid)
group_guid
The group GUID.
user_guid
The user GUID.
groups_create()
Create a group.
Connect$groups_create(name)
name
The group name.
groups_create_remote()
Create a remote group.
Connect$groups_create_remote(temp_ticket)
temp_ticket
Ticket identifying target remote group.
groups_remote()
Get remote groups.
Connect$groups_remote(prefix = NULL, limit = 500)
prefix
The search term.
limit
The maximal result set size.
inst_content_visits()
Get (non-interactive) content visits.
Connect$inst_content_visits( content_guid = NULL, min_data_version = NULL, from = NULL, to = NULL, limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE )
content_guid
Content GUID.
min_data_version
Data version for request.
from
Start of range.
to
End of range.
limit
Result set size.
previous
Previous item.
nxt
Next item.
asc_order
Indicates ascending result order.
inst_shiny_usage()
Get interactive content visits.
Get (non-interactive) content visits.
Connect$inst_shiny_usage( content_guid = NULL, min_data_version = NULL, from = NULL, to = NULL, limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE )
content_guid
Content GUID.
min_data_version
Data version for request.
from
Start of range.
to
End of range.
limit
Result set size.
previous
Previous item.
nxt
Next item.
asc_order
Indicates ascending result order.
procs()
Get running processes.
Connect$procs()
repo_account()
Determine if Git repository is associated with authorization.
Connect$repo_account(host)
host
Repository URL.
repo_branches()
Get Git repository branches.
Connect$repo_branches(repo)
repo
Repository URL.
repo_manifest_dirs()
Get Git repository directories.
Connect$repo_manifest_dirs(repo, branch)
repo
Repository URL.
branch
Repository branch.
schedules()
Get schedules.
Connect$schedules( start = Sys.time(), end = Sys.time() + 60 * 60 * 24 * 7, detailed = FALSE )
start
Starting time.
end
Ending time.
detailed
Indicates detailed schedule information.
docs()
Get documentation.
Connect$docs(docs = "api", browse = TRUE)
docs
Named document.
browse
Open a browser.
audit_logs()
Get auditing.
Connect$audit_logs(limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE)
limit
Result set size.
previous
Previous item.
nxt
Next item.
asc_order
Indicates ascending result order.
server_settings_r()
Get R installations.
Connect$server_settings_r()
server_settings()
Get server settings.
Connect$server_settings()
clone()
The objects of this class are cloneable with this method.
Connect$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
Content
,
ContentTask
,
Environment
,
Task
,
Vanity
,
Variant
,
VariantSchedule
,
VariantTask
Promote content from one Connect server to another
promote(from, to, to_key, from_key, name)
promote(from, to, to_key, from_key, name)
from |
The url for the server containing the content (the originating server) |
to |
The url for the server where the content will be deployed (the destination server) |
to_key |
An API key on the destination "to" server. If the destination content is going to be updated, the API key must belong to a user with collaborator access on the content that will be updated. If the destination content is to be created new, the API key must belong to a user with publisher privileges. |
from_key |
An API key on the originating "from" server. The API key must belong to a user with collaborator access to the content to be promoted. |
name |
The name of the content on the originating "from" server. If content with the same name is found on the destination server, the content will be updated. If no content on the destination server has a matching name, a new endpoint will be created. |
The URL for the content on the destination "to" server
Please use set_thumbnail
instead.
Set the Content Image using a variety of methods.
set_image_path(content, path) set_image_url(content, url) set_image_webshot(content, ...)
set_image_path(content, path) set_image_url(content, url) set_image_webshot(content, ...)
content |
A content object |
path |
The path to an image on disk |
url |
The url for an image |
... |
Additional arguments passed on to |
NOTE: set_image_webshot()
requires webshot2::webshot()
, but currently
skips and warns for any content that requires authentication until the
webshot2
package supports authentication.
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Set the RunAs
user for a piece of content.
The run_as_current_user
flag only does anything if:
set_run_as(content, run_as, run_as_current_user = FALSE)
set_run_as(content, run_as, run_as_current_user = FALSE)
content |
an R6 Content item |
run_as |
The RunAs user to use for this content |
run_as_current_user |
Whether to run this content as the viewer of the application |
PAM is the authentication method
Applications.RunAsCurrentUser
is enabled on the server
Also worth noting that the run_as
user must exist on the Posit Connect
server (as a linux user) and have appropriate group memberships, or you will
get a 400: Bad Request
. Set to NULL
to use the default RunAs user / unset
any current configuration.
To "read" the current RunAs user, use the Content
object or get_content()
function.
a Content object, updated with new details
connectapi::content_update
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
Sets the schedule for a given Variant. Requires a
Schedule
object (as returned by get_variant_schedule()
)
set_schedule(.schedule, ...) set_schedule_minute( .schedule, n = 30, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_hour( .schedule, n = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_day( .schedule, n = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_weekday( .schedule, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_week( .schedule, n = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_dayofweek( .schedule, days, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_semimonth( .schedule, first = TRUE, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_dayofmonth( .schedule, n = 1, day = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_dayweekofmonth( .schedule, n = 1, day = 1, week = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_year( .schedule, n = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_remove(.schedule) schedule_describe(.schedule)
set_schedule(.schedule, ...) set_schedule_minute( .schedule, n = 30, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_hour( .schedule, n = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_day( .schedule, n = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_weekday( .schedule, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_week( .schedule, n = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_dayofweek( .schedule, days, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_semimonth( .schedule, first = TRUE, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_dayofmonth( .schedule, n = 1, day = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_dayweekofmonth( .schedule, n = 1, day = 1, week = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_year( .schedule, n = 1, start_time = Sys.time(), activate = TRUE, email = FALSE, timezone = Sys.timezone() ) set_schedule_remove(.schedule) schedule_describe(.schedule)
.schedule |
A schedule object. As returned by |
... |
Scheduling parameters |
n |
The "number of" iterations |
start_time |
The start time of the schedule |
activate |
Whether to publish the output of this schedule |
email |
Whether to send emails on this schedule |
timezone |
The timezone to use for setting the schedule. Defaults to |
days |
The days of the week (0-6) |
first |
logical Whether to execute on the 1st and 15th (TRUE) or 14th and last (FALSE) |
day |
The day of the week (0-6) or day of the month (0-31) |
week |
The week of the month (0-5) |
schedule |
A JSON blob (as a string) describing the schedule. See "More Details" |
set_schedule()
is a raw interface to Posit Connect's schedule
API
set_schedule_*()
functions provide handy wrappers around set_schedule()
set_schedule_remove()
removes a schedule / un-schedules a variant
Beware, using set_schedule()
currently uses the Posit Connect schedule
API
directly, and so can be a little clunky. Using the set_schedule_*()
is generally
recommended.
An updated Schedule object
Other schedule functions:
get_timezones()
,
get_variant_schedule()
Set the thumbnail for a content item.
set_thumbnail(content, path)
set_thumbnail(content, path)
content |
A content item. |
path |
Either a path to a local file or a URL to an image available over
HTTP/HTTPS. If |
The content item (invisibly).
Other thumbnail functions:
delete_thumbnail()
,
get_thumbnail()
,
has_thumbnail()
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_vanity_url()
,
swap_vanity_url()
,
verify_content_name()
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") set_thumbnail(item, "resources/image.png") ## End(Not run)
## Not run: client <- connect() item <- content_item(client, "8f37d6e0-3395-4a2c-aa6a-d7f2fe1babd0") set_thumbnail(item, "resources/image.png") ## End(Not run)
Sets the Vanity URL for a piece of content.
set_vanity_url(content, url, force = FALSE)
set_vanity_url(content, url, force = FALSE)
content |
A Content object |
url |
The path component of the URL |
force |
optional. Default FALSE. Whether to force-reassign a vanity URL that already exists |
An updated Content object
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
swap_vanity_url()
,
verify_content_name()
## Not run: bnd <- bundle_dir("~/my/directory") connect() %>% deploy(bnd) %>% set_vanity_url("a/vanity/url") ## End(Not run)
## Not run: bnd <- bundle_dir("~/my/directory") connect() %>% deploy(bnd) %>% set_vanity_url("a/vanity/url") ## End(Not run)
Swaps the Vanity URLs between two pieces of content
swap_vanity_url(from_content, to_content)
swap_vanity_url(from_content, to_content)
from_content |
A Content object |
to_content |
A Content object |
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
verify_content_name()
Task
Task
An R6 class that represents a Task
connect
The Connect instance.
task
The task.
data
The task data.
new()
Initialize this task.
Task$new(connect, task)
connect
The Connect
instance.
task
The task data.
get_connect()
Return the associated Connect instance.
Task$get_connect()
get_task()
Return the underlying task.
Task$get_task()
add_data()
Set the data.
Task$add_data(data)
data
The data.
get_data()
Get the data.
Task$get_data()
print()
Print this object.
Task$print(...)
...
Unused.
clone()
The objects of this class are cloneable with this method.
Task$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
Content
,
ContentTask
,
Environment
,
PositConnect
,
Vanity
,
Variant
,
VariantSchedule
,
VariantTask
A lazy tibble that automatically pages through API requests when collect
ed.
tbl_connect( src, from = c("users", "groups", "content", "usage_shiny", "usage_static", "audit_logs"), ... )
tbl_connect( src, from = c("users", "groups", "content", "usage_shiny", "usage_static", "audit_logs"), ... )
src |
The source object |
from |
The type of tibble |
... |
Additional arguments that are not yet implemented |
A tbl_connect
object
Get user details
user_guid_from_username(client, username)
user_guid_from_username(client, username)
client |
A Connect R6 object |
username |
The user's username |
user_guid_from_username()
is a helper to retrieve a user GUID, given the
user's username. It is useful in Shiny applications for using session$user
The remote user creation workflow involves authentication providers like LDAP
that involve a queryable identity store. This helper wraps the API calls
necessary to retrieve information about and then create such a user. It
functions with a "fuzzy match" prefix
by default, but if you want to
instantiate users directly, you should set exact = TRUE
.
users_create_remote(connect, prefix, expect = 1, check = TRUE, exact = FALSE)
users_create_remote(connect, prefix, expect = 1, check = TRUE, exact = FALSE)
connect |
An R6 Connect object. |
prefix |
character. The prefix of the user name to search for. |
expect |
number. Optional. The number of responses to expect for this search. |
check |
boolean. Optional. Whether to check for local existence first. |
exact |
boolean. Optional. Whether to only create users whose username
exactly matches the provided |
NOTE: there can be problems with usernames that are not unique. Please open an issue if you run into any problems.
The results of creating the users.
Vanity
Vanity
An R6 class that represents a Vanity URL
connectapi::Content
-> Vanity
vanity
The vanity.
connectapi::Content$bundle_delete()
connectapi::Content$bundle_download()
connectapi::Content$danger_delete()
connectapi::Content$deploy()
connectapi::Content$environment()
connectapi::Content$environment_all()
connectapi::Content$environment_set()
connectapi::Content$get_bundles()
connectapi::Content$get_connect()
connectapi::Content$get_content()
connectapi::Content$get_content_remote()
connectapi::Content$get_dashboard_url()
connectapi::Content$get_url()
connectapi::Content$internal_content()
connectapi::Content$job()
connectapi::Content$jobs()
connectapi::Content$permissions()
connectapi::Content$permissions_add()
connectapi::Content$permissions_delete()
connectapi::Content$permissions_update()
connectapi::Content$repo_enable()
connectapi::Content$repo_set()
connectapi::Content$tag_delete()
connectapi::Content$tag_set()
connectapi::Content$tags()
connectapi::Content$update()
connectapi::Content$variants()
new()
Initialize this vanity.
Vanity$new(connect, content, vanity)
connect
The Connect
instance.
content
The Content
instance.
vanity
The vanity data.
get_vanity()
Return the underlying vanity.
Vanity$get_vanity()
print()
Print this object.
Vanity$print(...)
...
Unused.
clone()
The objects of this class are cloneable with this method.
Vanity$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
Content
,
ContentTask
,
Environment
,
PositConnect
,
Task
,
Variant
,
VariantSchedule
,
VariantTask
vanity_is_available(connect, vanity)
vanity_is_available(connect, vanity)
connect |
A Connect R6 object |
vanity |
string of the vanity URL to check |
logical indicating if the vanity URL is available.
Other audit functions:
audit_access_open()
,
audit_r_versions()
,
audit_runas()
Variant
Variant
An R6 class that represents a Variant
connectapi::Content
-> Variant
key
The variant key.
variant
The variant.
connectapi::Content$bundle_delete()
connectapi::Content$bundle_download()
connectapi::Content$danger_delete()
connectapi::Content$deploy()
connectapi::Content$environment()
connectapi::Content$environment_all()
connectapi::Content$environment_set()
connectapi::Content$get_bundles()
connectapi::Content$get_connect()
connectapi::Content$get_content()
connectapi::Content$get_content_remote()
connectapi::Content$internal_content()
connectapi::Content$permissions()
connectapi::Content$permissions_add()
connectapi::Content$permissions_delete()
connectapi::Content$permissions_update()
connectapi::Content$repo_enable()
connectapi::Content$repo_set()
connectapi::Content$tag_delete()
connectapi::Content$tag_set()
connectapi::Content$tags()
connectapi::Content$update()
connectapi::Content$variants()
get_variant()
Get the underlying variant data.
Variant$get_variant()
get_variant_remote()
Get and store the (remote) variant data.
Variant$get_variant_remote()
new()
Initialize this variant.
Variant$new(connect, content, key)
connect
The Connect
instance.
content
The Content
instance.
key
The variant key.
send_mail()
Mail previously rendered content.
Variant$send_mail(to = c("me", "collaborators", "collaborators_viewers"))
to
Targeting.
get_schedule()
Get the (remote) schedule data.
Variant$get_schedule()
get_schedule_remote()
Get the (remote) schedule data.
Variant$get_schedule_remote()
get_subscribers()
Get the subscribers.
Variant$get_subscribers()
remove_subscriber()
Remove a named subscriber.
Variant$remove_subscriber(guid)
guid
User GUID.
add_subscribers()
Add named subscribers.
Variant$add_subscribers(guids)
guids
User GUIDs.
render()
Render this variant.
Variant$render()
renderings()
List the renderings of this variant.
Variant$renderings()
update_variant()
Update this variant.
Variant$update_variant(...)
...
Target fields and values.
jobs()
Jobs for this variant.
Variant$jobs()
job()
Return single job for this variant.
Variant$job(key)
key
The job key.
get_url()
Return the URL for this variant.
Variant$get_url()
get_url_rev()
Return the URL associated with one rendering for this variant.
Variant$get_url_rev(rev)
rev
Rendering identifier.
get_dashboard_url()
Return the URL for this variant in the Posit Connect dashboard.
Variant$get_dashboard_url(pane = "access")
pane
The pane in the dashboard to link to.
print()
Print this object.
Variant$print(...)
...
Unused.
clone()
The objects of this class are cloneable with this method.
Variant$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
Content
,
ContentTask
,
Environment
,
PositConnect
,
Task
,
Vanity
,
VariantSchedule
,
VariantTask
VariantSchedule
VariantSchedule
An R6 class that represents a Schedule
connectapi::Content
-> connectapi::Variant
-> VariantSchedule
schedule_data
The schedule data.
connectapi::Content$bundle_delete()
connectapi::Content$bundle_download()
connectapi::Content$danger_delete()
connectapi::Content$deploy()
connectapi::Content$environment()
connectapi::Content$environment_all()
connectapi::Content$environment_set()
connectapi::Content$get_bundles()
connectapi::Content$get_connect()
connectapi::Content$get_content()
connectapi::Content$get_content_remote()
connectapi::Content$internal_content()
connectapi::Content$permissions()
connectapi::Content$permissions_add()
connectapi::Content$permissions_delete()
connectapi::Content$permissions_update()
connectapi::Content$repo_enable()
connectapi::Content$repo_set()
connectapi::Content$tag_delete()
connectapi::Content$tag_set()
connectapi::Content$tags()
connectapi::Content$update()
connectapi::Content$variants()
connectapi::Variant$add_subscribers()
connectapi::Variant$get_dashboard_url()
connectapi::Variant$get_subscribers()
connectapi::Variant$get_url()
connectapi::Variant$get_url_rev()
connectapi::Variant$get_variant()
connectapi::Variant$get_variant_remote()
connectapi::Variant$job()
connectapi::Variant$jobs()
connectapi::Variant$remove_subscriber()
connectapi::Variant$render()
connectapi::Variant$renderings()
connectapi::Variant$send_mail()
connectapi::Variant$update_variant()
new()
Initialize this schedule.
VariantSchedule$new(connect, content, key, schedule)
connect
The Connect
instance.
content
The Content
instance.
key
The variant key.
schedule
The schedule data.
GET()
Perform an HTTP GET request of the named API path. Returns an object parsed from the HTTP response.
VariantSchedule$GET(path)
path
API path.
POST()
Perform an HTTP POST request of the named API path. Returns an object parsed from the HTTP response.
VariantSchedule$POST(path, body)
path
API path.
body
The HTTP payload.
DELETE()
Perform an HTTP DELETE request of the named API path. Returns the HTTP response object.
VariantSchedule$DELETE(path)
path
API path.
set_schedule()
Set the schedule for this variant
VariantSchedule$set_schedule(...)
...
Schedule fields.
is_empty()
Return if this variant has a schedule.
VariantSchedule$is_empty()
print()
Print this object.
VariantSchedule$print(...)
...
Unused.
get_schedule()
Get the schedule data.
VariantSchedule$get_schedule()
get_schedule_remote()
Get and store the (remote) schedule data.
VariantSchedule$get_schedule_remote()
describe_schedule()
Description of the associated schedule.
VariantSchedule$describe_schedule()
clone()
The objects of this class are cloneable with this method.
VariantSchedule$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
Content
,
ContentTask
,
Environment
,
PositConnect
,
Task
,
Vanity
,
Variant
,
VariantTask
VariantTask
VariantTask
An R6 class that represents a Variant Task
connectapi::Content
-> connectapi::Variant
-> VariantTask
task
The task.
data
The variant data.
connectapi::Content$bundle_delete()
connectapi::Content$bundle_download()
connectapi::Content$danger_delete()
connectapi::Content$deploy()
connectapi::Content$environment()
connectapi::Content$environment_all()
connectapi::Content$environment_set()
connectapi::Content$get_bundles()
connectapi::Content$get_connect()
connectapi::Content$get_content()
connectapi::Content$get_content_remote()
connectapi::Content$internal_content()
connectapi::Content$permissions()
connectapi::Content$permissions_add()
connectapi::Content$permissions_delete()
connectapi::Content$permissions_update()
connectapi::Content$repo_enable()
connectapi::Content$repo_set()
connectapi::Content$tag_delete()
connectapi::Content$tag_set()
connectapi::Content$tags()
connectapi::Content$update()
connectapi::Content$variants()
connectapi::Variant$add_subscribers()
connectapi::Variant$get_dashboard_url()
connectapi::Variant$get_schedule()
connectapi::Variant$get_schedule_remote()
connectapi::Variant$get_subscribers()
connectapi::Variant$get_url()
connectapi::Variant$get_url_rev()
connectapi::Variant$get_variant()
connectapi::Variant$get_variant_remote()
connectapi::Variant$job()
connectapi::Variant$jobs()
connectapi::Variant$remove_subscriber()
connectapi::Variant$render()
connectapi::Variant$renderings()
connectapi::Variant$send_mail()
connectapi::Variant$update_variant()
new()
Initialize this variant task.
VariantTask$new(connect, content, key, task)
connect
The Connect
instance.
content
The Content
instance.
key
The variant key.
task
The task data.
get_task()
Return the underlying task.
VariantTask$get_task()
add_data()
Set the data.
VariantTask$add_data(data)
data
The data.
get_data()
Get the data.
VariantTask$get_data()
print()
Print this object.
VariantTask$print(...)
...
Unused.
clone()
The objects of this class are cloneable with this method.
VariantTask$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 classes:
Bundle
,
Content
,
ContentTask
,
Environment
,
PositConnect
,
Task
,
Vanity
,
Variant
,
VariantSchedule
Ensures that a content name fits the specifications / requirements of Posit Connect. Throws an error if content name is invalid. Content names (as of the time of writing) must be between 3 and 64 alphanumeric characters, dashes, and underscores
verify_content_name(name)
verify_content_name(name)
name |
The proposed content name |
The name (or an error if invalid)
connectapi::create_random_name
Other content functions:
content_delete()
,
content_item()
,
content_title()
,
content_update()
,
create_random_name()
,
dashboard_url()
,
dashboard_url_chr()
,
delete_thumbnail()
,
delete_vanity_url()
,
deploy_repo()
,
get_bundles()
,
get_environment()
,
get_image()
,
get_jobs()
,
get_thumbnail()
,
get_vanity_url()
,
git
,
has_thumbnail()
,
permissions
,
set_image_path()
,
set_run_as()
,
set_thumbnail()
,
set_vanity_url()
,
swap_vanity_url()