Module: template_set

Copyright 2020 Parsable, Inc
API address: /api/template_sets
Functionality for Template Sets. A Template Set is a list of Templates.

ModuleServicesData typesConstants
template_setTemplateSetService
TemplateSet
TemplateSetCounts
TemplateSetFetchResult
TemplateSetParams
TemplateSetQueryResult
TemplateSetSelectOpts
TemplateUnion
TemplateUnionFetchResult
TemplateUnionQueryResult
TemplateUnionSelectOpts
TemplateUnionWhereOpts
VersionRef

Data structures

Struct: TemplateSetParams

KeyFieldTypeDescriptionRequirednessDefault value
1titlestringName of the template set optional
2descripstringDescription of the template set optional
3typjob_template.TemplateType * Set the type of the template set. * It can either contain job or issue templates. * optional

Mutable parts of the job template

Struct: TemplateSetCounts

KeyFieldTypeDescriptionRequirednessDefault value
1completedJobsi32default
2activeJobsi32default

Struct: TemplateSet

KeyFieldTypeDescriptionRequirednessDefault value
1idstringdefault
2internalVersioni32Only increments when update is called. default
3publicVersioni32Increment logic for publicVersion:

Normal team flow:
1. A new template set is created with create, initially publicVersion=0 and status=Unpublished.
2. publicVersion increments by 1 from latest published publicVersion when publish is called, and status=Published.
3. When a new edit is made with update on either published or unpublished template set, a new entry is created with publicVersion=0 and status=Unpublished.
4. Repeat from step 2) or 3).

Review team flow:
1. A new template set is created with create, initially publicVersion=0 and status=Unpublished.
2. publicVersion increments by 1 from max publicVersion when beginReview is called, and status=InReview. publicVersion does not change if this internalVersion has already been reviewed before, i.e., publicVersion != 0.
3. endReview must be called next to close review, making status=Unpublished.
4. A specific publicVersion must be used to call publishVersion and make status=Published.
5. When a new edit is made with update on either published or unpublished template set, a new entry is created with publicVersion=0 and status=Unpublished.
6. Repeat from step 2) or 5).
default
4titlestringdefault
5descripstringDescription default
6statusjob_template.JobTemplateStatusdefault
7teamIdstringdefault
8lastAuthoredAti64authored time for this edit default
9publishedAti64published time for this edit, 0 if not published default
10archivedAti64archive time, 0 means the template set is not archived default
11lastAuthorIdstringdefault
12lockjob_template.JobTemplateLockStatus of lock by another user. Internal authoring lock optional
13publishedVersioni32Only increments when publish or publishVersion is called. Is the same as publicVersion for normal teams, and only increments on publish for review teams. Is 0 for all template sets with status!=Published. default
14typjob_template.TemplateTypedefault
15publishedByIdstringoptional
101teamteam.TeamModularoptional
102lastPublishedAti64last published time for this template set. 0 if not published optional
103lastAuthoruser.UserModularoptional
104templateslist<job_template.JobTemplateModular>optional
105countsTemplateSetCountsoptional
106templateTagslist<job_template.TemplateTag>optional
107lastPublishedVersioni32last published version (public version) for this template set. 0 if not published optional
108lastModifiedAti64Bumps up on edit, status change, archive optional
109attributeslist<abac.AbacAttribute>optional
110originalAuthoruser.UserModularoptional
111lastPublishedByuser.Useroptional

Struct: TemplateSetSelectOpts

KeyFieldTypeDescriptionRequirednessDefault value
1includeTeambooldefault
2includeLastPublishedboolincludes both lastPublishedAt and lastPublishedVersion default
3includeLastAuthorbooldefault
4includeTemplatesbooldefault
5includeTagsbooldefault
6includeCountsbooldefault
7includeLastModifiedbooldefault
8includeAttributesbooldefault
9includeOriginalAuthorbooldefault

