Request cancellation of a build and return 202 Accepted.
Cancellation runs asynchronously: the endpoint verifies the build exists and then hands it off to a background workflow that marks the build as cancelling, asks the cloud build provider to stop it, and polls until the build reaches a terminal state before recording the final status. Only builds that are still queued or running are actually cancelled; if the build has already finished, or cancellation is already in progress, the request is still accepted but has no effect. The returned record reflects the build’s state at the time of the call, so it will not yet show the pending cancellation. The request is rejected if no such build exists for the caller’s account.
Cancel a build
import os
from scale_gp_beta import SGPClient
client = SGPClient(
api_key=os.environ.get("SGP_API_KEY"), # This is the default and can be omitted
)
agentex_cloud_build = client.build.cancel(
"build_id",
)
print(agentex_cloud_build.id){
"id": "id",
"account_id": "account_id",
"agent_name": "agent_name",
"build_status": "queued",
"cloud_provider_build_id": "cloud_provider_build_id",
"created_at": "2019-12-27T18:11:19.117Z",
"created_by": {
"id": "id",
"type": "user",
"object": "identity"
},
"image_name": "image_name",
"image_tag": "image_tag",
"source_commit": "source_commit",
"source_dirty": true,
"source_ref": "source_ref",
"source_repo": "source_repo",
"source_subpath": "source_subpath",
"working_tree_hash": "working_tree_hash",
"agent_id": "agent_id",
"build_end_time": "2019-12-27T18:11:19.117Z",
"build_start_time": "2019-12-27T18:11:19.117Z",
"image_url": "image_url",
"object": "agentex_cloud_build"
}Returns Examples
{
"id": "id",
"account_id": "account_id",
"agent_name": "agent_name",
"build_status": "queued",
"cloud_provider_build_id": "cloud_provider_build_id",
"created_at": "2019-12-27T18:11:19.117Z",
"created_by": {
"id": "id",
"type": "user",
"object": "identity"
},
"image_name": "image_name",
"image_tag": "image_tag",
"source_commit": "source_commit",
"source_dirty": true,
"source_ref": "source_ref",
"source_repo": "source_repo",
"source_subpath": "source_subpath",
"working_tree_hash": "working_tree_hash",
"agent_id": "agent_id",
"build_end_time": "2019-12-27T18:11:19.117Z",
"build_start_time": "2019-12-27T18:11:19.117Z",
"image_url": "image_url",
"object": "agentex_cloud_build"
}