feat(coder): Add PATCH /templateversions/:templateversion endpoint (#6698)

This commit is contained in:
Bruno Quaresma
2023-03-23 13:26:50 -03:00
committed by GitHub
parent ed9a3b9251
commit 8857971552
16 changed files with 391 additions and 19 deletions

View File

@ -76,6 +76,10 @@ type TemplateVersionVariable struct {
Sensitive bool `json:"sensitive"`
}
type PatchTemplateVersionRequest struct {
Name string `json:"name"`
}
// TemplateVersion returns a template version by ID.
func (c *Client) TemplateVersion(ctx context.Context, id uuid.UUID) (TemplateVersion, error) {
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s", id), nil)
@ -291,3 +295,16 @@ func (c *Client) PreviousTemplateVersion(ctx context.Context, organization uuid.
var version TemplateVersion
return version, json.NewDecoder(res.Body).Decode(&version)
}
func (c *Client) UpdateTemplateVersion(ctx context.Context, versionID uuid.UUID, req PatchTemplateVersionRequest) (TemplateVersion, error) {
res, err := c.Request(ctx, http.MethodPatch, fmt.Sprintf("/api/v2/templateversions/%s", versionID), req)
if err != nil {
return TemplateVersion{}, err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return TemplateVersion{}, ReadBodyAsError(res)
}
var version TemplateVersion
return version, json.NewDecoder(res.Body).Decode(&version)
}