1111# ' @family Execution Context API
1212# '
1313# ' @export
14- db_context_create <- function (cluster_id ,
15- language = c(" python" , " sql" , " scala" , " r" ),
16- host = db_host(), token = db_token(),
17- perform_request = TRUE ) {
18-
14+ db_context_create <- function (
15+ cluster_id ,
16+ language = c(" python" , " sql" , " scala" , " r" ),
17+ host = db_host(),
18+ token = db_token(),
19+ perform_request = TRUE
20+ ) {
1921 language <- match.arg(language , several.ok = FALSE )
2022
2123 body <- list (
@@ -37,7 +39,6 @@ db_context_create <- function(cluster_id,
3739 } else {
3840 req
3941 }
40-
4142}
4243
4344# ' Delete an Execution Context
@@ -50,11 +51,13 @@ db_context_create <- function(cluster_id,
5051# ' @family Execution Context API
5152# '
5253# ' @export
53- db_context_destroy <- function (cluster_id ,
54- context_id ,
55- host = db_host(), token = db_token(),
56- perform_request = TRUE ) {
57-
54+ db_context_destroy <- function (
55+ cluster_id ,
56+ context_id ,
57+ host = db_host(),
58+ token = db_token(),
59+ perform_request = TRUE
60+ ) {
5861 body <- list (
5962 clusterId = cluster_id ,
6063 contextId = context_id
@@ -74,7 +77,6 @@ db_context_destroy <- function(cluster_id,
7477 } else {
7578 req
7679 }
77-
7880}
7981
8082# ' Get Information About an Execution Context
@@ -86,10 +88,13 @@ db_context_destroy <- function(cluster_id,
8688# ' @family Execution Context API
8789# '
8890# ' @export
89- db_context_status <- function (cluster_id ,
90- context_id ,
91- host = db_host(), token = db_token(),
92- perform_request = TRUE ) {
91+ db_context_status <- function (
92+ cluster_id ,
93+ context_id ,
94+ host = db_host(),
95+ token = db_token(),
96+ perform_request = TRUE
97+ ) {
9398 req <- db_request(
9499 endpoint = " contexts/status" ,
95100 method = " GET" ,
@@ -109,7 +114,6 @@ db_context_status <- function(cluster_id,
109114 } else {
110115 req
111116 }
112-
113117}
114118
115119# ' Run a Command
@@ -126,15 +130,17 @@ db_context_status <- function(cluster_id,
126130# ' @family Execution Context API
127131# '
128132# ' @export
129- db_context_command_run <- function (cluster_id ,
130- context_id ,
131- language = c(" python" , " sql" , " scala" , " r" ),
132- command = NULL ,
133- command_file = NULL ,
134- options = list (),
135- host = db_host(), token = db_token(),
136- perform_request = TRUE ) {
137-
133+ db_context_command_run <- function (
134+ cluster_id ,
135+ context_id ,
136+ language = c(" python" , " sql" , " scala" , " r" ),
137+ command = NULL ,
138+ command_file = NULL ,
139+ options = list (),
140+ host = db_host(),
141+ token = db_token(),
142+ perform_request = TRUE
143+ ) {
138144 language <- match.arg(language , several.ok = FALSE )
139145
140146 # only can have one of `command` or `command_file`
@@ -164,13 +170,12 @@ db_context_command_run <- function(cluster_id,
164170 options = options
165171 )
166172
167- if (perform_request ) {
173+ if (perform_request ) {
168174 res <- db_perform_request(req )
169175 list (id = res $ id , language = language )
170176 } else {
171177 req
172178 }
173-
174179}
175180
176181# ' Run a Command and Wait For Results
@@ -181,15 +186,17 @@ db_context_command_run <- function(cluster_id,
181186# ' @family Execution Context API
182187# '
183188# ' @export
184- db_context_command_run_and_wait <- function (cluster_id ,
185- context_id ,
186- language = c(" python" , " sql" , " scala" , " r" ),
187- command = NULL ,
188- command_file = NULL ,
189- options = list (),
190- parse_result = TRUE ,
191- host = db_host(), token = db_token()) {
192-
189+ db_context_command_run_and_wait <- function (
190+ cluster_id ,
191+ context_id ,
192+ language = c(" python" , " sql" , " scala" , " r" ),
193+ command = NULL ,
194+ command_file = NULL ,
195+ options = list (),
196+ parse_result = TRUE ,
197+ host = db_host(),
198+ token = db_token()
199+ ) {
193200 stopifnot(is.logical(parse_result ))
194201
195202 command <- db_context_command_run(
@@ -227,7 +234,6 @@ db_context_command_run_and_wait <- function(cluster_id,
227234 } else {
228235 command_status
229236 }
230-
231237}
232238
233239# ' Get Information About a Command
@@ -240,12 +246,14 @@ db_context_command_run_and_wait <- function(cluster_id,
240246# ' @family Execution Context API
241247# '
242248# ' @export
243- db_context_command_status <- function (cluster_id ,
244- context_id ,
245- command_id ,
246- host = db_host(), token = db_token(),
247- perform_request = TRUE ) {
248-
249+ db_context_command_status <- function (
250+ cluster_id ,
251+ context_id ,
252+ command_id ,
253+ host = db_host(),
254+ token = db_token(),
255+ perform_request = TRUE
256+ ) {
249257 req <- db_request(
250258 endpoint = " commands/status" ,
251259 method = " GET" ,
@@ -266,7 +274,6 @@ db_context_command_status <- function(cluster_id,
266274 } else {
267275 req
268276 }
269-
270277}
271278
272279# ' Cancel a Command
@@ -278,33 +285,34 @@ db_context_command_status <- function(cluster_id,
278285# ' @family Execution Context API
279286# '
280287# ' @export
281- db_context_command_cancel <- function (cluster_id ,
282- context_id ,
283- command_id ,
284- host = db_host(), token = db_token(),
285- perform_request = TRUE ) {
288+ db_context_command_cancel <- function (
289+ cluster_id ,
290+ context_id ,
291+ command_id ,
292+ host = db_host(),
293+ token = db_token(),
294+ perform_request = TRUE
295+ ) {
296+ body <- list (
297+ clusterId = cluster_id ,
298+ contextId = context_id ,
299+ commandId = command_id
300+ )
286301
287302 req <- db_request(
288303 endpoint = " commands/cancel" ,
289304 method = " POST" ,
290305 version = " 1.2" ,
306+ body = body ,
291307 host = host ,
292308 token = token
293309 )
294310
295- req <- req | >
296- httr2 :: req_url_query(
297- clusterId = cluster_id ,
298- contextId = context_id ,
299- commandId = command_id
300- )
301-
302311 if (perform_request ) {
303312 db_perform_request(req )
304313 } else {
305314 req
306315 }
307-
308316}
309317
310318# ' Parse Command Results
@@ -317,8 +325,10 @@ db_context_command_cancel <- function(cluster_id,
317325# '
318326# ' @return command results
319327# ' @keywords internal
320- db_context_command_parse <- function (x , language = c(" r" , " py" , " scala" , " sql" )) {
321-
328+ db_context_command_parse <- function (
329+ x ,
330+ language = c(" r" , " py" , " scala" , " sql" )
331+ ) {
322332 language <- match.arg(language )
323333
324334 if (x $ results $ resultType == " error" ) {
@@ -338,7 +348,6 @@ db_context_command_parse <- function(x, language = c("r", "py", "scala", "sql"))
338348 huxtable :: set_all_borders(TRUE ) | >
339349 huxtable :: set_font_size(10 ) | >
340350 huxtable :: set_position(" left" )
341-
342351 huxtable :: print_screen(output_tbl )
343352 return (NULL )
344353 }
@@ -364,7 +373,6 @@ db_context_command_parse <- function(x, language = c("r", "py", "scala", "sql"))
364373 }
365374
366375 out
367-
368376}
369377
370378handle_cmd_error <- function (x , language ) {
0 commit comments