Union: TemplateSetFetchResult

KeyFieldTypeDescriptionRequirednessDefault value
1templateSetTemplateSetdefault
2errcommon.SystemExceptiondefault

Struct: TemplateSetQueryResult

KeyFieldTypeDescriptionRequirednessDefault value
1templateSetslist<TemplateSet>default
2pageInfocommon.PageInfooptional

Union: TemplateUnion

KeyFieldTypeDescriptionRequirednessDefault value
1templateSetTemplateSetdefault
2templatejob_template.JobTemplateModulardefault

Struct: TemplateUnionQueryResult

KeyFieldTypeDescriptionRequirednessDefault value
1templateUnionslist<TemplateUnion>default
2pageInfocommon.PageInfooptional

Struct: TemplateUnionFetchResult

KeyFieldTypeDescriptionRequirednessDefault value
1templateResultmap<string, job_template.TemplateFetchResult>default
2templateSetResultmap<string, TemplateSetFetchResult>default

Struct: TemplateUnionWhereOpts

KeyFieldTypeDescriptionRequirednessDefault value
1whereOptsjob_template.TemplateWhereOptsdefault
2includeTemplatesbooldefaulttrue
3includeTemplateSetsbooldefaulttrue

Filtering options to be passed to queryCombined

Struct: TemplateUnionSelectOpts

KeyFieldTypeDescriptionRequirednessDefault value
1templateSetSelectOptsTemplateSetSelectOptsdefault
2templateSelectOptsjob_template.TemplateSelectOptsdefault

Struct: VersionRef

KeyFieldTypeDescriptionRequirednessDefault value
1idstringdefault
2publicVersioni32default
3isArchivedbooldefault


Services

Service: TemplateSetService

Function: TemplateSetService.query

TemplateSetQueryResult query(TemplateSetSelectOpts selectOpts,
                             job_template.TemplateWhereOpts whereOpts,
                             list<job_template.TemplateOrder> order)
    throws common.SystemException
Query a list of template sets

Function: TemplateSetService.fetch

map<string, TemplateSetFetchResult> fetch(TemplateSetSelectOpts selectOpts,
                                        list<string> templateSetIds)
    throws common.SystemException
Get a template set

Function: TemplateSetService.create

TemplateSet create(string teamId,
                   TemplateSetParams params,
                   list<abac.AbacAttribute> attributes)
    throws common.SystemException

Function: TemplateSetService.update

TemplateSet update(string templateSetId,
                   i32 internalVersion,
                   TemplateSetParams params)
    throws common.SystemException

Function: TemplateSetService.archive

TemplateSet archive(string templateSetId)
    throws common.SystemException

Function: TemplateSetService.unarchive

TemplateSet unarchive(string templateSetId)
    throws common.SystemException

Function: TemplateSetService.publish

TemplateSet publish(string templateSetId)
    throws common.SystemException

Function: TemplateSetService.getPublicVersion

TemplateSet getPublicVersion(string templateSetId,
                             i32 publicVersion)
    throws common.SystemException
Get a published TemplateSet.

If publicVersion is 0, get the currently published version

Function: TemplateSetService.beginReview

i32 beginReview(string templateSetId)
    throws common.SystemException
Enter review state, which means that editing will be locked until the review process ends; also generates a new public version number which is returned. When configured, this will also call a registered webhook.

During review state, all operations which add or update content will fail with an error.

Function: TemplateSetService.endReview

i32 endReview(string templateSetId)
    throws common.SystemException
Exit review state, release editing lock; returns current public version number.

Function: TemplateSetService.publishVersion

TemplateSet publishVersion(string templateSetId,
                           i32 publicVersion)
    throws common.SystemException
Publish a specified version of the template set; must be called AFTER endReview

Function: TemplateSetService.addTemplate

TemplateSet addTemplate(string templateSetId,
                        i32 internalVersion,
                        string templateId,
                        i32 position,
                        bool replace)
    throws common.SystemException

