Templates¶
The Templates component of the Genomcore API allows you to create, edit and delete templates in Genomcore UMD.
Get more information about the Templates inside the records API here
Create¶
Create a template in the project defined in the token.
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.
The type of the template can be generic or an specific type (eg. “study”, “patient”, etc). Specific types have special constraints and fields. These provide extra functionality in the Genomcore BIMS Platform.
More information about the fields and template types can be found in the Genomcore UMD documentation.
import logging
from dotenv import load_dotenv
from genomcore.client import GenomcoreApiClient
load_dotenv(override=True)
logging.basicConfig(
level="INFO",
format="[%(asctime)s][%(levelname)s][%(name)s] -- %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
api = GenomcoreApiClient(
token=os.getenv("TOKEN"),
refresh_token=os.getenv("REFRESH_TOKEN")
)
body = {
"name": "e2e_test_template",
"slug": "e2e_test_template",
"type": "generic",
"color": "#000000",
"data": {} # Add the fields of the template here
}
response = api.templates.create_template(body=body)
Update¶
Update a template in the project.
The template to update is identified by the template_id/slug.The body should be a dictionary with the same structure as the create template.
Warning
A complete template must be sent in the body. The system does not allow partial updates.
body = {
"name": "e2e_test_template (updated)",
"slug": "e2e_test_template",
"type": "generic",
"color": "#000000",
"data": {} # Add the fields of the template here
}
response = api.templates.update_template(template_id="e2e_test_template", body=body)
Delete¶
Delete a template in the project.
The template to delete is identified by the template_id/slug.
response = api.templates.delete_template(template_id="e2e_test_template")
Warning
Deleting a template will delete all the records that defined by it.
Get¶
Get struct template by its ID or unique ID.
response = api.templates.delete_template(slug_or_id="id_template")
Note
urllib.parse is used to make ‘uniqueId’ URL-safe.