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

Examples

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
    }
  ]
}

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

search
Optional

filter results

Validations:

  • Must be a String

order
Optional

Sort field and order, eg. ‘id DESC’

Validations:

  • Must be a String

page
Optional

Page number, starting at 1

Validations:

  • Must be a number.

per_page
Optional

Number of results per page to return

Validations:

  • Must be a number.

Search fields

Field name Tipo 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

Examples

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": []
}

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

id
Required

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

Examples

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
    }
  ]
}

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

report_template
Required

Validations:

  • Must be a Hash

report_template[name]
Required

Validations:

  • Must be a String

report_template[template]
Required

Validations:

  • Must be a String

report_template[snippet]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

Validations:

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

report_template[audit_comment]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

Validations:

  • Must be a String

report_template[locked]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

Whether or not the template is locked for editing

Validations:

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

report_template[default]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

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]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

REPLACE locations with given ids

Validations:

  • Must be an array of any type

report_template[organization_ids]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type


POST /api/report_templates/import
Import a report template

Examples

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
}

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

report_template
Required

Validations:

  • Must be a Hash

report_template[name]
Optional

template name

Validations:

  • Must be a String

report_template[template]
Optional

template contents including metadata

Validations:

  • Must be a String

report_template[location_ids]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

REPLACE locations with given ids

Validations:

  • Must be an array of any type

report_template[organization_ids]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type

options
Optional

Validations:

  • Must be a Hash

options[force]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

use if you want update locked templates

Validations:

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

options[associate]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

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]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

lock imported templates (false by default)

Validations:

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

options[default]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

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

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

version
Optional

template version

Validations:

  • Must be a String


PUT /api/report_templates/:id
Update a report template

Examples

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"
    ]
  }
}

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

id
Required

Validations:

  • Must be a String

report_template
Required

Validations:

  • Must be a Hash

report_template[name]
Optional

Validations:

  • Must be a String

report_template[template]
Optional

Validations:

  • Must be a String

report_template[snippet]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

Validations:

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

report_template[audit_comment]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

Validations:

  • Must be a String

report_template[locked]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

Whether or not the template is locked for editing

Validations:

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

report_template[default]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

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]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

REPLACE locations with given ids

Validations:

  • Must be an array of any type

report_template[organization_ids]
Optional , <span class="translation_missing" title="translation missing: gl.apipie.nil_allowed">Nil Allowed</span>

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type


DELETE /api/report_templates/:id
Delete a report template

Examples

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
}

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

id
Required

Validations:

  • Must be a String


POST /api/report_templates/:id/clone
Clone a template

Examples

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"
    ]
  }
}

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

id
Required

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
Required

Validations:

  • Must be a Hash

report_template[name]
Required

template name

Validations:

  • Must be a String


GET /api/report_templates/:id/export
Export a report template to ERB

Examples

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

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

id
Required

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

Examples

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

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

id
Required

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
Optional

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

Validations:

  • Must be a Hash

gzip
Optional

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).

Examples

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"
}

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

id
Required

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
Optional

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

Validations:

  • Must be a Hash

gzip
Optional

Compress the report using gzip

Validations:

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

mail_to
Optional

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

Validations:

  • Must be a String

generate_at
Optional

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.

Examples

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

Params

Param Name Description
location_id
Optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
Optional

Scope by organizations

Validations:

  • Must be a Integer

id
Required

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
Required

ID assigned to generating job by the schedule command

Validations:

  • Must be a String