Search Assets

Use this API to retrieve the list of assets in the
Control Compliance Suite
12.5 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
To use the Search Assets API, you must have the following task assigned:
  • View Assets
To use the Search Assets 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 retrieve the list of
Control Compliance Suite
assets in your environment, create a
GET
request.
  HTTPS request components for Search Assets API
Create a GET request by using the following components:
HTTPS request components for Search Assets API
Request component
Value
URL
https://<hostname>:<port number>/ccs/api/v1/ Assets?Attributes=Attrname1 OP value1, Attrname2 OP value2, AttrnameN OP valueN)& ContainerPath=<Asset system path value>&SearchSubTree=<True/False>& page=X&pagesize=Y
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 Search Assets API
The following table contains the description of the HTTPS request parameters for the Search Assets API:
HTTPS request parameters for Search Assets API
Field name
Field type
Data type
Description
Attributes
Mandatory
String
This is a comma-separated list of asset attributes and their respective values that are joined by an operator. The ‘OP’ placeholder in the HTTPS request components for Search Assets API the section indicates a query operator, which can be any of the following:
  • =
  • EqualTo
  • Contains
  • StartsWith
  • EndsWith
All these query operators are case-sensitive.
Comma in the list of attributes can be the 'AND' operator that is represented by '&' or the "OR' operator that is represented by "|'. Note the following conditions to use these operators in a request:
  • A request can include either the AND operator or the OR operator within a parentheses set but not both the operators within the same parentheses set.
    • Valid request example
      : attributes=(DisplayName = Win2012 | DisplayName = Win2016 | DisplayName = Win2019) & (symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName = example.com & symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName = example.org)
    • Invalid request example
      : attributes=(DisplayName = Win2012 | DisplayName = Win2016 & DisplayName = Win2019) & (symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName = example.com & symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName = example.org)
  • A request can include only up to two sets of parentheses.
    • Valid request
      example
      : attributes=(DisplayName = Win2012 | DisplayName = Win2016) & (symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName = example.com | symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName = example.org)
    • Invalid request example
      : attributes=(DisplayName = Win2012 | DisplayName = Win2016) & (symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName = example.com & symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName = example.org) & (symc-csm-AssetSystem-Asset-Wnt-Machine-OSVersionType = windows & symc-csm-AssetSystem-Asset-Wnt-Machine-OSVersionType = win)
Wildcard character asterisk (*) is supported in values to be specified.
The
Search Asset
API returns a list of assets along with their total count.
ContainerPath
Optional
String
This is the folder in which the search operation is executed. The default value of this parameter is Asset System, which is the default root folder in the Control Compliance Suite asset hierarchy.
SearchSubtree
Optional
Boolean
By using this parameter, you can decide whether to search for the assets in the sub-folders recursively. The default value of this parameter is ‘True’.
Page
Optional
Integer
Considering that the Search Assets API can return huge data depending on the number of assets in your asset system, pagination support is added. By using the
Page
parameter, you can specify the page number to retrieve in response to the API call. The default value of this parameter is 0.
PageSize
Optional
Integer
By using this parameter, you can decide how many result entries should be displayed on a single page. The default value of this parameter is 1000.
Commonly used attributes in HTTPS request for Search Assets API
The following are some attributes that are commonly used in an HTTPS request for the Search Assets API. These attributes vary depending on the platform.
Commonly used attributes in HTTPS request for Search Assets API
Platform
Supported attribute
Windows
  • DisplayName
  • symc-csm-AssetSystem-Asset-Wnt-Machine-DomainWorkgroupName
  • symc-csm-AssetSystem-Asset-Wnt-Machine-HostName
  • symc-csm-AssetSystem-Asset-Wnt-Machine-OSVersionType
  • symc-csm-AssetSystem-Asset-Wnt-Machine-OSMajorVersionNumber
  • symc-csm-AssetSystem-Asset-Wnt-Machine-OSMinorVersionNumber
UNIX
  • DisplayName
  • symc-csm-AssetSystem-Asset-Unix-Machine-HostMachine
  • symc-csm-AssetSystem-Asset-Unix-Machine-IPAddress
  • symc-csm-AssetSystem-Asset-Unix-Machine-OSDistributionField
  • symc-csm-AssetSystem-Asset-Unix-Machine-OSSystem
  • symc-csm-AssetSystem-Asset-Unix-Machine-OSVersionString
