MCPcopy Index your code
hub / github.com/coder/coder / PreviousTemplateVersion

Method PreviousTemplateVersion

codersdk/templateversions.go:288–302  ·  view source on GitHub ↗
(ctx context.Context, organization uuid.UUID, templateName, versionName string)

Source from the content-addressed store, hash-verified

286var ErrNoPreviousVersion = xerrors.New("no previous template version")
287
288func (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
304func (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)

Callers 1

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 1