Terminate a Job

Problem

You want to terminate a Job associated with your Content.

Solution

Important

This action requires owner, collaborator, or administrator privileges.

Note

Requires posit-sdk>=0.6.0

First, obtain the content object. In this example, we get the content using it’s GUID. Then obtain the job using it’s key. Call the destroy method to request a job termination event. This event is asynchronous and will take a few moments to process.

from posit import connect

CONTENT_GUID = '154bd2af-e8fa-4aa4-aab8-dcef701f4af9'
JOB_KEY = 'CwCoI9tizMRRcvLw'

client = connect.Client()
content = client.content.get(CONTENT_GUID)
job = content.jobs.find(JOB_KEY)
job.destroy()

Use the API to delete a job using its job key. You’ll need the GUID for the content item, and the job key associated with the job you wish to kill.

library(connectapi)
library(httr)

CONTENT_ITEM_GUID <- "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
JOB_KEY <- "CwCoI9tizMRRcvLw"

client <- connect()
response <- client$DELETE(
    glue::glue("v1/content/{CONTENT_ITEM_GUID}/jobs/{JOB_KEY}"),
)
> print(response)
Response [https://connect.company.co/__api__/v1/content/fdc3f938-3ace-4a22-8af2-1a8f17828b6a/jobs/CwCoI9tizMRRcvLw]
  Date: 2024-06-21 17:48
  Status: 200
  Content-Type: application/json; charset=utf-8
  Size: 199 B

See Also