搜索

第 2 章 比较报告 API

download PDF

比较报告的目的是为请求的系统获取系统配置文件,从库存服务中提取其事实,然后将这些事实转换为比较报告。如果您只需要获取系统的信息且不需要比较信息,您可以直接使用清单 API。

注意

目前,通过 Web 用户界面或 API 比较系统时会有 45 个系统限制。一次比较超过 45 个系统的请求可能会导致 400 错误。此类请求可能会达到 API 基础架构设置的超时限制。

示例

以下示例使用 comparison_report API 与清单中注册的系统交互,以使用 GET 方法比较系统配置。此请求使用给定系统 ID 的清单服务中的数据来获取最新的系统状态,并生成比较报告。

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

响应:

        '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'

示例

以下示例使用 comparison_report API 与清单中注册的系统交互,通过提供 JSON 文件作为 POST 方法输入来比较系统配置。

注意

通过 API 使用 POST 方法比较系统时没有系统限制。

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

下面是一个 JSON 文件内容示例。

{"system_ids": ["UUID1", "UUID2", "UUID3"]}

2.1. 仅系统报告查询

您可以使用 API 查询仅系统报告:

GET
api/drift/v1/comparison_report?system_ids[]=55e47a1d-05d7-4abb-963
a-ba513a0a57ad&system_ids[]=....
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.