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.

query_templates(filters, group=None, sort=None, project=None, page=None, pageSize=None)

Search over templates

Parameters:
  • filters (dict) – This paramenter is the ‘where’ clause of my query,

  • None (by default is) –

    {

    “type”: { “$in”: [

    ”term”, “study”, “generic”

    }

    The name of field can be:
    1. complate path: example: data.general.change_status

    2. only field key: change_status

    You can use regex in query:

    {‘$regex’:q,”$options”: “i”}

  • records (then return all) –

    {

    “type”: { “$in”: [

    ”term”, “study”, “generic”

    }

    The name of field can be:
    1. complate path: example: data.general.change_status

    2. only field key: change_status

    You can use regex in query:

    {‘$regex’:q,”$options”: “i”}

  • fields (dict) – The argument filter by columns, default is None { “_id”: 1 }

  • group (dict) –

    The argument group by column name and do one operation, default is None {

    ”_id”: “$type”, “count”: { “$sum”: 1 }

  • sort (dict) – The argument sort record by columns, default is None, you can sort:

__annotations__ = {}
__firstlineno__ = 10
__static_attributes__ = ('_requester',)