GET /api/report_templates
List all report templates

GET /api/locations/:location_id/report_templates
List all report templates per location

GET /api/organizations/:organization_id/report_templates
List all report templates per organization

示例

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

Sort field and order, eg. ‘id DESC’

Validations:

  • Must be a String

page
選填

頁數,從 1 開始

Validations:

  • Must be a number.

per_page
選填

每頁要傳回的結果數量

Validations:

  • Must be a number.

Search fields

Field name 類型 Possible values
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
Show a report template

示例

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
Create a report template

示例

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]
選填 , 允許空值

Whether or not the template is added automatically to new organizations and locations

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
Import a report template

示例

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]
選填

template contents including metadata

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]
選填 , 允許空值

use if you want update locked templates

Validations:

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

options[associate]
選填 , 允許空值

determines when the template should associate objects based on metadata, new means only when new template is being created, always means both for new and existing template which is only being updated, never ignores metadata

Validations:

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

options[lock]
選填 , 允許空值

lock imported templates (false by default)

Validations:

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

options[default]
選填 , 允許空值

makes the template default meaning it will be automatically associated with newly created organizations and locations (false by default)

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
Update a report template

示例

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]
選填 , 允許空值

Whether or not the template is added automatically to new organizations and locations

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 a report template

示例

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
Export a report template to 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
選填

Hash of input values where key is the name of input, value is the value for this input

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

Hash of input values where key is the name of input, value is the value for this input

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