Get All Assets by Asset Group ID
Use this API to retrieve the details of all the assets that belong to a specific asset group in the
Control Compliance Suite
12.5 asset system. Provide asset group GUID in input request to retrieve the asset details.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 Get All Assets by Asset Group ID API:
- View Assets
To use the Get All Assets by Asset Group ID 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 details of a
Control Compliance Suite
asset in an asset group, create a GET
request. HTTPS request components for Get All Assets by Asset Group ID 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 Get All Assets by Asset Group ID API
The following table contains the description of the HTTPS request parameters for the Get All Assets by Asset Group API:
Field name | Field type | Data type | Description |
|---|---|---|---|
AssetGroupID | Mandatory | GUID | This is the unique identifier of the asset group from which you want to retrieve the asset details. |
Page | Optional | Integer | Considering that the Get All Assets by Asset Group ID can return huge data depending on the number of assets in an asset group, 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. |
Response body for Get All Assets by Asset Group ID API
The GET request for the Get All Assets by Asset Group ID API returns the response body in the following structure:
Success Response: { TotalCount":Int, "TotalPages":Int, "PrevPageUrl":"URL", "NextPageUrl":"URL", "assetDataList":[{ "DispalyName": String "ContainerPath":String, "ID":Guid "Type":String }, {..} ] }
Sample HTTPS request for Get All Assets by Asset Group ID API
The following is a sample HTTPS request for your reference.
Request component | Value |
|---|---|
URL |
|
Content type | application/json |
Sample HTTPS response for Get All Assets by Asset Group ID API
The sample HTTPS request that you created earlier returns the following response:
{"TotalCount":4,"TotalPages":1,"PrevPageUrl":"","NextPageUrl":"", "assetDataList":[{"DisplayName":"<domain name>\\<IP address>","ContainerPath":"Asset System\\Windows","Id":"17510f00-cc0e-437d-bd39-3122d2bb0688","Type":"symc-csm-AssetSystem-Asset-Wnt-Machine"}, {"DisplayName":"<domain name>\\<IP address>","ContainerPath":"Asset System\\Windows","Id":"1f5244db-f667-438f-b475-9fe39fb67c09","Type":"symc-csm-AssetSystem-Asset-Wnt-Machine"}, {"DisplayName":"t1\\t1","ContainerPath":"Asset System\\Windows","Id":"4421e1ec-63f9-42fa-a10d-a709eb58503e","Type":"symc-csm-AssetSystem-Asset-Wnt-Machine"}, {"DisplayName":"<domain name>\\<IP address>","ContainerPath":"Asset System\\Windows","Id":"b9be1cc2-bc95-4077-bff1-a68dadf0b3ef","Type":"symc-csm-AssetSystem-Asset-Wnt-Machine"}]}
HTTPS response codes for Get All Assets by Asset Group ID API
Depending on the success or the failure of your API request, you see the following response codes for the Get All Assets by Asset Group ID API:
Response Code | Response Type | Description |
|---|---|---|
200 | OK | The following details are retrieved:
|
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 operation. Access is denied. |
404 | Not Found | If the user does not have sufficient permissions on an asset group from which details are to be retrieved, or if the specified asset group does not exist in the Control Compliance Suite asset system, the following error message is displayed:
|
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 Get All Assets by Asset Group ID API
Click to view a sample Python script for Get All Assets by Asset Group API
#Script to retrieve the details of all the assets that belong to specific asset group by providing assetgroup GUID in the input request. import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning # Declare Variables # 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'] return token #GetAllAssetsByAssetGroupID API endpoint URL. Provide the Assetgroup GUID in the request for retrieving the details of all the assets in the specific asset group. #You can use SerachAssetGroup API to get the GUID of the Asset group. url = "https://" + HostName + ":" + PortNumber + "/ccs/api/v1/AssetGroup/817fd810-83e1-4a29-85ea-8aa6204421e3/Assets" requests.packages.urllib3.disable_warnings(InsecureRequestWarning) bearertoken = "Bearer " + getToken() headers = { 'Authorization': bearertoken, 'Content-Type': "application/json" } response = requests.request("GET", url, headers=headers, verify=False) print(response.text) print(response.json)