|
|
|
@ -28,6 +28,14 @@ import (
|
|
|
|
|
"github.com/coder/coder/examples"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// @Summary Get template version by ID
|
|
|
|
|
// @ID get-template-version-by-id
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Success 200 {object} codersdk.TemplateVersion
|
|
|
|
|
// @Router /templateversions/{templateversion} [get]
|
|
|
|
|
func (api *API) templateVersion(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
var (
|
|
|
|
@ -61,6 +69,14 @@ func (api *API) templateVersion(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, convertTemplateVersion(templateVersion, convertProvisionerJob(job), user))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Cancel template version by ID
|
|
|
|
|
// @ID cancel-template-version-by-id
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Success 200 {object} codersdk.Response
|
|
|
|
|
// @Router /templateversions/{templateversion}/cancel [patch]
|
|
|
|
|
func (api *API) patchCancelTemplateVersion(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
var (
|
|
|
|
@ -116,6 +132,14 @@ func (api *API) patchCancelTemplateVersion(rw http.ResponseWriter, r *http.Reque
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get schema by template version
|
|
|
|
|
// @ID get-schema-by-template-version
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Success 200 {array} codersdk.ParameterSchema
|
|
|
|
|
// @Router /templateversions/{templateversion}/schema [get]
|
|
|
|
|
func (api *API) templateVersionSchema(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
var (
|
|
|
|
@ -168,6 +192,14 @@ func (api *API) templateVersionSchema(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, apiSchemas)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get parameters by template version
|
|
|
|
|
// @ID get-parameters-by-template-version
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Success 200 {array} parameter.ComputedValue
|
|
|
|
|
// @Router /templateversions/{templateversion}/parameters [get]
|
|
|
|
|
func (api *API) templateVersionParameters(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
var (
|
|
|
|
@ -213,6 +245,16 @@ func (api *API) templateVersionParameters(rw http.ResponseWriter, r *http.Reques
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, values)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Create template version dry-run
|
|
|
|
|
// @ID create-template-version-dry-run
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Param request body codersdk.CreateTemplateVersionDryRunRequest true "Dry-run request"
|
|
|
|
|
// @Success 201 {object} codersdk.ProvisionerJob
|
|
|
|
|
// @Router /templateversions/{templateversion}/dry-run [post]
|
|
|
|
|
func (api *API) postTemplateVersionDryRun(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
var (
|
|
|
|
@ -308,6 +350,16 @@ func (api *API) postTemplateVersionDryRun(rw http.ResponseWriter, r *http.Reques
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusCreated, convertProvisionerJob(provisionerJob))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get template version dry-run by job ID
|
|
|
|
|
// @ID get-template-version-dry-run-by-job-id
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Param jobid path string true "Job ID" format(uuid)
|
|
|
|
|
// @Success 200 {object} codersdk.ProvisionerJob
|
|
|
|
|
// @Router /templateversions/{templateversion}/dry-run/{jobid} [get]
|
|
|
|
|
func (api *API) templateVersionDryRun(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
job, ok := api.fetchTemplateVersionDryRunJob(rw, r)
|
|
|
|
@ -318,6 +370,15 @@ func (api *API) templateVersionDryRun(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, convertProvisionerJob(job))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get template version dry-run resources by job ID
|
|
|
|
|
// @ID get-template-version-dry-run-resources-by-job-id
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Param jobid path string true "Job ID" format(uuid)
|
|
|
|
|
// @Success 200 {array} codersdk.WorkspaceResource
|
|
|
|
|
// @Router /templateversions/{templateversion}/dry-run/{jobid}/resources [get]
|
|
|
|
|
func (api *API) templateVersionDryRunResources(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
job, ok := api.fetchTemplateVersionDryRunJob(rw, r)
|
|
|
|
|
if !ok {
|
|
|
|
@ -327,6 +388,18 @@ func (api *API) templateVersionDryRunResources(rw http.ResponseWriter, r *http.R
|
|
|
|
|
api.provisionerJobResources(rw, r, job)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get template version dry-run logs by job ID
|
|
|
|
|
// @ID get-template-version-dry-run-logs-by-job-id
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Param jobid path string true "Job ID" format(uuid)
|
|
|
|
|
// @Param before query int false "Before Unix timestamp"
|
|
|
|
|
// @Param after query int false "After Unix timestamp"
|
|
|
|
|
// @Param follow query bool false "Follow log stream"
|
|
|
|
|
// @Success 200 {array} codersdk.ProvisionerJobLog
|
|
|
|
|
// @Router /templateversions/{templateversion}/dry-run/{jobid}/logs [get]
|
|
|
|
|
func (api *API) templateVersionDryRunLogs(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
job, ok := api.fetchTemplateVersionDryRunJob(rw, r)
|
|
|
|
|
if !ok {
|
|
|
|
@ -336,6 +409,14 @@ func (api *API) templateVersionDryRunLogs(rw http.ResponseWriter, r *http.Reques
|
|
|
|
|
api.provisionerJobLogs(rw, r, job)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Cancel template version dry-run by job ID
|
|
|
|
|
// @ID cancel-template-version-dry-run-by-job-id
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Success 200 {object} codersdk.Response
|
|
|
|
|
// @Router /templateversions/{templateversion}/dry-run/{jobid}/cancel [patch]
|
|
|
|
|
func (api *API) patchTemplateVersionDryRunCancel(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
templateVersion := httpmw.TemplateVersionParam(r)
|
|
|
|
@ -454,6 +535,14 @@ func (api *API) fetchTemplateVersionDryRunJob(rw http.ResponseWriter, r *http.Re
|
|
|
|
|
return job, true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary List template versions by template ID
|
|
|
|
|
// @ID list-template-versions-by-template-ID
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param id path string true "Template ID" format(uuid)
|
|
|
|
|
// @Success 200 {array} codersdk.TemplateVersion
|
|
|
|
|
// @Router /templates/{id}/versions [get]
|
|
|
|
|
func (api *API) templateVersionsByTemplate(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
template := httpmw.TemplateParam(r)
|
|
|
|
@ -551,6 +640,15 @@ func (api *API) templateVersionsByTemplate(rw http.ResponseWriter, r *http.Reque
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, apiVersions)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get template version by template ID and name
|
|
|
|
|
// @ID get-template-version-by-template-id-and-name
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param id path string true "Template ID" format(uuid)
|
|
|
|
|
// @Param templateversionname path string true "Template version name"
|
|
|
|
|
// @Success 200 {array} codersdk.TemplateVersion
|
|
|
|
|
// @Router /templates/{id}/versions/{templateversionname} [get]
|
|
|
|
|
func (api *API) templateVersionByName(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
template := httpmw.TemplateParam(r)
|
|
|
|
@ -601,6 +699,15 @@ func (api *API) templateVersionByName(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, convertTemplateVersion(templateVersion, convertProvisionerJob(job), user))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get template version by organization and name
|
|
|
|
|
// @ID get-template-version-by-organization-and-name
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param organization path string true "Organization ID" format(uuid)
|
|
|
|
|
// @Param templateversionname path string true "Template version name"
|
|
|
|
|
// @Success 200 {object} codersdk.TemplateVersion
|
|
|
|
|
// @Router /organizations/{organization}/templateversions/{templateversionname} [get]
|
|
|
|
|
func (api *API) templateVersionByOrganizationAndName(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
organization := httpmw.OrganizationParam(r)
|
|
|
|
@ -643,6 +750,15 @@ func (api *API) templateVersionByOrganizationAndName(rw http.ResponseWriter, r *
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, convertTemplateVersion(templateVersion, convertProvisionerJob(job), user))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get previous template version by organization and name
|
|
|
|
|
// @ID get-previous-template-version-by-organization-and-name
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param organization path string true "Organization ID" format(uuid)
|
|
|
|
|
// @Param templateversionname path string true "Template version name"
|
|
|
|
|
// @Success 200 {object} codersdk.TemplateVersion
|
|
|
|
|
// @Router /organizations/{organization}/templateversions/{templateversionname}/previous [get]
|
|
|
|
|
func (api *API) previousTemplateVersionByOrganizationAndName(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
ctx := r.Context()
|
|
|
|
|
organization := httpmw.OrganizationParam(r)
|
|
|
|
@ -708,6 +824,16 @@ func (api *API) previousTemplateVersionByOrganizationAndName(rw http.ResponseWri
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusOK, convertTemplateVersion(previousTemplateVersion, convertProvisionerJob(job), user))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Update active template version by template ID
|
|
|
|
|
// @ID update-active-template-version-by-template-ID
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param request body codersdk.UpdateActiveTemplateVersion true "Modified template version"
|
|
|
|
|
// @Param id path string true "Template ID" format(uuid)
|
|
|
|
|
// @Success 200 {object} codersdk.Response
|
|
|
|
|
// @Router /templates/{id}/versions [patch]
|
|
|
|
|
func (api *API) patchActiveTemplateVersion(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
var (
|
|
|
|
|
ctx = r.Context()
|
|
|
|
@ -782,7 +908,18 @@ func (api *API) patchActiveTemplateVersion(rw http.ResponseWriter, r *http.Reque
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Creates a new version of a template. An import job is queued to parse the storage method provided.
|
|
|
|
|
// @Summary Create template version by organization
|
|
|
|
|
// @ID create-template-version-by-organization
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param organization path string true "Organization ID" format(uuid)
|
|
|
|
|
// @Param request body codersdk.CreateTemplateVersionDryRunRequest true "Create template version request"
|
|
|
|
|
// @Success 201 {object} codersdk.TemplateVersion
|
|
|
|
|
// @Router /organizations/{organization}/templateversions [post]
|
|
|
|
|
//
|
|
|
|
|
// postTemplateVersionsByOrganization creates a new version of a template. An import job is queued to parse the storage method provided.
|
|
|
|
|
func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
|
var (
|
|
|
|
|
ctx = r.Context()
|
|
|
|
@ -1067,6 +1204,15 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
|
|
|
|
|
httpapi.Write(ctx, rw, http.StatusCreated, convertTemplateVersion(templateVersion, convertProvisionerJob(provisionerJob), user))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get resources by template version
|
|
|
|
|
// @ID get-resources-by-template-version
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Success 200 {array} codersdk.WorkspaceResource
|
|
|
|
|
// @Router /templateversions/{templateversion}/resources [get]
|
|
|
|
|
//
|
|
|
|
|
// templateVersionResources returns the workspace agent resources associated
|
|
|
|
|
// with a template version. A template can specify more than one resource to be
|
|
|
|
|
// provisioned, each resource can have an agent that dials back to coderd. The
|
|
|
|
@ -1095,6 +1241,18 @@ func (api *API) templateVersionResources(rw http.ResponseWriter, r *http.Request
|
|
|
|
|
api.provisionerJobResources(rw, r, job)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary Get logs by template version
|
|
|
|
|
// @ID get-logs-by-template-version
|
|
|
|
|
// @Security CoderSessionToken
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Tags Templates
|
|
|
|
|
// @Param templateversion path string true "Template version ID" format(uuid)
|
|
|
|
|
// @Param before query int false "Before Unix timestamp"
|
|
|
|
|
// @Param after query int false "After Unix timestamp"
|
|
|
|
|
// @Param follow query bool false "Follow log stream"
|
|
|
|
|
// @Success 200 {array} codersdk.ProvisionerJobLog
|
|
|
|
|
// @Router /templateversions/{templateversion}/logs [get]
|
|
|
|
|
//
|
|
|
|
|
// templateVersionLogs returns the logs returned by the provisioner for the given
|
|
|
|
|
// template version. These logs are only associated with the template version,
|
|
|
|
|
// and not any build logs for a workspace.
|
|
|
|
|