TemplateVersionPresets returns the presets associated with a template version.
(ctx context.Context, templateVersionID uuid.UUID)
| 27 | |
| 28 | // TemplateVersionPresets returns the presets associated with a template version. |
| 29 | func (c *Client) TemplateVersionPresets(ctx context.Context, templateVersionID uuid.UUID) ([]Preset, error) { |
| 30 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/presets", templateVersionID), nil) |
| 31 | if err != nil { |
| 32 | return nil, xerrors.Errorf("do request: %w", err) |
| 33 | } |
| 34 | defer res.Body.Close() |
| 35 | if res.StatusCode != http.StatusOK { |
| 36 | return nil, ReadBodyAsError(res) |
| 37 | } |
| 38 | var presets []Preset |
| 39 | return presets, json.NewDecoder(res.Body).Decode(&presets) |
| 40 | } |