Deleting Runtime Caches
Problem
You want to request the removal of a specified runtime cache.
Solution
Call the DELETE /v1/system/caches/runtime
endpoint.
You must specify the language, version, and image name for the runtime cache you wish to delete. See Viewing Runtime Caches to view runtime caches on your Connect server.
from posit import connect
= "Python"
LANGUAGE = "3.7.6"
VERSION = "Local"
IMAGE_NAME
= connect.Client()
client
= {
instructions "language": LANGUAGE,
"version": VERSION,
"image_name": IMAGE_NAME
}
= client.delete(
response "v1/system/caches/runtime",
=instructions,
json )
Runtime cache deletion can take some time. A successful request indicates that deletion was started, and returns a task object. You can use this task to poll Connect’s tasks API to check the status of the deletion.
>>> response.json()
'language': 'Python',
{'version': '3.7.6',
'image_name': 'Local',
'task_id': 'lFvijYN16kjCoal6'}
library(connectapi)
library(httr)
<- "R"
LANGUAGE <- "3.0.2"
VERSION <- "Local"
IMAGE_NAME
<- connect()
client
<- list(
instructions language = LANGUAGE,
version = VERSION,
image_name = IMAGE_NAME
)
<- client$DELETE(
response "/v1/system/caches/runtime",
body = instructions,
encode = "json"
)<- httr::content(response, as = "parsed") response_content
Runtime cache deletion can take some time. A successful request indicates that deletion was started, and returns a task object. You can use this task to poll Connect’s tasks API to check the status of the deletion.
> response_content
$language
1] "R"
[
$version
1] "3.0.2"
[
$image_name
1] "Local"
[
$task_id
1] "uThXBHopZ2Wgv7wn" [
Polling the task
Use Connect’s GET /v1/tasks/{id}
endpoint to check the status of a deletion task.
= response.json()["task_id"]
task_id = client.get(f"/v1/tasks/{task_id}") task_status
>>> task_status.json()
'id': 'lFvijYN16kjCoal6',
{'output': ['Deleting runtime cache...', 'Successfully deleted runtime cache'],
'result': None,
'finished': True,
'code': 0,
'error': '',
'last': 2}
= response_content$task_id
task_id = client$GET(glue::glue("v1/tasks/{task_id}")) task_status
> task_status
$id
1] "uThXBHopZ2Wgv7wn"
[
$output
$output[[1]]
1] "Deleting runtime cache..."
[
$output[[2]]
1] "Successfully deleted runtime cache"
[
$result
NULL
$finished
1] TRUE
[
$code
1] 0
[
$error
1] ""
[
$last
1] 2 [