Templates Controller¶
- class genomcore.controllers.templates.TemplatesController(*args, **kwargs)¶
Bases:
BaseController- get(slug_or_id: str)¶
Get struct template by its ID or unique ID.
Note: urllib.parse is used to make ‘uniqueId’ URL-safe.
- Parameters:
slug_or_id (Union[str, int]) – id or slug of the template
- Returns:
raw template struct
- Return type:
Template
- create_template(body: dict) str¶
Create a Record Template.
- Parameters:
body (dict) – The template body.
- Returns:
The response from the API.
- Return type:
str
Note
The body should be a dictionary with the following keys:
name (str): The name of the template.
slug (str): The slug of the template.
type (str): The type of the template.
color (str): The color of the template.
data (dict): The data of the template.
The data value should be a dictionary with all the fields of the template. More information about the fields can be found in the Genomcore UMD documentation.
Example:
body = { "name": "e2e_test_template", "slug": "e2e_test_template", "type": "generic", "color": "#000000", "data": {} # Add the fields of the template here } api.templates.create_template(body=body)
- delete_template(template_id: str) str¶
Delete a Record Template.
- Parameters:
template_id (str) – The ID of the template to delete.
- Returns:
The response from the API.
- Return type:
str
Example:
api.templates.delete_template(template_id="template_id")
Warning
This method will delete the all records associated with the template. Be careful when using this method.
- update_template(template_id: str, body: dict) str¶
Update a Record Template.
- Parameters:
template_id (str) – The ID of the template to update.
body (dict) – The template body.
- Returns:
The response from the API.
- Return type:
str
Note
The body should be a dictionary with the following keys:
name (str): The name of the template.
slug (str): The slug of the template.
type (str): The type of the template.
color (str): The color of the template.
data (dict): The data of the template.
The data value should be a dictionary with all the fields of the template. More information about the fields can be found in the Genomcore UMD documentation.
Example:
body = { "name": "e2e_test_template (updated)", "slug": "e2e_test_template", "type": "generic", "color": "#000000", "data": {} # Add the fields of the template here } api.templates.update_template(template_id="template_id", body=body)
Warning
This method will update the template with the new data. All fields should be provided in the body since. The system does not support partial updates.
- __annotations__ = {}¶
- __firstlineno__ = 10¶
- __static_attributes__ = ('_requester',)¶