Jobs

This endpoint is used to create, update, search or delete jobs for a particular Terrakube workspace.

To use this endpoint you need to create a Terrakube workspace.

Entity fields:

PathTypeDescription

data.type

string

Should be "job"

data.attributes.tcl

string

Terraform Configuration Language job template

data.attributes.templateReference

string

Terrakube template id to use when running the job

data.relationships.workspace.data.type

string

Should be "workspace"

data.relationships.workspace.data.Id

string

Should be the VCS Workspace Id (OPTIONAL)

To better understand Terrakube Configuration Language job templates please refer to the following GitHub repository.

Example:

{
  "data": {
    "type": "job",
    "attributes": {
      "tcl": "Base64 TCL job template"
      "templateReference": "XXXXXXXXX"
    },
    "relationships":{
        "workspace":{
            "data":{
                "type": "workspace",
                "id": "{{workspaceId}}"
            }
        }
    }
  }
}

Supported Operations

Returns an instance of type job

GET/api/v1/workspace/{workspaceId}/job/{jobId}
Path parameters
workspaceId*string

workspace Identifier

jobId*string

job Identifier

Query parameters
Response

Successful response

Body
datajob (object)
includedarray of object

Included resources

Request
const response = await fetch('/api/v1/workspace/{workspaceId}/job/{jobId}', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "data": {
    "type": "text",
    "id": "text",
    "attributes": {
      "command": "plan",
      "output": "text",
      "status": "pending"
    },
    "relationships": {
      "organization": {
        "id": "text",
        "type": "organization"
      },
      "workspace": {
        "id": "text",
        "type": "workspace"
      }
    }
  },
  "included": [
    {
      "id": "text",
      "type": "text"
    }
  ]
}

Creates an item of type job and adds it to job

POST/api/v1/workspace/{workspaceId}/job
Path parameters
workspaceId*string

workspace Identifier

Body
datajob (object)
Response

Successful response

Body
datajob (object)
Request
const response = await fetch('/api/v1/workspace/{workspaceId}/job', {
    method: 'POST',
    headers: {
      "Content-Type": "application/vnd.api+json"
    },
    body: JSON.stringify({}),
});
const data = await response.json();
Response
{
  "data": {
    "type": "text",
    "id": "text",
    "attributes": {
      "command": "plan",
      "output": "text",
      "status": "pending"
    },
    "relationships": {
      "organization": {
        "id": "text",
        "type": "organization"
      },
      "workspace": {
        "id": "text",
        "type": "workspace"
      }
    }
  }
}

Deletes an instance of type job

DELETE/api/v1/workspace/{workspaceId}/job/{jobId}
Path parameters
workspaceId*string

workspace Identifier

jobId*string

job Identifier

Response

Successful response

Request
const response = await fetch('/api/v1/workspace/{workspaceId}/job/{jobId}', {
    method: 'DELETE',
    headers: {},
});
const data = await response.json();

Modifies an instance of type job

PATCH/api/v1/workspace/{workspaceId}/job/{jobId}
Path parameters
workspaceId*string

workspace Identifier

jobId*string

job Identifier

Body
datajob (object)
Response

Successful response

Request
const response = await fetch('/api/v1/workspace/{workspaceId}/job/{jobId}', {
    method: 'PATCH',
    headers: {
      "Content-Type": "application/vnd.api+json"
    },
    body: JSON.stringify({}),
});
const data = await response.json();

For a complete list of organization operation please visit the OpenAPI specification