GET /api/report_templates
列出所有报告模块

GET /api/locations/:location_id/report_templates
列出每个位置的报告模板

GET /api/organizations/:organization_id/report_templates
列出每个机构的所有报告模板

示例

GET /api/report_templates
200
{
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "created_at": "2019-09-11 14:39:38 UTC",
      "updated_at": "2019-09-11 14:39:38 UTC",
      "name": "report_template36",
      "id": 1007981737
    }
  ]
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

search
选填

过滤结果

Validations:

  • Must be a String

order
选填

排序项和顺序,例如 ‘id DESC’

Validations:

  • Must be a String

page
选填

页号,从 1 开始

Validations:

  • Must be a number.

per_page
选填

每页中显示的返回结果数

Validations:

  • Must be a number.

搜索字段

字段名 类型 可能的值
default true, false
location string
location_id integer
locked true, false
name string
organization string
organization_id integer
snippet true, false
template text

GET /api/report_templates/:id
显示一个报告模板

示例

GET /api/report_templates/1007981756-report_template51
200
{
  "template": "template content 46",
  "default": false,
  "snippet": false,
  "locked": false,
  "created_at": "2019-09-11 14:39:39 UTC",
  "updated_at": "2019-09-11 14:39:39 UTC",
  "name": "report_template51",
  "id": 1007981756,
  "locations": [],
  "organizations": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.


POST /api/report_templates
创建一个报告模板

示例

POST /api/report_templates
{
  "report_template": {
    "name": "report_template_test",
    "template": "a,b,c",
    "organization_ids": [
      114267492
    ]
  }
}
201
{
  "template": "a,b,c",
  "default": false,
  "snippet": false,
  "locked": false,
  "created_at": "2019-09-11 14:39:38 UTC",
  "updated_at": "2019-09-11 14:39:38 UTC",
  "name": "report_template_test",
  "id": 1007981732,
  "locations": [],
  "organizations": [
    {
      "id": 114267492,
      "name": "Empty Organization",
      "title": "Empty Organization",
      "description": null
    }
  ]
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

report_template
必填

Validations:

  • Must be a Hash

report_template[name]
必填

Validations:

  • Must be a String

report_template[template]
必填

Validations:

  • Must be a String

report_template[snippet]
选填 , 允许空值

Validations:

  • Must be one of: true, false, 1, 0.

report_template[audit_comment]
选填 , 允许空值

Validations:

  • Must be a String

report_template[locked]
选填 , 允许空值

是否已锁定该模板进行编辑

Validations:

  • Must be one of: true, false, 1, 0.

report_template[default]
选填 , 允许空值

模板是否会自动添加到新的机构和位置

Validations:

  • Must be one of: true, false, 1, 0.

report_template[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

report_template[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type


POST /api/report_templates/import
导入一个报告模板

示例

POST /api/report_templates/import
{
  "report_template": {
    "name": "report_template39",
    "template": "b"
  }
}
201
{
  "template": "b",
  "name": "report_template39",
  "id": 1007981740,
  "snippet": false,
  "template_kind_id": null,
  "created_at": "2019-09-11T14:39:38.542Z",
  "updated_at": "2019-09-11T14:39:38.555Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

report_template
必填

Validations:

  • Must be a Hash

report_template[name]
选填

模板名称

Validations:

  • Must be a String

report_template[template]
选填

包括元数据的模板内容

Validations:

  • Must be a String

report_template[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

report_template[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type

options
选填

Validations:

  • Must be a Hash

options[force]
选填 , 允许空值

在您希望更新锁定的模板时使用

Validations:

  • Must be one of: true, false, 1, 0.

options[associate]
选填 , 允许空值

确定模板何时应基于元数据关联对象,new 表示只在创建新模板时,always 表示同时适用于新模板和的只进行更新的现有模板,never 表示忽略元数据

Validations:

  • Must be one of: new, always, never.

options[lock]
选填 , 允许空值

锁定导入的模板(默认为 false)

Validations:

  • Must be one of: true, false, 1, 0.

options[default]
选填 , 允许空值

把模块设为默认意味着它将自动与新创建的组织和位置相关联(默认为 false)

Validations:

  • Must be one of: true, false, 1, 0.


GET /api/report_templates/revision

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

version
选填

模板版本

Validations:

  • Must be a String


PUT /api/report_templates/:id
更新一个报告模板

示例

PUT /api/report_templates/1007981734
{
  "report_template": {
    "template": ""
  }
}
422
{
  "error": {
    "id": 1007981734,
    "errors": {
      "template": [
        "can't be blank"
      ]
    },
    "full_messages": [
      "Template can't be blank"
    ]
  }
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be a String

report_template
必填

Validations:

  • Must be a Hash

report_template[name]
选填

Validations:

  • Must be a String

report_template[template]
选填

Validations:

  • Must be a String

report_template[snippet]
选填 , 允许空值

Validations:

  • Must be one of: true, false, 1, 0.

report_template[audit_comment]
选填 , 允许空值

Validations:

  • Must be a String

report_template[locked]
选填 , 允许空值

是否已锁定该模板进行编辑

Validations:

  • Must be one of: true, false, 1, 0.

report_template[default]
选填 , 允许空值

模板是否会自动添加到新的机构和位置

Validations:

  • Must be one of: true, false, 1, 0.

report_template[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

report_template[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type


DELETE /api/report_templates/:id
删除一个报告模板

示例

DELETE /api/report_templates/1007981749-report_template46
{
  "report_template": {}
}
200
{
  "id": 1007981749,
  "name": "report_template46",
  "template": "template content 41",
  "snippet": false,
  "template_kind_id": null,
  "created_at": "2019-09-11T14:39:38.775Z",
  "updated_at": "2019-09-11T14:39:38.775Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be a String


POST /api/report_templates/:id/clone
克隆模板

示例

POST /api/report_templates/1007981743-report_template42/clone
{
  "report_template": {
    "name": ""
  }
}
422
{
  "error": {
    "id": null,
    "errors": {
      "name": [
        "can't be blank"
      ]
    },
    "full_messages": [
      "Name can't be blank"
    ]
  }
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

report_template
必填

Validations:

  • Must be a Hash

report_template[name]
必填

模板名称

Validations:

  • Must be a String


GET /api/report_templates/:id/export
导出一个报告模板到 ERB

示例

GET /api/report_templates/1007981763-report_template58/export
200
template content 53
<%#
name: report_template58
snippet: false
model: ReportTemplate
%>

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.


POST /api/report_templates/:id/generate
Generate report from a template

示例

POST /api/report_templates/1007981703/generate
{
  "input_values": {
    "hello": "ohai"
  },
  "report_template": {}
}
200
2 ohai

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

input_values
选填

哈希输入值,其中关键字是输入名称,值是这个输入

Validations:

  • Must be a Hash

gzip
选填

Compress the report uzing gzip

Validations:

  • Must be one of: true, false, 1, 0.


POST /api/report_templates/:id/schedule_report
Schedule generating of a report

The reports are generated asynchronously. If mail_to is not given, action returns an url to get resulting report from (see report_data).

示例

POST /api/report_templates/:id/schedule_report/
200
{
  "job_id": UNIQUE-REPORT-GENERATING-JOB-UUID
  "data_url": "/api/v2/report_templates/1/report_data/UNIQUE-REPORT-GENERATING-JOB-UUID"
}
POST /api/report_templates/1007981703/schedule_report
{
  "report_template": {}
}
200
{
  "job_id": "JOB-UNIQUE-IDENTIFIER",
  "data_url": "/api/v2/report_templates/1007981703-report_template25/report_data/JOB-UNIQUE-IDENTIFIER"
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

input_values
选填

哈希输入值,其中关键字是输入名称,值是这个输入

Validations:

  • Must be a Hash

gzip
选填

Compress the report using gzip

Validations:

  • Must be one of: true, false, 1, 0.

mail_to
选填

If set, scheduled report will be delivered via e-mail. Use ‘,’ to separate multiple email addresses.

Validations:

  • Must be a String

generate_at
选填

UTC time to generate report at

Validations:

  • Must be a String


GET /api/report_templates/:id/report_data/:job_id
Downloads a generated report

Returns the report data as a raw response. In case the report hasn’t been generated yet, it will return an empty response with http status 204 - NoContent.

示例

GET /api/report_templates/1007981712/report_data/JOBID
204

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

job_id
必填

ID assigned to generating job by the schedule command

Validations:

  • Must be a String