Package com.xebialabs.xlrelease.api.v1

## Interface TemplateApi

- All Superinterfaces:
    `ApiService`

      @Path("/api/v1/templates")
      @Consumes("application/json")
      @Produces("application/json")
      public interface TemplateApi
      extends ApiService

  Operations on templates.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static java.lang.String` | `SERVICE_NAME` |

    - ### Fields inherited from interface com.xebialabs.xlrelease.api.ApiService

      `DEFAULT_RESULTS_PER_PAGE, DEFAULT_RESULTS_PER_PAGE_STRING, DEPTH, ORDER_BY, PAGE, PAGE_IS_OFFSET, RESULTS_PER_PAGE, ROLE_IDS_DATA`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Release` | `copyTemplate​(java.lang.String templateId, CopyTemplate copyTemplate)` | Makes a copy of the template on the current folder
    `default Release` | `copyTemplate​(java.lang.String templateId, java.lang.String title, java.lang.String description)` | Makes a copy of the template on the current folder
    `Release` | `create​(java.lang.String templateId, CreateRelease createRelease)` | Creates a release from a template.
    `Release` | `createTemplate​(Release template, java.lang.String folderId)` | Creates a template inside a folder.
    `Variable` | `createVariable​(java.lang.String templateId, Variable variable)` | Create a new variable.
    `void` | `deleteTemplate​(java.lang.String templateId)` | Deletes a template.
    `void` | `deleteVariable​(java.lang.String variableId)` | Delete variable from template.
    `javax.ws.rs.core.Response` | `exportTemplateToZip​(java.lang.String templateId)` | Exports template as a zip download, in xlr format
    `java.util.List<java.lang.String>` | `getPermissions()` | Returns possible permissions.
    `java.util.List<TeamView>` | `getTeams​(java.lang.String templateId)` | Returns effective teams of the template.
    `Release` | `getTemplate​(java.lang.String templateId)` | Returns the template for the given identifier.
    `java.util.List<Release>` | `getTemplates​(java.lang.String filter)` | Deprecated. Please use `getTemplates(String, List, Long, Long, Integer)`
    `java.util.List<Release>` | `getTemplates​(java.lang.String title, java.util.List<java.lang.String> tags, java.lang.Long page, java.lang.Long resultsPerPage, java.lang.Integer depth)` | Returns the list of templates that are visible to the current user.
    `Variable` | `getVariable​(java.lang.String variableId)` | Returns the variable for the given identifier.
    `java.util.Collection<java.lang.Object>` | `getVariablePossibleValues​(java.lang.String variableId)` | Returns possible values for the variable with the given identifier.
    `java.util.List<Variable>` | `getVariables​(java.lang.String templateId)` | Get variables.
    `java.util.List<ImportResult>` | `importTemplate​(java.lang.String json, java.lang.String folderId)` | Imports a template, serialized in JSON format.
    `java.util.List<ImportResult>` | `importTemplate​(java.lang.String json, java.lang.String folderId, java.lang.String version)` | Imports a template, serialized in JSON format.
    `java.util.List<ImportResult>` | `importTemplateAsXlr​(javax.servlet.http.HttpServletRequest request, java.lang.String folderId)` | Imports a template, serialized in XLR format, or a Releasefile (Releasefile.groovy) inside a .zip file.
    `java.lang.Boolean` | `isVariableUsed​(java.lang.String variableId)` | Returns true if variable with the given identifier is used in the template.
    `void` | `replaceVariable​(java.lang.String variableId, VariableOrValue variableOrValue)` | Replace variable occurrences with the given replacement.
    `default java.lang.String` | `serviceName()` |
    `java.util.List<TeamView>` | `setTeams​(java.lang.String templateId, java.util.List<TeamView> teamDtos)` | Sets teams of the template.
    `Release` | `start​(java.lang.String templateId, StartRelease startRelease)` | Starts a release from a template.
    `default Release` | `updateTemplate​(Release template)` | Updates the properties of a template.
    `Release` | `updateTemplate​(java.lang.String templateId, Release template)` | Updates the properties of a template.
    `default Variable` | `updateVariable​(Variable variable)` | Updates the properties of a variable.
    `Variable` | `updateVariable​(java.lang.String variableId, Variable variable)` |
    `java.util.List<Variable>` | `updateVariables​(java.lang.String releaseId, java.util.List<Variable> variables)` | Update the variable list.

