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:
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 |
HTTPS request parameters for Search Assets API
The following table contains the description of the HTTPS request parameters for the 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:
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:
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.
Platform | Supported attribute |
|---|---|
Windows |
|
UNIX |
|
MS SQL Server |
|
Oracle Server |
|
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:
Request component | Value |
|---|---|
URL |
|
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:
Response Code | Response Type | Description |
|---|---|---|
200 | OK | The list of assets is available with the following asset details:
|
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:
|
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:
|
500 | Internal Server Error (Server Error) | The following error message is displayed:
|
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)