Delete Job

Use this API to delete a specified job and the associated job data from the SQL store or from the
Control Compliance Suite
directory.
Authentication
To grant access to users to view or execute
Control Compliance Suite
RESTful APIs, you must generate an authentication token.
Authorization requirements
You must have the following tasks to use the Delete Job API:
  • View standards
  • Manage jobs
  • Collect data
  • Evaluate standards
  • View evaluation results
You must have the permission to access the following folders to use the Delete Job API:
  • Asset System
  • Standards
Only a CCS user who creates a job can delete that job.
  Request method
To delete a job, create a
DELETE
request.
  HTTPS request components for Delete Job API
Create a DELETE request by using the following components:
HTTPS request components for Delete Job API
Request component
Value
URL
https://<hostname>:<port number>/ccs/api/v1/Jobs?jobid={jobid}& DeleteJob={True/False}
You can also use the Fully Qualified Domain Name (FQDN) as the hostname. You can configure the port number from the
Integration Services Endpoint Configuration
dialog box from
Settings
>
Deployment View
on the
Control Compliance Suite
console. You must restart the Symantec Application Server Service after you configure the port. If you do not configure the port, the default port is considered in the request. The default port is 12431.
Content type
application/json
HTTPS request parameters for Delete Job API
The following table contains the description of the HTTPS request parameters for the Delete Job API:
HTTPS request parameters for Delete Job API
Field name
Field type
Data type
Description
JobID
Mandatory
GUID
This is the unique identifier of the job that you want to delete.
DeleteJob
Optional
Boolean
Set the value of this parameter to True if you want to delete the job permanently from the
Control Compliance Suite
directory.
Set the value of this parameter to False if you do not want to delete the job from the
Control Compliance Suite
directory. In this case, the historical data related to the job is deleted from the SQL store but the job is available for future job runs.
The default value of this parameter is True.
Sample HTTPS request for Delete Job API
The following is a sample HTTPS request for your reference:
HTTPS request components for Delete Job API
Request component
Value
URL
https://<host name>:<port number>/ccs/api/v1/ Jobs?jobid=754F7C7E-884A-4420-AF72-1FED35D3EFC1&DeleteJob=False
Content type
application/json
  Response body for Delete Job API
The DELETE request for the Delete Job API returns the response body in the following structure:
204 (No content)
  Sample HTTPS response for Delete Job API
The sample HTTPS request that you created earlier returns the following response:
204 (No content)
HTTPS response codes for Delete Job API
Depending on the success or the failure of your API request, you see the following response codes for the Delete Job API:
HTTPS response codes for Delete Job API
Response Code
Response Type
Description
204
No content
The request is successfully completed and all the specified jobs are deleted. However, no content needs to be returned to client
200
OK
The request is successfully completed. A response message informing users about the deletion of the specified job and its runs is displayed.
401
Unauthorized
This may be because of an invalid or expired access token in an API request.
400
Bad Request
(Client Error)
The following error message is displayed:
JobID is invalid.
403
Forbidden
This may be because of any of the following reasons:
  • The identified user does not have proper authorization to delete a job in
    Control Compliance Suite
    .
  • The user is trying to delete a system-defined job. A system job cannot be deleted.
404
NOT found
The JobID that is specified in the request does not exist in the
Control Compliance Suite
system.
500
Internal Server Error
(Server Error)
The following error message is displayed:
Server encountered an error while serving request. Please contact administrator if problem persists.
Sample Python script for Delete Job API
Click to view a sample Python script for Delete Job API
# Script to Delete the custom created job in CCS system import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning # Variable # Replace the <hostname> with CCS application server host name # Replace the <port number> with the configured port number for REST API, Default Port Number : 12431 # Replace the <user name> and <password> with valid CCS user name and password for example: UserName = domain1\\administrator, password = <Base64 encoded> HostName = '<hostname>' PortNumber = '<port number>' UserName = '<user name>' Password = '<password>' #<Base64 encoded> # Function to generate CCS REST API access token def getToken(): urlToken = "https://" + HostName + ":" + PortNumber + "/ccs/api/v1/oauth/tokens" payload = "grant_type=password&username=" + UserName + "&password=" + Password +"" headers = {'Content-Type': "application/json"} responseToken = requests.request("POST", urlToken, data=payload, headers=headers, verify=False) autheticationresult = responseToken.status_code if (autheticationresult!=200) : print("\nToken Generation Failed. Please check if the REST API is enabled and User name and password is correct\n") exit() tokenDict = responseToken.json() token = tokenDict['access_token'] refreshToken = tokenDict['refresh_token'] print("bearer Token is:\n") print(token) print("\n Refresh Token is:\n") print(refreshToken) return token # CCS job URI url = "https://" + HostName + ":" + PortNumber + "/ccs/api/v1/Jobs" # provide any valid job GUID like - a282d163-2248-4904-8135-0eaf08be8e55, Customer can use 'Search Job by Name' API to find the job GUID. querystring = {"jobid":"<JobID>"} payload = "\r" requests.packages.urllib3.disable_warnings(InsecureRequestWarning) bearertoken = "Bearer " + getToken() headers = { 'Authorization': bearertoken , 'Content-Type': "application/json" } response = requests.request("DELETE", url, data=payload, headers=headers, params=querystring, verify=False) print(response.text) print(response.json)