Delete Asset

Use this API to delete an asset or a list of assets from the
Control Compliance Suite
asset system.
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 Asset API:
  • View assets
  • Manage assets and asset groups
To use the Delete Asset API, you must have access to sub-folders in the Asset System folder. You may not require permissions on the entire asset system.
  Request method
To delete an asset, create a
DELETE
request.
  HTTPS request components for Delete Asset API
Create a DELETE request by using any of the following components:
HTTPS request components for Delete Asset API
Request component
Value
URL
https://<hostname>:<port number>/ccs/api/v1/assets
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
JSON body
[ "<Asset GUID>", "<Asset GUID>", "<Asset GUID>", "<Asset GUID>", "<Asset GUID>", ]
HTTPS request parameters for Delete Asset API
The <JSONBody> request field must contain an array of asset GUIDs as shown in the Sample HTTPS request for Delete Asset API
Sample HTTPS request for Delete Asset API
The following is sample HTTPS request for your reference:
HTTPS request components for Delete Asset API
Request component
Value
URL
https://<hostname>:<port number>/ccs/api/v1/assets
Content type
application/json
JSON body
[ "db7a5e44-adc0-4664-b471-f651dfda8d7c", "3cbf536a-9cad-4b4f-b23b-9525beb39f6a", "d13e3aec-a594-4235-ae7d-51f0efb0ab99", "69b37500-e81f-45fb-8d44-38fbdc5013ed", "1310e2ad-df2a-4faa-afc1-bcb9e77b36ce", "e140c904-d192-4c70-a291-51066dcae8b2", "a6d8d3d7-44e2-4446-b8ed-5919acbab3d2", "0918bc28-5c7e-44bb-964d-027836b749ad" ]
  Response body for Delete Asset API
The DELETE request for the Delete Asset API returns the response body in the following structure:
204 (No content)
  Sample HTTPS response for Delete Asset API
The sample HTTPS request that you created earlier returns the following response:
204 (No content)
HTTPS response codes for Delete Asset API
Depending on the success or the failure of your API request, you see the following response codes for the Delete Asset API:
HTTPS response codes for Delete Asset API
Response Code
Response Type
Description
204
No Content
All the specified assets are deleted. However, no content needs to be returned to client after the successful completion of the request.
200
OK
The request is successfully completed. However, either no assets are deleted or some of the assets are deleted.
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:
Asset ID is invalid.
403
Forbidden
The following error message is displayed:
You are not authorized to perform this task. Access is denied.
404
NOT found
The asset ID 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 Asset API
Click to view a sample Python script for Delete Asset API
# Script to Delete assets from CCS systems 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 Asset URI url = "https://" + HostName + ":" + PortNumber + "/ccs/api/v1/assets" # provide the asset GUIDs which need to be deleted. Like # payload = "[\"19cdaca5-ae26-422b-a07a-936599134768\",\"1e80bf4e-afaa-4b83-ae4b-a02b42be4045\"]" payload = "[\"<Asset GUID>\",\"<Asset GUID>\"]" 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, verify=False) print(response.text) print(responce.json)