@@ -12,41 +12,57 @@ Content <- R6::R6Class(
12
12
# ' @field content The content details from Posit Connect
13
13
content = NULL ,
14
14
15
+ # ' @description Initialize this content.
16
+ # ' @param connect The `Connect` instance.
17
+ # ' @param content The content data.
15
18
initialize = function (connect , content ) {
16
19
validate_R6_class(connect , " Connect" )
17
20
self $ connect <- connect
18
21
# TODO: need to check that content has
19
22
# at least guid, url, title to be functional
20
23
self $ content <- content
21
24
},
25
+ # ' @description Returns the `Connect` instance.
22
26
get_connect = function () {
23
27
self $ connect
24
28
},
29
+ # ' @description Returns the underlying content data.
25
30
get_content = function () {
26
31
self $ content
27
32
},
33
+ # ' @description Obtain the content data from the Connect server.
28
34
get_content_remote = function () {
29
35
new_content_details <- self $ get_connect()$ content(self $ get_content()$ guid )
30
36
self $ content <- new_content_details
31
37
self $ get_content()
32
38
},
39
+ # ' @description Return the set of content bundles.
33
40
get_bundles = function () {
34
41
url <- glue :: glue(" v1/content/{self$get_content()$guid}/bundles" )
35
42
self $ get_connect()$ GET(url )
36
43
},
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.
37
48
bundle_download = function (bundle_id , filename = tempfile(pattern = " bundle" , fileext = " .tar.gz" ), overwrite = FALSE ) {
38
49
url <- glue :: glue(" /v1/content/{self$get_content()$guid}/bundles/{bundle_id}/download" )
39
50
self $ get_connect()$ GET(url , httr :: write_disk(filename , overwrite = overwrite ), " raw" )
40
51
return (filename )
41
52
},
53
+ # ' @description Delete a content bundle.
54
+ # ' @param bundle_id The bundle identifer.
42
55
bundle_delete = function (bundle_id ) {
43
56
url <- glue :: glue(" /v1/content/{self$get_content()$guid}/bundles/{bundle_id}" )
44
57
self $ get_connect()$ DELETE(url )
45
58
},
59
+ # ' @description Get this (remote) content item.
46
60
internal_content = function () {
47
61
url <- glue :: glue(" applications/{self$get_content()$guid}" )
48
62
self $ get_connect()$ GET(url )
49
63
},
64
+ # ' @description Update this content item.
65
+ # ' @param ... Content fields.
50
66
update = function (... ) {
51
67
con <- self $ get_connect()
52
68
error_if_less_than(con , " 1.8.6" )
@@ -58,36 +74,49 @@ Content <- R6::R6Class(
58
74
)
59
75
return (self )
60
76
},
77
+ # ' @description Delete this content item.
61
78
danger_delete = function () {
62
79
con <- self $ get_connect()
63
80
url <- glue :: glue(" v1/content/{self$get_content()$guid}" )
64
81
res <- con $ DELETE(url )
65
82
return (res )
66
83
},
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.
67
87
runas = function (run_as , run_as_current_user = FALSE ) {
68
88
lifecycle :: deprecate_soft(" 0.1.1" , " Content$runas()" , " content$update()" )
69
89
70
90
self $ update(run_as = run_as , run_as_current_user = run_as_current_user )
71
91
},
92
+ # ' @description Return the URL for this content.
72
93
get_url = function () {
73
94
self $ get_content()$ content_url
74
95
},
96
+ # ' @description Return the URL for this content in the Posit Connect dashboard.
97
+ # ' @param pane The pane in the dashboard to link to.
75
98
get_dashboard_url = function (pane = " " ) {
76
99
dashboard_url_chr(self $ connect $ server , self $ content $ guid , pane = pane )
77
100
},
101
+ # ' @description Return the jobs for this content.
78
102
get_jobs = function () {
79
103
lifecycle :: deprecate_warn(" 0.1.0.9005" , what = " get_jobs()" , with = " jobs()" )
80
104
self $ jobs()
81
105
},
106
+ # ' @description Return a single job for this content.
107
+ # ' @param key The job key.
82
108
get_job = function (key ) {
83
109
lifecycle :: deprecate_warn(" 0.1.0.9005" , " get_job()" , " job()" )
84
110
self $ job(key )
85
111
},
112
+ # ' @description Return the jobs for this content.
86
113
jobs = function () {
87
114
warn_experimental(" jobs" )
88
115
url <- glue :: glue(" applications/{self$get_content()$guid}/jobs" )
89
116
res <- self $ get_connect()$ GET(url )
90
117
},
118
+ # ' @description Return a single job for this content.
119
+ # ' @param key The job key.
91
120
job = function (key ) {
92
121
warn_experimental(" job" )
93
122
url <- glue :: glue(" applications/{self$get_content()$guid}/job/{key}" )
@@ -99,22 +128,32 @@ Content <- R6::R6Class(
99
128
~ purrr :: list_modify(.x , app_guid = content_guid )
100
129
)[[1 ]]
101
130
},
131
+ # ' @description Return the variants for this content.
102
132
variants = function () {
103
133
warn_experimental(" variants" )
104
134
url <- glue :: glue(" applications/{self$get_content()$guid}/variants" )
105
135
self $ get_connect()$ GET(url )
106
136
},
137
+ # ' @description Set a tag for this content.
138
+ # ' @param tag_id The tag identifier.
107
139
tag_set = function (tag_id ) {
108
140
self $ get_connect()$ set_content_tag(self $ get_content()$ guid , tag_id = tag_id )
109
141
},
142
+ # ' @description Remove a tag for this content.
143
+ # ' @param id The tag identifier.
110
144
tag_delete = function (id ) {
111
145
# note that deleting the parent tag deletes all children
112
146
self $ get_connect()$ tag_delete(id )
113
147
},
148
+ # ' @description The tags for this content.
114
149
tags = function () {
115
150
url <- glue :: glue(" v1/content/{self$get_content()$guid}/tags" )
116
151
self $ get_connect()$ GET(url )
117
152
},
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.
118
157
permissions_add = function (principal_guid , principal_type , role ) {
119
158
url <- glue :: glue(" v1/content/{self$get_content()$guid}/permissions" )
120
159
self $ get_connect()$ POST(url , body = list (
@@ -123,6 +162,11 @@ Content <- R6::R6Class(
123
162
role = role
124
163
))
125
164
},
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.
126
170
permissions_update = function (id , principal_guid , principal_type , role ) {
127
171
url <- glue :: glue(" v1/content/{self$get_content()$guid}/permissions/{id}" )
128
172
self $ get_connect()$ PUT(url , body = list (
@@ -131,10 +175,15 @@ Content <- R6::R6Class(
131
175
role = role
132
176
))
133
177
},
178
+ # ' @description Remove an entry from the ACL for this content.
179
+ # ' @param id The target identifier.
134
180
permissions_delete = function (id ) {
135
181
url <- glue :: glue(" v1/content/{self$get_content()$guid}/permissions/{id}" )
136
182
self $ get_connect()$ DELETE(url )
137
183
},
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.
138
187
permissions = function (id = NULL , add_owner = FALSE ) {
139
188
guid <- self $ get_content()$ guid
140
189
url <- glue :: glue(" v1/content/{guid}/permissions" )
@@ -157,11 +206,14 @@ Content <- R6::R6Class(
157
206
}
158
207
return (res )
159
208
},
209
+ # ' @description Return the environment variables set for this content.
160
210
environment = function () {
161
211
url <- glue :: glue(" v1/content/{self$get_content()$guid}/environment" )
162
212
res <- self $ get_connect()$ GET(url )
163
213
return (res )
164
214
},
215
+ # ' @description Adjust the environment variables set for this content.
216
+ # ' @param ... Environment variable names and values.
165
217
environment_set = function (... ) {
166
218
url <- glue :: glue(" v1/content/{self$get_content()$guid}/environment" )
167
219
# post with
@@ -179,6 +231,8 @@ Content <- R6::R6Class(
179
231
)
180
232
res
181
233
},
234
+ # ' @description Overwrite the environment variables set for this content.
235
+ # ' @param ... Environment variable names and values.
182
236
environment_all = function (... ) {
183
237
url <- glue :: glue(" v1/content/{self$get_content()$guid}/environment" )
184
238
@@ -196,13 +250,17 @@ Content <- R6::R6Class(
196
250
)
197
251
res
198
252
},
253
+ # ' @description Deploy this content
254
+ # ' @param bundle_id Target bundle identifier.
199
255
deploy = function (bundle_id = NULL ) {
200
256
body <- list (bundle_id = bundle_id )
201
257
self $ get_connect()$ POST(
202
258
glue :: glue(" v1/content/{self$get_content()$guid}/deploy" ),
203
259
body = body
204
260
)
205
261
},
262
+ # ' @description Adjust Git polling.
263
+ # ' @param enabled Polling enabled.
206
264
repo_enable = function (enabled = TRUE ) {
207
265
warn_experimental(" repo_enable" )
208
266
self $ get_connect()$ PUT(
@@ -212,6 +270,10 @@ Content <- R6::R6Class(
212
270
)
213
271
)
214
272
},
273
+ # ' @description Adjust Git repository.
274
+ # ' @param repository Git repository URL
275
+ # ' @param branch Git repository branch
276
+ # ' @param subdirectory Git repository directory
215
277
repo_set = function (repository , branch , subdirectory ) {
216
278
warn_experimental(" repo_set" )
217
279
self $ get_connect()$ POST(
@@ -223,6 +285,8 @@ Content <- R6::R6Class(
223
285
)
224
286
)
225
287
},
288
+ # ' @description Print this object.
289
+ # ' @param ... Unused.
226
290
print = function (... ) {
227
291
cat(" Posit Connect Content: \n " )
228
292
cat(" Content GUID: " , self $ get_content()$ guid , " \n " , sep = " " )
@@ -248,37 +312,51 @@ Environment <- R6::R6Class(
248
312
" Environment" ,
249
313
inherit = Content ,
250
314
public = list (
315
+ # ' @field env_raw The (raw) set of environment variables.
251
316
env_raw = NULL ,
317
+ # ' @field env_vars The set of environment variables.
252
318
env_vars = NULL ,
319
+
320
+ # ' @description Initialize this set of environment variables.
321
+ # ' @param connect The `Connect` instance.
322
+ # ' @param content The `Content` instance.
253
323
initialize = function (connect , content ) {
254
324
super $ initialize(connect = connect , content = content )
255
325
self $ env_refresh()
256
326
},
327
+ # ' @description Fetch the set of environment variables.
257
328
environment = function () {
258
329
res <- super $ environment()
259
330
env_raw <- res
260
331
env_vars <- res
261
332
return (res )
262
333
},
334
+ # ' @description Update the set of environment variables.
335
+ # ' @param ... Environment variable names and values.
263
336
environment_set = function (... ) {
264
337
res <- super $ environment_set(... )
265
338
env_raw <- res
266
339
env_vars <- res
267
340
return (res )
268
341
},
342
+ # ' @description Overwrite the set of environment variables.
343
+ # ' @param ... Environment variable names and values.
269
344
environment_all = function (... ) {
270
345
res <- super $ environment_all(... )
271
346
env_raw <- res
272
347
env_vars <- res
273
348
return (res )
274
349
},
350
+ # ' @description Fetch the set o environment variables.
275
351
env_refresh = function () {
276
352
# mutates the existing instance, so future
277
353
# references have the right version
278
354
self $ env_raw <- self $ environment()
279
355
self $ env_vars <- self $ env_raw
280
356
return (self )
281
357
},
358
+ # ' @description Print this object.
359
+ # ' @param ... Unused.
282
360
print = function (... ) {
283
361
super $ print(... )
284
362
cat(" Environment Variables:\n " )
0 commit comments