9.4. 使用 Satellite API 导出报告模板

您可以使用 Satellite report_templates API 从 Satellite 导出报告模板。有关使用 Satellite API 的更多信息,请参阅 API 指南

流程

  1. 使用以下请求来检索可用报告模板列表:

    请求示例:

    $ curl --insecure --user admin:redhat \
    --request GET \
    --config https://satellite.example.com/api/report_templates \
    | json_reformat

    在本例中,json_reformat 工具用于格式化 JSON 输出。

    响应示例:

    {
        "total": 6,
        "subtotal": 6,
        "page": 1,
        "per_page": 20,
        "search": null,
        "sort": {
            "by": null,
            "order": null
        },
        "results": [
            {
                "created_at": "2019-11-20 17:49:52 UTC",
                "updated_at": "2019-11-20 17:49:52 UTC",
                "name": "Applicable errata",
                "id": 112
            },
            {
                "created_at": "2019-11-20 17:49:52 UTC",
                "updated_at": "2019-11-20 17:49:52 UTC",
                "name": "Applied Errata",
                "id": 113
            },
            {
                "created_at": "2019-11-30 16:15:24 UTC",
                "updated_at": "2019-11-30 16:15:24 UTC",
                "name": "Hosts - complete list",
                "id": 158
            },
            {
                "created_at": "2019-11-20 17:49:52 UTC",
                "updated_at": "2019-11-20 17:49:52 UTC",
                "name": "Host statuses",
                "id": 114
            },
            {
                "created_at": "2019-11-20 17:49:52 UTC",
                "updated_at": "2019-11-20 17:49:52 UTC",
                "name": "Registered hosts",
                "id": 115
            },
            {
                "created_at": "2019-11-20 17:49:52 UTC",
                "updated_at": "2019-11-20 17:49:52 UTC",
                "name": "Subscriptions",
                "id": 116
            }
        ]
    }

  2. 请注意您要导出的模板的 id,并使用以下请求导出模板:

    请求示例:

    $ curl --insecure --output /tmp/_Example_Export_Template.erb_ \
    --user admin:password --request GET --config \
    https://satellite.example.com/api/report_templates/My_Template_ID/export

    请注意,158 是要导出的模板的示例 ID。

    在本例中,导出的模板重定向到 host_complete_list.erb