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": [
    {
      "description": null,
      "created_at": "2019-11-07 08:49:27 UTC",
      "updated_at": "2019-11-07 08:49:27 UTC",
      "name": "report_template51",
      "id": 1007981702
    }
  ]
}

参数

参数名字 描述
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/1007981727-report_template71
200
{
  "template": "template content 60",
  "default": false,
  "snippet": false,
  "locked": false,
  "description": null,
  "created_at": "2019-11-07 08:49:28 UTC",
  "updated_at": "2019-11-07 08:49:28 UTC",
  "name": "report_template71",
  "id": 1007981727,
  "locations": [],
  "organizations": []
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

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": ""
  }
}
422
{
  "error": {
    "id": null,
    "errors": {
      "template": [
        "can't be blank"
      ]
    },
    "full_messages": [
      "Template can't be blank"
    ]
  }
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

Validations:

  • Must be a Integer

report_template
必填

Validations:

  • Must be a Hash

report_template[name]
必填

Validations:

  • Must be a String

report_template[description]
选填 , 允许空值

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_template74",
    "template": "b"
  }
}
201
{
  "template": "b",
  "name": "report_template74",
  "id": 1007981731,
  "snippet": false,
  "description": null,
  "template_kind_id": null,
  "created_at": "2019-11-07T08:49:28.417Z",
  "updated_at": "2019-11-07T08:49:28.429Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

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
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

Validations:

  • Must be a Integer

version
选填

模板版本

Validations:

  • Must be a String


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

示例

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

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

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[description]
选填 , 允许空值

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/1007981734-report_template77
{
  "report_template": {}
}
200
{
  "id": 1007981734,
  "name": "report_template77",
  "template": "template content 65",
  "snippet": false,
  "template_kind_id": null,
  "created_at": "2019-11-07T08:49:28.522Z",
  "updated_at": "2019-11-07T08:49:28.522Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null,
  "description": null
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be a String


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

示例

POST /api/report_templates/1007981722-report_template67/clone
{
  "report_template": {
    "name": "MyClone"
  }
}
201
{
  "id": 1007981723,
  "name": "MyClone",
  "template": "template content 56",
  "snippet": false,
  "template_kind_id": null,
  "created_at": "2019-11-07T08:49:28.256Z",
  "updated_at": "2019-11-07T08:49:28.256Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null,
  "description": null
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

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/1007981717-report_template62/export
200
template content 51
<%#
name: report_template62
snippet: false
model: ReportTemplate
%>

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

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/1007981727/generate
{
  "report_format": "json",
  "report_template": {}
}
200
[
  {
    "a": 1
  },
  {
    "a": 2
  }
]

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

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.

report_format
选填

Report format, defaults to ‘csv’

Validations:

  • Must be one of: csv, json, yaml, html.


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
{
  "input_values": {
    "foo": "bar"
  },
  "report_template": {}
}
200
{
  "job_id": "JOB-UNIQUE-IDENTIFIER",
  "data_url": "/api/v2/report_templates/1007981703-report_template113/report_data/JOB-UNIQUE-IDENTIFIER"
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

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

report_format
选填

Report format, defaults to ‘csv’

Validations:

  • Must be one of: csv, json, yaml, html.


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/1007981707/report_data/JOBID
404
{
  "message": "Report not found, please ensure you used the correct job_id"
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

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