Chapter 2. Comparison report API
The purpose of the comparison report is to fetch system profiles for the systems requested, pull their facts from the inventory service, and then transform those facts into a comparison report. If you simply need to fetch the information for a system and do not require comparison information, you can use the inventory API directly.
Currently, there is a 45 system limit when comparing systems via either the web user interface or API. Requests to compare more than 45 systems at a time may result in a 400 error. Such requests may hit the timeout limit set by the API infrastructure.
Example
The following example uses the comparison_report API to interact with registered systems in inventory to compare system configurations using the GET method. This request fetches the most current system state, using data from the inventory service for the given system IDs, and generates a comparison report.
Request:
GET api/drift/v1/comparison_report?system_ids[]=<UUID>&system_ids[]=<UUID>
openapi: 3.0.1 info: version: "1.0" title: Drift Backend Service description: Service that returns differences between systems. license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html servers: - url: "/api/drift/v1" paths: /comparison_report: parameters: - $ref: '#/components/parameters/rhIdentityHeader' get: summary: fetch comparison report description: "Fetch a comparison report for given system IDs. This will only fetch the most current system state using data from inventory service." operationId: drift.views.v1.comparison_report parameters: - name: system_ids[] in: query schema: type: array items: type: string format: uuid required: true description: list of system IDs to generate report for
Responses:
'200': description: a comparison report for the given system IDs content: application/json: schema: $ref: "#/components/schemas/ComparisonReport" examples: jsonObject: summary: A sample comparison report externalValue: "https://git.io/fhQ00" '400': $ref: '#/components/responses/BadRequest' '500': $ref: '#/components/responses/InternalServerError'
Example
The following example uses the comparison_report API to interact with registered systems in inventory to compare system configurations by providing a JSON file as input using the POST method.
There is no system limit when comparing systems using the POST method via API.
Request:
$ curl -k -u username:password -X POST --header "Content-Type: application/json" https://cloud.redhat.com/api/drift/v1/comparison_report -d @/directory/example-uuid-file.json
An example of JSON file content follows.
{"system_ids": ["UUID1", "UUID2", "UUID3"]}
2.1. Systems-only report queries
You can query systems-only reports by using API:
GET api/drift/v1/comparison_report?system_ids[]=55e47a1d-05d7-4abb-963 a-ba513a0a57ad&system_ids[]=....
2.2. Systems and baseline report queries
You can query systems and baseline reports by using API:
GET api/drift/v1/comparison_report?system_ids[]=55e47a1d-05d7-4abb-963 a-ba513a0a57ad&baseline_ids[]=79032c7b-8284-44d0-b820-ebbb6d25c5e2
2.3. System and historical system profile report queries
You can query systems and historical system profile reports by using API:
GET api/drift/v1/comparison_report?system_ids[]=55e47a1d-05d7-4abb-963 a-ba513a0a57ad&historical_system_profile_ids[]=5d7dd2e9-18e5-412e-8f25-efa8a96a4289
2.4. System, baseline, and historical system profile report queries
You can query systems, baselines, and historical system profile reports by using API:
GET api/drift/v1/comparison_report?system_ids[]=55e47a1d-05d7-4abb-963 a-ba513a0a57ad&baseline_ids[]=79032c7b-8284-44d0-b820-ebbb6d25c5e2 &historical_system_profile_ids[]=5d7dd2e9-18e5-412e-8f25-efa8a96a4 289
2.5. Exporting the comparison report API
You can use the comparison report API to export the entire comparison report output for the given systems, baselines, and historical system profile IDs without any filters. The output includes all facts including categories (parent facts) and sub facts, and their values in a comma-separated values (CSV) format.
Request:
$ curl -X GET 'https://username:password@cloud.redhat.com/api/drift/v1/ comparison_report?baseline_ids[]=UUID1&system_ids[]=UUID2&system_ids[]=UUID3' -H 'accept: text/csv'
2.6. Reference queries
You can set a reference in the query when using the API:
GET api/drift/v1/comparison_report?reference_id=UUID1&system_ids[]= 55e47a1d-05d7-4abb-963a-ba513a0a57ad&baseline_ids[]=79032c7b- 8284-44d0-b820-ebbb6d25c5e2&historical_system_profile_ids[]= 5d7dd2e9-18e5-412e-8f25-efa8a96a4289
The reference_id
parameter is optional, and you can use only one reference ID in a query. You can set it to any used parameter in the comparison query: system ID, baseline ID, or historical system profile ID. When you use the reference ID, the Comparison service compares all systems, baselines, and historical system profiles in the list against it.