Search Asset Group

Use this API to retrieve the list of asset groups 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
You must have the following task to use the Search Asset Group API:
  • View Assets
To use the Search Asset Group API, you must have the permission to access sub-folders in the Asset System folder. You may not require permissions on the entire asset system.
  Request method
To retrieve the list of asset groups in your
Control Compliance Suite
environment, create a
GET
request.
  HTTPS request components for Search Asset Group API
Create a GET request by using the following components:
HTTPS request components for Search Asset Group API
Request component
Value
URL
https://<hostname>:<port number>/ccs/api/v1/ AssetGroup?Attributes=Attrname1 OP value1, Attrname2 OP value2, AttrnameN OP valueN)&ContainerPath=Asset system path value& SearchSubTree=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 Search Asset Group API
The following table contains the description of the HTTPS request parameters for the Search Asset Group API:
HTTPS request parameters for Search Asset Group API
Field name
Filed type
Data type
Description
Attributes
Mandatory
String
This is a comma-separated list of asset attributes and their respective values joined by an operator. The ‘OP’ placeholder in the HTTPS request components for Search Asset Group API section indicates a query operator, which can be any of the following:
  • =
  • EqualTo
  • Contains
  • StartsWith
  • EndsWith
All these query operators are case-sensitive.
Comma used in the list of attributes is treated as 'AND.'
Wildcard character asterisk (*) is supported in values to be specified.
The
Search Asset Group
API returns a list of asset groups along with their total count.
The following are some attributes that are commonly used in an HTTPS request for the Search Asset Group API:
  • DisplayName
  • Symc-CSM-AssetSystem-AssetGroup-AssetTypes
  • Symc-CSM-AssetSystem-AssetGroup-Owner
  • symc-csm-AssetSystem-AssetGroup
Container path
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 asset groups in the sub-folders recursively. The default value of this parameter is ‘True.’
Response body for Search Asset Group API
The GET request for the Search Asset Group API returns the response body in the following structure:
{ "TotalCount": {Int}, "AssetGroupType": {String}, "AssetGroup": [ { "DisplayName": {String}, "ID": {String}, } ] }
Sample HTTPS request for Search Asset Group API
The following is a sample HTTPS request for your reference. We have used display name of an asset group as an attribute in the sample:
HTTPS request components for Search Asset Group API
Request component
Value
URL
https://<hostname>:<port number>/ccs/api/v1/AssetGroup?attributes= (displayname EqualTo All Windows Machines,symc-csm-AssetSystem-AssetGroup-Description Contains Windows)& ContainerPath=asset system\unix&searchsubtree=false
Content type
application/json
  Sample HTTPS response for Search Asset Group API
The sample HTTPS request that you created earlier returns the following response:
{"TotalCount":1, "AssetGroupType":"symc-csm-AssetSystem-AssetGroup", "AssetGroups":[{"DisplayName":"All Windows Machines", "Id":"8265ee65-8614-429b-bfc4-0da8224df09c"}]}
HTTPS response codes for Search Asset Group API
Depending on the success or the failure of your API request, you see the following response codes for the Search Asset Group API:
HTTPS response codes for Search Asset Group API
Response Code
Response Type
Description
200
OK
The list of asset groups with their total and asset group type is available. Asset group details include display names of asset groups and their IDs.
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 asset groups in this case is zero:
{ "TotalCount": 0, "AssetGroupType": null, "AssetGroup": [{}] }
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 or expired access token in an API request.
400
Bad Request
(Client Error)
One of the following error messages is displayed:
  • Server could not understand the request due to invalid syntax. Please check requested URL.
  • The parameter Attributes is null or Empty.
  • The parameter '#name' is invalid. The expression '#expression' within is invalid.
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 Asset Group API
Click to view a sample Python script for Search Asset Group API
# Script to Search the asset group in the 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 asset group URI url = "https://" + HostName + ":" + PortNumber + "/ccs/api/v1/AssetGroup" requests.packages.urllib3.disable_warnings(InsecureRequestWarning) bearertoken = "Bearer " + getToken() headers = { 'Authorization': bearertoken } # Simple Search querystring = {"Attributes":"(displayName = All DB2 *)"} # Advanced Search #querystring = {"Attributes":"(displayName = *)","ContainerPath":"Asset system","SearchSubTree":"True"} response = requests.request("GET", url, headers=headers, params=querystring, verify=False) GroupData = response.json() print(response.text)