Skip to contents

Class representing a Connect API client

Class representing a Connect API client

Usage


client <- Connect$new(server = 'connect.example.com',
  apiKey = 'mysecretkey')
client$get_apps()
client$get_tags()

Details

This class allows a user to interact with a Connect server via the Connect API. Authentication is done by providing an API key.

Public fields

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.

Active bindings

version

The server version.

Methods


Method get_connect()

Return this connect.

Usage

Connect$get_connect()


Method new()

Initialize a new connect.

Usage

Connect$new(server, api_key)

Arguments

server

The base URL of your Posit Connect server.

api_key

Your Posit Connect API key.


Method httr_config()

Set additional httr configuration that is added to each HTTP call.

Usage

Connect$httr_config(...)

Arguments

...

Set of httr configurations.


Method print()

Print details about this instance.

Usage

Connect$print(...)

Arguments

...

Ignored.


Method raise_error()

Raise an error when the HTTP result is an HTTP error.

Usage

Connect$raise_error(res)

Arguments

res

HTTP result.


Method add_auth()

Returns HTTP authorization headers, or NULL when none are used.

Usage

Connect$add_auth()


Method api_url()

Build a URL relative to the API root

Usage

Connect$api_url(...)

Arguments

...

path segments


Method server_url()

Build a URL relative to the server root

Usage

Connect$server_url(...)

Arguments

...

path segments


Method request()

General wrapper around httr verbs

Usage

Connect$request(method, url, ..., parser = "parsed")

Arguments

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).


Method GET()

Perform an HTTP GET request of the named API path.

Usage

Connect$GET(path, ..., url = self$api_url(path), parser = "parsed")

Arguments

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).


Method PUT()

Perform an HTTP PUT request of the named API path.

Usage

Connect$PUT(
  path,
  body = "{}",
  ...,
  url = self$api_url(path),
  encode = "json",
  parser = "parsed"
)

Arguments

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).


Method HEAD()

Perform an HTTP HEAD request of the named API path.

Usage

Connect$HEAD(path, ..., url = self$api_url(path))

Arguments

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).


Method DELETE()

Perform an HTTP DELETE request of the named API path. Returns the HTTP response object.

Usage

Connect$DELETE(path, ..., url = self$api_url(path), parser = NULL)

Arguments

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).


Method PATCH()

Perform an HTTP PATCH request of the named API path.

Usage

Connect$PATCH(
  path,
  body = "{}",
  ...,
  url = self$api_url(path),
  encode = "json",
  parser = "parsed"
)

Arguments

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).


Method POST()

Perform an HTTP POST request of the named API path.

Usage

Connect$POST(
  path,
  body = "{}",
  ...,
  url = self$api_url(path),
  encode = "json",
  parser = "parsed"
)

Arguments

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).


Method me()

Perform an HTTP GET request of the "me" server endpoint.

Usage

Connect$me()


Method get_dashboard_url()

Return the base URL of the Connect server.

Usage

Connect$get_dashboard_url()


Method get_tags()

Return all tags.

Usage

Connect$get_tags(use_cache = FALSE)

Arguments

use_cache

Indicates that a cached set of tags is used.


Method get_tag_id()

Get the identifier for the named tag.

Usage

Connect$get_tag_id(tagname)

Arguments

tagname

The name of the tag.


Method get_tag_tree()

Get the tag tree.

Usage

Connect$get_tag_tree()


Method tag_create_safe()

Create a tag.

Usage

Connect$tag_create_safe(name, parent_id = NULL)

Arguments

name

The tag name.

parent_id

The parent identifier.


Method tag_create()

Create a tag.

Usage

Connect$tag_create(name, parent_id = NULL)

Arguments

name

The tag name.

parent_id

The parent identifier.


Method tag()

Get a tag.

Usage

Connect$tag(id = NULL)

Arguments

id

The tag identifier.


Method tag_delete()

Delete a tag.

Usage

Connect$tag_delete(id)

Arguments

id

The tag identifier.


Method get_apps()

Get content items.

Usage

Connect$get_apps(filter = NULL, .collapse = "&", .limit = Inf, page_size = 25)

Arguments

filter

Named list containing filter conditions.

.collapse

How multiple filters are combined.

.limit

The limit.

page_size

The page size.


Method get_schedule()

Get a schedule.

Usage

Connect$get_schedule(schedule_id)

Arguments

schedule_id

The schedule identifier.


Method content_create()

Create content.

Usage

Connect$content_create(name, title = name, ...)

Arguments

name

The content name.

title

The content title.

...

Other content fields.


Method content_upload()

Upload a content bundle.

Usage

Connect$content_upload(bundle_path, guid)

Arguments

bundle_path

The path to the bundle archive.

guid

The content GUID.


Method content_deploy()

Deploy a content bundle.

Usage

Connect$content_deploy(guid, bundle_id)

Arguments

guid

The content GUID.

bundle_id

The bundle identifier.


Method content()

Get a content item.

Usage

Connect$content(
  guid = NULL,
  owner_guid = NULL,
  name = NULL,
  include = "tags,owner"
)

Arguments

guid

The content GUID.

owner_guid

The target content owner.

name

The target name.

include

Additional response fields.


Method task()

Get a task.

Usage