- - ### Field Detail

    - #### SERVICE_NAME

          static final java.lang.String SERVICE_NAME

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### serviceName

          default java.lang.String serviceName()

      Specified by:
        `serviceName` in interface `ApiService`

    - #### getTemplates

          @GET
          java.util.List<Release> getTemplates​(@QueryParam("title")
                                               java.lang.String title,
                                               @QueryParam("tag")
                                               java.util.List<java.lang.String> tags,
                                               @DefaultValue("0") @QueryParam("page")
                                               java.lang.Long page,
                                               @DefaultValue("100") @QueryParam("resultsPerPage")
                                               java.lang.Long resultsPerPage,
                                               @DefaultValue("1") @QueryParam("depth")
                                               java.lang.Integer depth)

      Returns the list of templates that are visible to the current user.
      Parameters:
        `title` - an optional search filter containing the title of the template.
        `tags` - an optional search filter containing list of template tags.
        `page` - the page of results to return. Default value is 0.
        `resultsPerPage` - the number of results per page. Default value is 100. Maximum value is 100.
        `depth` - the depth to search for. Default value is 1.
      Returns:
        a list of release templates.

    - #### getTemplates

          @Deprecated
          java.util.List<Release> getTemplates​(java.lang.String filter)

      Deprecated.
      Please use `getTemplates(String, List, Long, Long, Integer)`
      Returns the list of the first 100 templates that are visible to the current user with depth 1.
      Parameters:
        `filter` - An optional search filter containing the title of the template

    - #### updateTemplate

          @PUT
          @Path("/{templateId:.*Release[^/]*}")
          Release updateTemplate​(@PathParam("templateId")
                                 java.lang.String templateId,
                                 Release template)

      Updates the properties of a template.
      Parameters:
        `templateId` - the template identifier.
        `template` - new contents of the template.
      Returns:
        the updated release template.

    - #### updateTemplate

          default Release updateTemplate​(Release template)

      Updates the properties of a template.
      Parameters:
        `template` - new contents of the template.
      Returns:
        the updated release template.

    - #### createTemplate

          @POST
          Release createTemplate​(Release template,
                                 @QueryParam("folderId")
                                 java.lang.String folderId)

      Creates a template inside a folder.

      All nested configuration items (e.g. phases, tasks, teams) will be removed from the provided template, you can use corresponding phaseApi or taskApi for those.

      Parameters:
        `template` - the contents of the release template.
        `folderId` - an optional parameter to create a template inside a folder
      Returns:
        the created template.

    - #### importTemplate

          @POST
          @Path("/import")
          @Consumes("application/json")
          java.util.List<ImportResult> importTemplate​(java.lang.String json,
                                                      @QueryParam("folderId")
                                                      java.lang.String folderId,
                                                      @QueryParam("version")
                                                      java.lang.String version)

      Imports a template, serialized in JSON format.
      Parameters:
        `json` - JSON representation of the template.
        `folderId` - the target folder.
        `version` - the version of the template. (optional)
      Returns:
        the newly created release template

    - #### importTemplate

          java.util.List<ImportResult> importTemplate​(java.lang.String json,
                                                      java.lang.String folderId)

      Imports a template, serialized in JSON format.
      Parameters:
        `json` - JSON representation of the template.
        `folderId` - the target folder.
      Returns:
        the newly created release template

    - #### importTemplateAsXlr

          @POST
          @Path("/import")
          @Consumes("multipart/form-data")
          java.util.List<ImportResult> importTemplateAsXlr​(@Context
                                                           javax.servlet.http.HttpServletRequest request,
                                                           @QueryParam("folderId")
                                                           java.lang.String folderId)
                                                    throws java.io.IOException,
                                                           org.apache.commons.fileupload.FileUploadException

      Imports a template, serialized in XLR format, or a Releasefile (Releasefile.groovy) inside a .zip file.
      Parameters:
        `request` - the HttpServletRequest
      Returns:
        the newly created release template
      Throws:
        `java.io.IOException`
        `org.apache.commons.fileupload.FileUploadException`

    - #### getTemplate

          @GET
          @Path("/{templateId:.*Release[^/]*}")
          Release getTemplate​(@PathParam("templateId")
                              java.lang.String templateId)

      Returns the template for the given identifier.
      Parameters:
        `templateId` - the template identifier.
      Returns:
        the release template.

    - #### deleteTemplate

          @DELETE
          @Path("/{templateId:.*Release[^/]*}")
          void deleteTemplate​(@PathParam("templateId")
                              java.lang.String templateId)

      Deletes a template.
      Parameters:
        `templateId` - the template identifier

    - #### create

          @POST
          @Path("/{templateId:.*Release[^/]*}/create")
          Release create​(@PathParam("templateId")
                         java.lang.String templateId,
                         CreateRelease createRelease)

      Creates a release from a template.
      Parameters:
        `templateId` - the template identifier of the template the release is based on.
        `createRelease` - the parameters for the new release.
      Returns:
        the newly created release.

    - #### start

          @POST
          @Path("/{templateId:.*Release[^/]*}/start")
          Release start​(@PathParam("templateId")
                        java.lang.String templateId,
                        StartRelease startRelease)

      Starts a release from a template.
      Parameters:
        `templateId` - the template identifier of the template the release is based on.
        `startRelease` - the parameters for the new release.
      Returns:
        the newly created and started release.

    - #### getVariables

          @GET
          @Path("/{templateId:.*Release[^/]*}/variables")
          java.util.List<Variable> getVariables​(@PathParam("templateId")
                                                java.lang.String templateId)

      Get variables.
      Parameters:
        `templateId` - the identifier of the release or template.
      Returns:
        a list of variables.

    - #### getVariable

          @GET
          @Path("/{variableId:.*/Variable[^/]*}")
          Variable getVariable​(@PathParam("variableId")
                               java.lang.String variableId)

      Returns the variable for the given identifier.
      Parameters:
        `variableId` - the identifier of the variable.
      Returns:
        the variable.

    - #### getVariablePossibleValues

          @GET
          @Path("/{variableId:.*/Variable[^/]*}/possibleValues")
          java.util.Collection<java.lang.Object> getVariablePossibleValues​(@PathParam("variableId")
                                                                           java.lang.String variableId)

      Returns possible values for the variable with the given identifier.
      Parameters:
        `variableId` - the variable identifier.
      Returns:
        possible values for the variable.

    - #### isVariableUsed

          @GET
          @Path("/{variableId:.*/Variable[^/]*}/used")
          java.lang.Boolean isVariableUsed​(@PathParam("variableId")
                                           java.lang.String variableId)

      Returns true if variable with the given identifier is used in the template.
      Parameters:
        `variableId` - the variable ID.
      Returns:
        true if variable with the given identifier is used in the template.

    - #### replaceVariable

          @POST
          @Path("/{variableId:.*/Variable[^/]*}/replace")
          void replaceVariable​(@PathParam("variableId")
                               java.lang.String variableId,
                               VariableOrValue variableOrValue)

      Replace variable occurrences with the given replacement.
      Parameters:
        `variableId` - the variable ID.
        `variableOrValue` - an object with a variable or value replacing the initial variable.

    - #### deleteVariable

          @DELETE
          @Path("/{variableId:.*/Variable[^/]*}")
          void deleteVariable​(@PathParam("variableId")
                              java.lang.String variableId)

      Delete variable from template.
      Parameters:
        `variableId` - the variable ID.

    - #### createVariable

          @POST
          @Path("/{templateId:.*Release[^/]*}/variables")
          Variable createVariable​(@PathParam("templateId")
                                  java.lang.String templateId,
                                  Variable variable)

      Create a new variable.
      Parameters:
        `templateId` - the identifier of a template.
        `variable` - the `Variable` object describing the new variable.
      Returns:
        created `Variable` object.

    - #### updateVariables

          @PUT
          @Path("/{releaseId:.*Release[^/]*}/variables")
          java.util.List<Variable> updateVariables​(@PathParam("releaseId")
                                                   java.lang.String releaseId,
                                                   java.util.List<Variable> variables)

      Update the variable list.
      Parameters:
        `releaseId` - the identifier of the release.
        `variables` - the variable list to update.
      Returns:
        updated variables.

    - #### updateVariable

          @PUT
          @Path("/{variableId:.*/Variable[^/]*}")
          Variable updateVariable​(@PathParam("variableId")
                                  java.lang.String variableId,
                                  Variable variable)

    - #### updateVariable

          default Variable updateVariable​(Variable variable)

      Updates the properties of a variable.
      Parameters:
        `variable` - new contents of the variable.
      Returns:
        the updated variable.

    - #### getPermissions

          @GET
          @Path("/permissions")
          java.util.List<java.lang.String> getPermissions()

      Returns possible permissions.
      Returns:
        list of permissions for templates and releases

    - #### getTeams

          @GET
          @Path("/{templateId:.*Release[^/]*}/teams")
          java.util.List<TeamView> getTeams​(@PathParam("templateId")
                                            java.lang.String templateId)

      Returns effective teams of the template.
      Parameters:
        `templateId` - the identifier of the template
      Returns:
        a list of effective teams

    - #### setTeams

          @POST
          @Path("/{templateId:.*Release[^/]*}/teams")
          java.util.List<TeamView> setTeams​(@PathParam("templateId")
                                            java.lang.String templateId,
                                            java.util.List<TeamView> teamDtos)

      Sets teams of the template.
      Parameters:
        `templateId` - the identifier of the template
      Returns:
        a list of updated teams

    - #### exportTemplateToZip

          @GET
          @Path("zip/{templateId:.*Release[^/]*}")
          @Produces("application/octet-stream")
          javax.ws.rs.core.Response exportTemplateToZip​(@PathParam("templateId")
                                                        java.lang.String templateId)

      Exports template as a zip download, in xlr format
      Parameters:
        `templateId` - the identifier of the template
      Returns:
        zip archive of template

    - #### copyTemplate

          @POST
          @Path("/{templateId:.*Release[^/]*}/copy")
          Release copyTemplate​(@PathParam("templateId")
                               java.lang.String templateId,
                               CopyTemplate copyTemplate)

      Makes a copy of the template on the current folder
      Parameters:
        `templateId` - : the full templateID: Applications/FolderXXXX/ReleaseYYYY
        `copyTemplate` - : new properties of the template
      Returns:
        the new template
      Since:
        10.0

    - #### copyTemplate

          default Release copyTemplate​(java.lang.String templateId,
                                       java.lang.String title,
                                       java.lang.String description)

      Makes a copy of the template on the current folder
      Parameters:
        `templateId` - : the full templateID: Applications/FolderXXXX/ReleaseYYYY
        `title` - : the new template title
        `description` - : the new template description
      Returns:
        the new template
      Since:
        10.0