| 286 | var ErrNoPreviousVersion = xerrors.New("no previous template version") |
| 287 | |
| 288 | func (c *Client) PreviousTemplateVersion(ctx context.Context, organization uuid.UUID, templateName, versionName string) (TemplateVersion, error) { |
| 289 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/organizations/%s/templates/%s/versions/%s/previous", organization, templateName, versionName), nil) |
| 290 | if err != nil { |
| 291 | return TemplateVersion{}, err |
| 292 | } |
| 293 | defer res.Body.Close() |
| 294 | if res.StatusCode == http.StatusNoContent { |
| 295 | return TemplateVersion{}, ErrNoPreviousVersion |
| 296 | } |
| 297 | if res.StatusCode != http.StatusOK { |
| 298 | return TemplateVersion{}, ReadBodyAsError(res) |
| 299 | } |
| 300 | var version TemplateVersion |
| 301 | return version, json.NewDecoder(res.Body).Decode(&version) |
| 302 | } |
| 303 | |
| 304 | func (c *Client) UpdateTemplateVersion(ctx context.Context, versionID uuid.UUID, req PatchTemplateVersionRequest) (TemplateVersion, error) { |
| 305 | res, err := c.Request(ctx, http.MethodPatch, fmt.Sprintf("/api/v2/templateversions/%s", versionID), req) |