Function: TemplateSetService.addTemplateSet

TemplateSet addTemplateSet(string templateSetId,
                           i32 internalVersion,
                           string addedSetId,
                           i32 position)
    throws common.SystemException

Function: TemplateSetService.moveTemplate

TemplateSet moveTemplate(string templateSetId,
                         i32 internalVersion,
                         string templateId,
                         i32 oldPosition,
                         i32 newPosition)
    throws common.SystemException
Move a template to a different position in the template set

Function: TemplateSetService.removeTemplate

TemplateSet removeTemplate(string templateSetId,
                           i32 internalVersion,
                           string templateId,
                           i32 position)
    throws common.SystemException
Remove a template from the template set

Function: TemplateSetService.setTemplateList

TemplateSet setTemplateList(string templateSetId,
                            i32 internalVersion,
                            list<common.ListActions> movements)
    throws common.SystemException
Set full list of templates on a template set. This replaces the need for consecutive api calls when moving, removing, and adding templates

Function: TemplateSetService.getTags

list<job_template.TemplateTag> getTags(string templateSetId)
    throws common.SystemException
Get all of the tags and comments for a template set

Function: TemplateSetService.updateTags

void updateTags(string templateSetId,
                list<job_template.TemplateTag> added,
                list<string> removedTagIds)
    throws common.SystemException
Update the tags on a template set. additions are the tags and comments to be added to the template. Removals are the ids of the tags to be removed from the template.

Function: TemplateSetService.acquireLock

job_template.JobTemplateLock acquireLock(string templateSetId)
    throws common.SystemException, job_template.JobTemplateLockFailed
Start editing the template set Note that this lock is associated with the specific authToken used, not just the user owning that token. The life of the lock is until releaseLock (which should be called when editing is complete), forcible takeover, or implicitly on logout. Returns the new lock on success. If the lock is already owned by another token, raises JobTemplateLockFailed with previous lock information.

Function: TemplateSetService.forceAcquireLock

job_template.ForceAcquireResponse forceAcquireLock(string templateSetId)
    throws common.SystemException
Start editing the template, forcibly taking over any existing lock. Note that this lock is associated with the specific authToken used, not just the user owning that token. The life of the lock is until releaseLock (which should be called when editing is complete), forcible takeover, or implicitly on logout. Returns the new lock in the response structure. If the lock was owned by another token, also returns details of previous lock. This method is intended to be called after acquireLock fails and an explicit user response to forcibly take the lock. WARNING: this could result in data loss if another user is editing.

Function: TemplateSetService.queryCombined

TemplateUnionQueryResult queryCombined(TemplateUnionSelectOpts selectOpts,
                                       TemplateUnionWhereOpts whereOpts,
                                       list<job_template.TemplateOrder> order)
    throws common.SystemException
Query across both templates and template sets.

Function: TemplateSetService.fetchUpdated

TemplateUnionFetchResult fetchUpdated(TemplateUnionSelectOpts selectOpts,
                                      list<VersionRef> templateArgs,
                                      list<VersionRef> templateSetArgs)
    throws common.SystemException
Only returns back templates and sets where either the version or the archivedAt timestamps don't match To figure out if you have the latest versions of the templates inside the template sets, pass those along in the templateArgs

Function: TemplateSetService.updateAttribute

list<abac.AbacAttribute> updateAttribute(common.UUID templateSetId,
                                         string attributeId,
                                         list<abac.AbacAttributeValue> values,
                                         abac.AbacUploadBehaviour behave)
    throws common.SystemException
Update a single attribute on a template set return value will always be a list with a single attribute determined by which attribute was updated param templateSetId: template set to update param attributeId: the AttributeId of the team level attribute to be updated param values: the new AttributeValues to associated with Attribute attributeId on template set templateSetId param behave: determine the behaviour of the endpoint, merge or clobber. Default: clobber