Delete Assets and Agents
Use this API to delete one or more agents and the associated 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 AssetsAndAgents API:
- View agents
- View assets
- Manage agents
- Manage assets and asset groups
To use the Delete AssetsAndAgents 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 agent and its associated assets, create a
DELETE
request.HTTPS request components for Delete AssetsAndAgents API
Create a DELETE request by using any of the following components:
Request component | Value |
|---|---|
URL |
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 |
|
HTTPS request parameters for Delete AssetsAndAgents API
The following table contains the description of the HTTPS request parameters for the Delete AssetsAndAgents API:
Field name | Field type | Data type | Description |
AssetIds | Mandatory | GUID | This is the unique identifier for an asset that you want to delete. Use a comma to separate multiple asset IDs. |
DelinkAgentsAndAssetsOnly | Optional | Boolean | If this parameter is True then the assets are only delinked from their agents. |
DeleteAgent | Optional | Boolean | This option should be set to true to delete the agents. If this option is false then only the assets are deleted.
This parameter is ignored if the DelinkAgentsAndAssetsOnly parameter is True. |
DeleteAllOtherAssetsOnAgents | Optional | Boolean | DeleteAgent only deletes the agent if there are no other assets associated with the agent. If the value of DeleteAllOtherAssetsOnAgents is True then the agent and the other associated assets are deleted from the CCS system.
This can only be used if DeleteAgent is True. |
Sample HTTPS request for Delete AssetsAndAgents API
The following is sample HTTPS request for your reference:
Request component | Value |
|---|---|
URL |
|
Content type | application/json |
JSON body |
|
Response body for Delete AssetsAndAgents API
The DELETE request for the Delete AssetsAndAgents API returns the response body in the following structure:
204 (No content)
Response body for Delete AssetsAndAgents API when the request is partially successful
The DELETE request for the Delete AssetsAndAgents API returns the response body in the following structure when the request is partially successful:
206 Partial Content { "TotalNumberOfAssets": COUNT OF TOTAL AGENTS AND ASSETS TO BE DELETED, "TotalNumberOfAssetsDeleted": COUNT OF SUCCESSFULLY DELETED, "TotalNumberAssetsNotFound": COUNT OF AGENTS AND ASSETS NOT FOUND, "ListOfAssetsNotFound": [ "ASSETS GUID OF NOT FOUND” ] } Sample HTTPS response for partial successful 206 Partial Content { "TotalNumberOfAssets": 3, "TotalNumberOfAssetsDeleted": 1, "TotalNumberAssetsNotFound": 2, "ListOfAssetsNotFound": [ "a8177adb-0f91-450f-9e08-40e888fa7255", "c05070c6-d4ea-45e8-95dd-b323b7b29177" ] }
Response body for Delete AssetsAndAgents API when the request is unsuccesful
The DELETE request for the Delete AssetsAndAgents API returns the response body in the following structure when the request is unsuccessful when the assets are not found or the asset IDs are invalid:
404 Not Found { "TotalNumberOfAssets": COUNT OF TOTAL AGENTS AND ASSETS TO BE DELETED, "TotalNumberOfAssetsDeleted": 0, "TotalNumberAssetsNotFound": COUNT OF AGENTS AND ASSETS NOT FOUND, "ListOfAssetsNotFound": [ "ASSETS GUID OF NOT FOUND” ] } Sample HTTPS response for partial successful 404 Not Found { "TotalNumberOfAssets": 3, "TotalNumberOfAssetsDeleted": 0, "TotalNumberAssetsNotFound": 3, "ListOfAssetsNotFound": [ "a8177adb-0f91-450f-9e08-40e888fa7255", "c05070c6-d4ea-45e8-95dd-b323b7b29177", "cb46e4d6-13dc-4559-b625-e867a1712eaa" ]
Sample HTTPS response for Delete AssetsAndAgents API
The sample HTTPS request that you created earlier returns the following response:
204 (No content)
HTTPS response codes for Delete AssetsAndAgents API
Depending on the success or the failure of your API request, you see the following response codes for the Delete AssetsAndAgents API:
Response Code | Response Type | Description |
|---|---|---|
204 | No Content | All the specified agents and their 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 agents along with their assets are deleted, or some of the agents along with their assets are deleted. |
206 | Partial Content | The request was partially completed. Not all the assets from the list of provided Asset Ids in the request body were found. |
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:
|
403 | Forbidden | The following error message is displayed:
|
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:
|
Sample Python script for Delete Assets and Agents API
Click to view a sample Python script for Delete Assets and Agents API
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 = Base 64 encrypted HostName = "<hostname>" PortNumber = "<port number>" UserName = "<user name>" Password = "<password>" # Base 64 encrypted # 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'] return token # CCS Asset URI url = "https://" + HostName + ":" + PortNumber + "/ccs/api/v1/AssetsAndAgents" payload ={} asset_ids = ["ASSET_1_GUID","ASSET_2_GUID"] payload["AssetIds"] = asset_ids payload["DelinkAgentsAndAssetsOnly"] = False payload["DeleteAgent"] = True payload["DeleteAllOtherAssetsOnAgents"]= False requests.packages.urllib3.disable_warnings(InsecureRequestWarning) bearertoken = "Bearer " + getToken() headers = { 'Authorization': bearertoken, 'Content-Type': "application/json" } response = requests.request("DELETE", url, json=payload, headers=headers, verify=False) if response.ok: print("All agents are deleted successfully.") else: print(response.status_code) print(response.text)