Connect$task(task_id, first = 0, wait = 5)

Arguments

task_id

The task identifier.

first

The initial status position.

wait

Maximum time to wait for update.


Method set_content_tag()

Set a tag for a content item.

Usage

Connect$set_content_tag(content_id, tag_id)

Arguments

content_id

The content identifier.

tag_id

The tag identifier.


Method remove_content_tag()

Remove a tag from a content item.

Usage

Connect$remove_content_tag(content_id, tag_id)

Arguments

content_id

The content identifier.

tag_id

The tag identifier.


Method user()

Get user details.

Usage

Connect$user(guid)

Arguments

guid

The user GUID.


Method users()

Get users.

Usage

Connect$users(
  page_number = 1,
  prefix = NULL,
  page_size = 500,
  user_role = NULL,
  account_status = NULL
)

Arguments

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.


Method users_remote()

Get remote users.

Usage

Connect$users_remote(prefix)

Arguments

prefix

The search term.


Method users_create()

Create a user.

Usage

Connect$users_create(
  username,
  email,
  first_name = NULL,
  last_name = NULL,
  password = NULL,
  user_must_set_password = NULL,
  user_role = NULL,
  unique_id = NULL
)

Arguments

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.


Method users_create_remote()

Create a remote user.

Usage

Connect$users_create_remote(temp_ticket)

Arguments

temp_ticket

Ticket identifying target remote user.


Method users_lock()

Lock a user.

Usage

Connect$users_lock(user_guid)

Arguments

user_guid

User GUID.


Method users_unlock()

Unlock a user.

Usage

Connect$users_unlock(user_guid)

Arguments

user_guid

User GUID.


Method users_update()

Update a user.

Usage

Connect$users_update(user_guid, ...)

Arguments

user_guid

User GUID.

...

User fields.


Method groups()

Get groups.

Usage

Connect$groups(page_number = 1, prefix = NULL, page_size = 500)

Arguments

page_number

The page number.

prefix

The search term.

page_size

The page size.


Method group_members()

Get group members.

Usage

Connect$group_members(guid)

Arguments

guid

The group GUID.


Method group_member_add()

Add a group member.

Usage

Connect$group_member_add(group_guid, user_guid)

Arguments

group_guid

The group GUID.

user_guid

The user GUID.


Method group_member_remove()

Remove a group member.

Usage

Connect$group_member_remove(group_guid, user_guid)

Arguments

group_guid

The group GUID.

user_guid

The user GUID.


Method groups_create()

Create a group.

Usage

Connect$groups_create(name)

Arguments

name

The group name.


Method groups_create_remote()

Create a remote group.

Usage

Connect$groups_create_remote(temp_ticket)

Arguments

temp_ticket

Ticket identifying target remote group.


Method groups_remote()

Get remote groups.

Usage

Connect$groups_remote(prefix = NULL, limit = 500)

Arguments

prefix

The search term.

limit

The maximal result set size.


Method group_content()

Get content to which a group has access

Usage

Connect$group_content(guid)

Arguments

guid

The group GUID.


Method inst_content_visits()

Get (non-interactive) content visits.

Usage

Connect$inst_content_visits(
  content_guid = NULL,
  min_data_version = NULL,
  from = NULL,
  to = NULL,
  limit = 500,
  previous = NULL,
  nxt = NULL,
  asc_order = TRUE
)

Arguments

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.


Method inst_shiny_usage()

Get interactive content visits.

Get (non-interactive) content visits.

Usage

Connect$inst_shiny_usage(
  content_guid = NULL,
  min_data_version = NULL,
  from = NULL,
  to = NULL,
  limit = 500,
  previous = NULL,
  nxt = NULL,
  asc_order = TRUE
)

Arguments

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.


Method procs()

Get running processes.

Usage

Connect$procs()


Method repo_account()

Determine if Git repository is associated with authorization.

Usage

Connect$repo_account(host)

Arguments

host

Repository URL.


Method repo_branches()

Get Git repository branches.

Usage

Connect$repo_branches(repo)

Arguments

repo

Repository URL.


Method repo_manifest_dirs()

Get Git repository directories.

Usage

Connect$repo_manifest_dirs(repo, branch)

Arguments

repo

Repository URL.

branch

Repository branch.


Method schedules()

Get schedules.

Usage

Connect$schedules(
  start = Sys.time(),
  end = Sys.time() + 60 * 60 * 24 * 7,
  detailed = FALSE
)

Arguments

start

Starting time.

end

Ending time.

detailed

Indicates detailed schedule information.


Method docs()

Get documentation.

Usage

Connect$docs(docs = "api", browse = TRUE)

Arguments

docs

Named document.

browse

Open a browser.


Method audit_logs()

Get auditing.

Usage

Connect$audit_logs(limit = 500, previous = NULL, nxt = NULL, asc_order = TRUE)

Arguments

limit

Result set size.

previous

Previous item.

nxt

Next item.

asc_order

Indicates ascending result order.


Method vanities()

Get all vanity URLs

Usage

Connect$vanities()


Method server_settings_r()

Get R installations.

Usage

Connect$server_settings_r()


Method server_settings()

Get server settings.

Usage

Connect$server_settings()


Method clone()

The objects of this class are cloneable with this method.

Usage

Connect$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.