搜索

8.6. 使用 Satellite API 导入报告模板

download PDF

您可以使用 Satellite API 将报告模板导入到 Satellite。使用 Satellite API 导入报告模板会自动解析报告模板元数据并分配机构和位置。有关使用 Satellite API 的更多信息,请参阅 API 指南

前提条件

流程

  1. 使用以下示例格式化您要导入到 .json 文件的模板:

    # cat Example_Template.json
    {
        "name": "Example Template Name",
        "template": "
        Enter ERB Code Here
    "
    }

    带有 ERB 模板的 JSON 文件示例:

    {
        "name": "Hosts - complete list",
        "template": "
    <%#
    name: Hosts - complete list
    snippet: false
    template_inputs:
    - name: host
      required: false
      input_type: user
      advanced: false
      value_type: plain
      resource_type: Katello::ActivationKey
    model: ReportTemplate
    -%>
    <% load_hosts(search: input('host')).each_record do |host| -%>
    <%
          report_row(
              'Server FQND': host.name
          )
    -%>
    <%  end -%>
    <%= report_render %>
    "
    }

  2. 使用以下请求导入模板:

    $ curl --insecure --user admin:redhat \
    --data @Example_Template.json --header "Content-Type:application/json" \
    --request POST --config https://satellite.example.com/api/report_templates/import
  3. 使用以下请求来检索报告模板列表,并验证您可以在 Satellite 中查看模板:

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

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.