mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
feat(coder): Add PATCH /templateversions/:templateversion endpoint (#6698)
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user