foliolib.folio.api.templateEngine.TemplateEngine
- class foliolib.folio.api.templateEngine.TemplateEngine(tenant: str, okapi: Optional[foliolib.okapi.okapiClient.OkapiClient] = None)
Bases:
foliolib.folio.FolioApimod-template-engine API
This module dedicated for storing templates and generating text, html, xml, doc, docx etc from the template.
- Parameters
tenant (str) – Tenant id
okapi (OkapiClient, optional) – Instance of OkapiClient. Defaults to None.
Methods
delete_template(templateId)Delete template by id
get_template(templateId)Get template by id
get_templates(**kwargs)Get a list of templates
modify_template(templateId, template)Modify a template
set_template(template)Add a new template
set_templateRequest(templateRequest)process specified template using given context
- delete_template(templateId: str)
Delete template by id
DELETE /templates/{templateId}- Parameters
templateId (str) –
- Raises
OkapiRequestNotFound – Not Found
OkapiFatalError – Server Error
- get_template(templateId: str)
Get template by id
GET /templates/{templateId}- Parameters
templateId (str) –
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestNotFound – Not Found
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Template", "type": "object", "properties": { "id": { "type": "string", "description": "Template id" }, "description": { "type": "string", "description": "Template description" }, "outputFormats": { "type": "array", "items": { "type": "string" }, "description": "Array of output formats" }, "templateResolver": { "type": "string", "description": "Template engine name" }, "localizedTemplates": { "type": "object", "description": "List of localized templates", "additionalProperties": { "type": "object", "description": "Template content", "$ref": "templateContent.json" } }, "metadata": { "type": "object", "$ref": "raml-util/schemas/metadata.schema" } }, "required": [ "templateResolver", "localizedTemplates", "outputFormats" ] }
- get_templates(**kwargs)
Get a list of templates
GET /templates- Parameters
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
offset (int) –
(default=0) Skip over a number of elements by specifying an offset value for the query
Example
0
limit (int) –
(default=10) Limit the number of elements returned in the response
Example
10
query (str) – A query string to filter templates based on matching criteria in fields.
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "description": "Collection of templates", "properties": { "templates": { "type": "array", "description": "List of templates", "items": { "type": "object", "$ref": "template.json" } }, "totalRecords": { "type": "integer" } }, "required": [ "templates", "totalRecords" ] }
- modify_template(templateId: str, template: dict)
Modify a template
PUT /templates/{templateId}- Parameters
templateId (str) –
template (dict) – See Schema below
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestNotFound – Not Found
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Template", "type": "object", "properties": { "id": { "type": "string", "description": "Template id" }, "description": { "type": "string", "description": "Template description" }, "outputFormats": { "type": "array", "items": { "type": "string" }, "description": "Array of output formats" }, "templateResolver": { "type": "string", "description": "Template engine name" }, "localizedTemplates": { "type": "object", "description": "List of localized templates", "additionalProperties": { "type": "object", "description": "Template content", "$ref": "templateContent.json" } }, "metadata": { "type": "object", "$ref": "raml-util/schemas/metadata.schema" } }, "required": [ "templateResolver", "localizedTemplates", "outputFormats" ] }
- set_template(template: dict)
Add a new template
POST /templates- Parameters
template (dict) – See Schema below
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
OkapiRequestUnprocessableEntity – Unprocessable Entity
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Template", "type": "object", "properties": { "id": { "type": "string", "description": "Template id" }, "description": { "type": "string", "description": "Template description" }, "outputFormats": { "type": "array", "items": { "type": "string" }, "description": "Array of output formats" }, "templateResolver": { "type": "string", "description": "Template engine name" }, "localizedTemplates": { "type": "object", "description": "List of localized templates", "additionalProperties": { "type": "object", "description": "Template content", "$ref": "templateContent.json" } }, "metadata": { "type": "object", "$ref": "raml-util/schemas/metadata.schema" } }, "required": [ "templateResolver", "localizedTemplates", "outputFormats" ] }
- set_templateRequest(templateRequest: dict)
process specified template using given context
POST /template-request- Parameters
templateRequest (dict) – See Schema below
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
OkapiRequestUnprocessableEntity – Unprocessable Entity
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Request for template processing", "type": "object", "properties": { "templateId": { "type": "string", "description": "Target template id" }, "lang": { "type": "string", "description": "Target template language" }, "outputFormat": { "type": "string", "description": "Output format" }, "context": { "type": "object", "description": "Context object" } }, "required": [ "templateId", "lang", "outputFormat" ], "additionalProperties": false }
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Result of template processing", "type": "object", "properties": { "templateId": { "type": "string", "description": "Source template id" }, "result": { "type": "object", "description": "Template processing output", "$ref": "templateContent.json" }, "meta": { "type": "object", "description": "Template output metadata", "properties": { "size": { "type": "integer", "description": "Size of output in bytes" }, "dateCreate": { "type": "string", "format": "date-time", "description": "Date of template processing" }, "lang": { "type": "string", "description": "Processed template language" }, "outputFormat": { "type": "string", "description": "Output format" } }, "additionalProperties": false } }, "additionalProperties": false }