MS SQL Server
  • DisplayName
  • symc-csm-AssetSystem-Asset-Dbif-server-serverName
  • symc-csm-AssetSystem-Asset-Dbif-server-hostName
  • symc-csm-AssetSystem-Asset-Dbif-server-SQLServerDomainName
  • symc-csm-AssetSystem-Asset-Dbif-server-operatingSystem
  • symc-csm-AssetSystem-Asset-Dbif-server-platform
  • symc-csm-AssetSystem-Asset-Dbif-server-productLevel
  • symc-csm-AssetSystem-Asset-Dbif-server-productVersion
  • symc-csm-AssetSystem-Asset-Dbif-server-versionString
Oracle Server
  • DisplayName
  • symc-csm-AssetSystem-Asset-ORCL-CONFIGUREDDATABASES-NetBIOSName
  • symc-csm-AssetSystem-Asset-ORCL-CONFIGUREDDATABASES-DomainOrIP
  • symc-csm-AssetSystem-Asset-ORCL-CONFIGUREDDATABASES-servername
  • symc-csm-AssetSystem-Asset-ORCL-CONFIGUREDDATABASES-dbname
  • symc-csm-AssetSystem-Asset-ORCL-CONFIGUREDDATABASES-dbversion
  • symc-csm-AssetSystem-Asset-ORCL-CONFIGUREDDATABASES-OSTYPE
  • symc-csm-AssetSystem-Asset-ORCL-CONFIGUREDDATABASES-OSVERSION
Response body for Search Assets API
The GET request for the Search Assets API returns the response body in the following structure:
Success Response: { "TotalCount": Int, "TotalPages": Int, "PrevPageUrl": String, "NextPageUrl":String, "assetDataList": [ { "DisplayName": String, "Path": String, "Id": String, "Type": String } ] }
Sample HTTPS request for Search Assets API
The following is a sample HTTPS request for your reference. We have used DisplayName as the attribute in the sample:
HTTPS request components
Request component
Value
URL
GET https://<hostname>:<port number>/ccs/api/v1/Assets?attributes=(displayName = <Test_asset>)& ContainerPath=Asset system&SearchSubTree=True&page=0&pagesize=100
Content type
application/json
Sample HTTPS response for Search Assets API
The sample HTTPS request that you created earlier returns the following response:
{"TotalCount":1, "TotalPages":1, "PrevPageUrl":"", "NextPageUrl":"", "assetDataList":[{"DisplayName":"<display name>","Path":"Asset System","Id":"9c135703-b76e-4eff-bfe2-8959d7ca4148", "Type":"symc-csm-AssetSystem-Asset-Wnt-Machine"}]}
HTTPS response codes for Search Assets API
Depending on the success or the failure of your API request, you see the following response codes for the Search Assets API:
HTTPS response codes
Response Code
Response Type
Description
200
OK
The list of assets is available with the following asset details:
  • Total count of assets
  • Total pages
  • Previous page URL
  • Next page URL
  • Asset details
    Asset details include the following information:
    • Display name
    • Path
    • ID
    • Type
200
(with Total Count: 0 in response body)
OK
The request is completed successfully. However, there are no records matching the request parameters. In this case, the following response is returned. The total count of assets in this case is zero:
{ "TotalCount": 0, "TotalPages": 0, "PrevPageUrl": "", "NextPageUrl": "", "assetDataList": [] }
403
Forbidden
The following error message is displayed:
You are not authorized to perform this task. Access is denied.
401
Unauthorized
This may be because of an invalid access token or an expired access token in an API request.
400
Bad Request
(Client Error)
The following error message is displayed:
Server could not understand the request due to invalid syntax. Please check requested URL.
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 Search Assets API
Click to view a sample Python script for Search Asset API
# Script to Search assets in the CCS System import request 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 url = "https://" + HostName + ":" + PortNumber + "/ccs/api/v1/Assets" ## Simple Search #querystring = {"attributes":"displayname Contains 10.211.64"} ## Advanced Search querystring = {"attributes":"(symc-csm-AssetSystem-Asset-unix-Machine-OSSystem Contains linux, displayname Contains 10.211.64)","ContainerPath":"asset system", "searchsubtree":"false","page":"0","pagesize":"1"} requests.packages.urllib3.disable_warnings(InsecureRequestWarning) bearertoken = "Bearer " + getToken() headers = { 'Authorization': bearertoken } response = requests.request("GET", url, headers=headers, params=querystring, verify=False) assetsData = response.json() print(response.text)