Skip to content

Commit ee7873f

Browse files
authored
Merge pull request #191 from rstudio/aron-doc
roxygen silence
2 parents d1ecd6c + 5227343 commit ee7873f

15 files changed

+1586
-1
lines changed

R/connect.R

+197
Large diffs are not rendered by default.

R/content.R

+78
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,57 @@ Content <- R6::R6Class(
1212
#' @field content The content details from Posit Connect
1313
content = NULL,
1414

15+
#' @description Initialize this content.
16+
#' @param connect The `Connect` instance.
17+
#' @param content The content data.
1518
initialize = function(connect, content) {
1619
validate_R6_class(connect, "Connect")
1720
self$connect <- connect
1821
# TODO: need to check that content has
1922
# at least guid, url, title to be functional
2023
self$content <- content
2124
},
25+
#' @description Returns the `Connect` instance.
2226
get_connect = function() {
2327
self$connect
2428
},
29+
#' @description Returns the underlying content data.
2530
get_content = function() {
2631
self$content
2732
},
33+
#' @description Obtain the content data from the Connect server.
2834
get_content_remote = function() {
2935
new_content_details <- self$get_connect()$content(self$get_content()$guid)
3036
self$content <- new_content_details
3137
self$get_content()
3238
},
39+
#' @description Return the set of content bundles.
3340
get_bundles = function() {
3441
url <- glue::glue("v1/content/{self$get_content()$guid}/bundles")
3542
self$get_connect()$GET(url)
3643
},
44+
#' @description Download the source archive for a content bundle.
45+
#' @param bundle_id The bundle identifer.
46+
#' @param filename Where to write the result.
47+
#' @param overwrite Overwrite an existing filename.
3748
bundle_download = function(bundle_id, filename = tempfile(pattern = "bundle", fileext=".tar.gz"), overwrite = FALSE) {
3849
url <- glue::glue("/v1/content/{self$get_content()$guid}/bundles/{bundle_id}/download")
3950
self$get_connect()$GET(url, httr::write_disk(filename, overwrite = overwrite), "raw")
4051
return(filename)
4152
},
53+
#' @description Delete a content bundle.
54+
#' @param bundle_id The bundle identifer.
4255
bundle_delete = function(bundle_id) {
4356
url <- glue::glue("/v1/content/{self$get_content()$guid}/bundles/{bundle_id}")
4457
self$get_connect()$DELETE(url)
4558
},
59+
#' @description Get this (remote) content item.
4660
internal_content = function() {
4761
url <- glue::glue("applications/{self$get_content()$guid}")
4862
self$get_connect()$GET(url)
4963
},
64+
#' @description Update this content item.
65+
#' @param ... Content fields.
5066
update = function(...) {
5167
con <- self$get_connect()
5268
error_if_less_than(con, "1.8.6")
@@ -58,36 +74,49 @@ Content <- R6::R6Class(
5874
)
5975
return(self)
6076
},
77+
#' @description Delete this content item.
6178
danger_delete = function() {
6279
con <- self$get_connect()
6380
url <- glue::glue("v1/content/{self$get_content()$guid}")
6481
res <- con$DELETE(url)
6582
return(res)
6683
},
84+
#' @description Update the target Unix user.
85+
#' @param run_as The target Unix user.
86+
#' @param run_as_current_user Run as the active user.
6787
runas = function(run_as, run_as_current_user = FALSE) {
6888
lifecycle::deprecate_soft("0.1.1", "Content$runas()", "content$update()")
6989

7090
self$update(run_as = run_as, run_as_current_user = run_as_current_user)
7191
},
92+
#' @description Return the URL for this content.
7293
get_url = function() {
7394
self$get_content()$content_url
7495
},
96+
#' @description Return the URL for this content in the Posit Connect dashboard.
97+
#' @param pane The pane in the dashboard to link to.
7598
get_dashboard_url = function(pane = "") {
7699
dashboard_url_chr(self$connect$server, self$content$guid, pane = pane)
77100
},
101+
#' @description Return the jobs for this content.
78102
get_jobs = function() {
79103
lifecycle::deprecate_warn("0.1.0.9005", what = "get_jobs()", with = "jobs()")
80104
self$jobs()
81105
},
106+
#' @description Return a single job for this content.
107+
#' @param key The job key.
82108
get_job = function(key) {
83109
lifecycle::deprecate_warn("0.1.0.9005", "get_job()", "job()")
84110
self$job(key)
85111
},
112+
#' @description Return the jobs for this content.
86113
jobs = function() {
87114
warn_experimental("jobs")
88115
url <- glue::glue("applications/{self$get_content()$guid}/jobs")
89116
res <- self$get_connect()$GET(url)
90117
},
118+
#' @description Return a single job for this content.
119+
#' @param key The job key.
91120
job = function(key) {
92121
warn_experimental("job")
93122
url <- glue::glue("applications/{self$get_content()$guid}/job/{key}")
@@ -99,22 +128,32 @@ Content <- R6::R6Class(
99128
~ purrr::list_modify(.x, app_guid = content_guid)
100129
)[[1]]
101130
},
131+
#' @description Return the variants for this content.
102132
variants = function() {
103133
warn_experimental("variants")
104134
url <- glue::glue("applications/{self$get_content()$guid}/variants")
105135
self$get_connect()$GET(url)
106136
},
137+
#' @description Set a tag for this content.
138+
#' @param tag_id The tag identifier.
107139
tag_set = function(tag_id) {
108140
self$get_connect()$set_content_tag(self$get_content()$guid, tag_id = tag_id)
109141
},
142+
#' @description Remove a tag for this content.
143+
#' @param id The tag identifier.
110144
tag_delete = function(id) {
111145
# note that deleting the parent tag deletes all children
112146
self$get_connect()$tag_delete(id)
113147
},
148+
#' @description The tags for this content.
114149
tags = function() {
115150
url <- glue::glue("v1/content/{self$get_content()$guid}/tags")
116151
self$get_connect()$GET(url)
117152
},
153+
#' @description Add a principal to the ACL for this content.
154+
#' @param principal_guid GUID for the target user or group.
155+
#' @param principal_type Acting on user or group.
156+
#' @param role The kind of content access.
118157
permissions_add = function(principal_guid, principal_type, role) {
119158
url <- glue::glue("v1/content/{self$get_content()$guid}/permissions")
120159
self$get_connect()$POST(url, body = list(
@@ -123,6 +162,11 @@ Content <- R6::R6Class(
123162
role = role
124163
))
125164
},
165+
#' @description Alter a principal in the ACL for this content.
166+
#' @param id The target identifier.
167+
#' @param principal_guid GUID for the target user or group.
168+
#' @param principal_type Acting on user or group.
169+
#' @param role The kind of content access.
126170
permissions_update = function(id, principal_guid, principal_type, role) {
127171
url <- glue::glue("v1/content/{self$get_content()$guid}/permissions/{id}")
128172
self$get_connect()$PUT(url, body = list(
@@ -131,10 +175,15 @@ Content <- R6::R6Class(
131175
role = role
132176
))
133177
},
178+
#' @description Remove an entry from the ACL for this content.
179+
#' @param id The target identifier.
134180
permissions_delete = function(id) {
135181
url <- glue::glue("v1/content/{self$get_content()$guid}/permissions/{id}")
136182
self$get_connect()$DELETE(url)
137183
},
184+
#' @description Obtain some or all of the ACL for this content.
185+
#' @param id The target identifier.
186+
#' @param add_owner Include the content owner in the result set.
138187
permissions = function(id = NULL, add_owner=FALSE) {
139188
guid <- self$get_content()$guid
140189
url <- glue::glue("v1/content/{guid}/permissions")
@@ -157,11 +206,14 @@ Content <- R6::R6Class(
157206
}
158207
return(res)
159208
},
209+
#' @description Return the environment variables set for this content.
160210
environment = function() {
161211
url <- glue::glue("v1/content/{self$get_content()$guid}/environment")
162212
res <- self$get_connect()$GET(url)
163213
return(res)
164214
},
215+
#' @description Adjust the environment variables set for this content.
216+
#' @param ... Environment variable names and values.
165217
environment_set = function(...) {
166218
url <- glue::glue("v1/content/{self$get_content()$guid}/environment")
167219
# post with
@@ -179,6 +231,8 @@ Content <- R6::R6Class(
179231
)
180232
res
181233
},
234+
#' @description Overwrite the environment variables set for this content.
235+
#' @param ... Environment variable names and values.
182236
environment_all = function(...) {
183237
url <- glue::glue("v1/content/{self$get_content()$guid}/environment")
184238

@@ -196,13 +250,17 @@ Content <- R6::R6Class(
196250
)
197251
res
198252
},
253+
#' @description Deploy this content
254+
#' @param bundle_id Target bundle identifier.
199255
deploy = function(bundle_id = NULL) {
200256
body <- list(bundle_id = bundle_id)
201257
self$get_connect()$POST(
202258
glue::glue("v1/content/{self$get_content()$guid}/deploy"),
203259
body = body
204260
)
205261
},
262+
#' @description Adjust Git polling.
263+
#' @param enabled Polling enabled.
206264
repo_enable = function(enabled = TRUE) {
207265
warn_experimental("repo_enable")
208266
self$get_connect()$PUT(
@@ -212,6 +270,10 @@ Content <- R6::R6Class(
212270
)
213271
)
214272
},
273+
#' @description Adjust Git repository.
274+
#' @param repository Git repository URL
275+
#' @param branch Git repository branch
276+
#' @param subdirectory Git repository directory
215277
repo_set = function(repository, branch, subdirectory) {
216278
warn_experimental("repo_set")
217279
self$get_connect()$POST(
@@ -223,6 +285,8 @@ Content <- R6::R6Class(
223285
)
224286
)
225287
},
288+
#' @description Print this object.
289+
#' @param ... Unused.
226290
print = function(...) {
227291
cat("Posit Connect Content: \n")
228292
cat(" Content GUID: ", self$get_content()$guid, "\n", sep = "")
@@ -248,37 +312,51 @@ Environment <- R6::R6Class(
248312
"Environment",
249313
inherit = Content,
250314
public = list(
315+
#' @field env_raw The (raw) set of environment variables.
251316
env_raw = NULL,
317+
#' @field env_vars The set of environment variables.
252318
env_vars = NULL,
319+
320+
#' @description Initialize this set of environment variables.
321+
#' @param connect The `Connect` instance.
322+
#' @param content The `Content` instance.
253323
initialize = function(connect, content) {
254324
super$initialize(connect = connect, content = content)
255325
self$env_refresh()
256326
},
327+
#' @description Fetch the set of environment variables.
257328
environment = function() {
258329
res <- super$environment()
259330
env_raw <- res
260331
env_vars <- res
261332
return(res)
262333
},
334+
#' @description Update the set of environment variables.
335+
#' @param ... Environment variable names and values.
263336
environment_set = function(...) {
264337
res <- super$environment_set(...)
265338
env_raw <- res
266339
env_vars <- res
267340
return(res)
268341
},
342+
#' @description Overwrite the set of environment variables.
343+
#' @param ... Environment variable names and values.
269344
environment_all = function(...) {
270345
res <- super$environment_all(...)
271346
env_raw <- res
272347
env_vars <- res
273348
return(res)
274349
},
350+
#' @description Fetch the set o environment variables.
275351
env_refresh = function() {
276352
# mutates the existing instance, so future
277353
# references have the right version
278354
self$env_raw <- self$environment()
279355
self$env_vars <- self$env_raw
280356
return(self)
281357
},
358+
#' @description Print this object.
359+
#' @param ... Unused.
282360
print = function(...) {
283361
super$print(...)
284362
cat("Environment Variables:\n")

0 commit comments

Comments
 (0)