Read Target Version History
GET {{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}
The GET /v2/policy-manager/targets/{{targetId}}/history operation returns the history of changes made to the target identified by {{targetId}}. The request must provide a snapshot ID in the request URL to specify where the target and its version history should be read from.
Prerequisites
-
Create a branch to get a branch ID.
-
Create a snapshot to get a snapshot ID.
Query parameters
| Query parameter | Description |
|---|---|
|
Branch ID or name. |
|
Snapshot ID. This parameter is required. |
|
Specifies the page number of results to return. |
|
Specifies the number of results to return per page. |
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}' \
--header 'x-user-id: {{userId}}'
var options = new RestClientOptions("{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Get);
request.AddHeader("x-user-id", "{{userId}}");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("x-user-id", "{{userId}}")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
GET /v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}} HTTP/1.1
Host: {{apiPath}}
x-user-id: {{userId}}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}")
.method("GET", body)
.addHeader("x-user-id", "{{userId}}")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}",
"method": "GET",
"timeout": 0,
"headers": {
"x-user-id": "{{userId}}"
},
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'GET',
'url': '{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}',
'headers': {
'x-user-id': '{{userId}}'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
url = "{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}"
payload = {}
headers = {
'x-user-id': '{{userId}}'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'x-user-id' => '{{userId}}'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
require "uri"
require "net/http"
url = URI("{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["x-user-id"] = "{{userId}}"
response = http.request(request)
puts response.read_body
var request = URLRequest(url: URL(string: "{{apiPath}}/v2/policy-manager/targets/{{targetId}}/history?branch={{branchId}}&snapshot={{snapshotId}}")!,timeoutInterval: Double.infinity)
request.addValue("{{userId}}", forHTTPHeaderField: "x-user-id")
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()
Example Response
200 OK
{
"pageHeader": {
"entityId": "ff7c4314-51a9-4384-b565-c4fdafe34f69",
"entityType": "com.symphonicsoft.policymanager2.target.Target"
},
"pagination": {
"page": 1,
"pageSize": 100,
"totalItems": 0,
"totalPages": 0
},
"data": [
{
"version": "3eda70b1-a8c6-4a8e-9baa-9af8b2215644",
"deltaId": "73cef65b-f20c-4e73-9530-652ab3792ef3",
"snapshotId": "69e75db7-703c-43ce-8311-383e5b4e2299",
"timestamp": "2025-03-09T23:41:07.887407Z",
"user": "selfgovernanceadmin"
},
{
"version": "a88868f2-cd31-4c9f-8dcd-5af7c1083d94",
"deltaId": "4ff89d5c-3615-4335-a5fa-af828742819a",
"snapshotId": "69e75db7-703c-43ce-8311-383e5b4e2299",
"timestamp": "2025-03-09T23:40:00.677431Z",
"user": "selfgovernanceadmin"
},
{
"version": "8321f941-ad20-4a1c-a5a1-55886195b44d",
"deltaId": "efa38eca-c4cf-493c-9f10-7785c3f14612",
"snapshotId": "1057e1ea-7da6-419e-b676-9a9ff2f45d5c",
"timestamp": "2025-03-09T23:36:25.293886Z",
"user": "selfgovernanceadmin"
},
{
"version": "9761f699-2858-40ba-8e79-9fed3f757f58",
"deltaId": "f4b433e3-3cb2-41f6-9925-1dc157d0c49f",
"snapshotId": "1057e1ea-7da6-419e-b676-9a9ff2f45d5c",
"timestamp": "2025-03-09T23:24:45.095287Z",
"user": "selfgovernanceadmin"
}
]
}