Template API

Templates high-level API.

class template_api.TemplateAPI(sdk)

API for the Template entities.

Supports all of the CRUD operations and pulling/updating templates.

Example usage:

api = TemplateAPI(...)

# Get one template by ID
template = api.get_template('dsw:template:1.0.0')

# Get all templates for a given organization
templates = api.get_templates(organization_id='dsw')

# Get page number 1 (each page having 10 templates) of templates
# containing the "foo" string, sorted by the UUID attribute in the
# ascending order
templates = api.get_templates(q='foo', page=1, size=10, start='id,asc')

# Create template
template = api.create_template(template_id='new_temp', ...)

# Delete template
api.delete_template(template.id)

# Delete all templates for a given organization
api.delete_templates(organization_id='dsw')

# Delete list of templates
api.delete_templates(ids=['dsw:template:1.0.0', 'dsw:temp:2.3.1'])

# Pull specified templates from the Data Stewardship Registry
api.pull_templates(['dsw:template:1.0.0', 'dsw:temp:2.3.1'])

# Update specified templates (so that they have latest version
# available)
api.update_templates(['dsw:template:1.0.0', 'dsw:temp:2.3.1'])

# Update all templates to the latest version available
api.update_templates()
model_class

alias of dsw_sdk.high_level_api.models.templates.template.Template

get_template(id_)

Retrieves one template, identified by it’s ID. Also loading all of it’s related files and assets.

Parameters
  • id – template identifier

  • id_ (str) –

Returns

object representing a template

Return type

dsw_sdk.high_level_api.models.templates.template.Template

get_templates(organization_id=None, template_id=None, **query_params)

Retrieves list of templates. Also loading all related files and assets.

Possibly identified by the organization to which they belong to. It’s also possible to search based on the template_id (note that this is different from template’s id attribute).

Parameters
  • organization_id (Optional[str]) – ID of the organization whose templates we want to fetch

  • template_id (Optional[str]) – template_id attribute of a template (different from id attribute)

  • query_params – optional query params: q, size, page and sort

Returns

list of objects, each representing a template

Return type

List[dsw_sdk.high_level_api.models.templates.template.Template]

create_template(**kwargs)

Creates a template with given data on the DSW server.

Parameters

kwargs – all the data needed for the template creation

Returns

object representing the new template

Return type

dsw_sdk.high_level_api.models.templates.template.Template

delete_template(id_)

Deletes a template from the DSW server.

Parameters

id_ (str) – ID of the template to delete

delete_templates(organization_id=None, ids=None)

Deletes multiple templates on the DSW server, identified either by organization or ID.

Parameters
  • organization_id (Optional[str]) – ID of the organization whose templates we want to delete

  • ids (Optional[List[str]]) – IDs of templates to delete

pull_templates(ids)

Pulls given templates from the Data Stewardship Registry, so they become available in the DSW instance.

Parameters

ids (List[str]) – IDs of the templates you want to pull form the registry

update_templates(ids=None)

Updates specified templates, pulling their latest available version. If no IDs are given, updates all templates on the DSW instance.

Parameters

ids (Optional[List[str]]) – optional list of template IDs to update