Templates lists all viewable templates
(ctx context.Context, filter TemplateFilter)
| 605 | |
| 606 | // Templates lists all viewable templates |
| 607 | func (c *Client) Templates(ctx context.Context, filter TemplateFilter) ([]Template, error) { |
| 608 | res, err := c.Request(ctx, http.MethodGet, |
| 609 | "/api/v2/templates", |
| 610 | nil, |
| 611 | filter.asRequestOption(), |
| 612 | ) |
| 613 | if err != nil { |
| 614 | return nil, xerrors.Errorf("execute request: %w", err) |
| 615 | } |
| 616 | defer res.Body.Close() |
| 617 | |
| 618 | if res.StatusCode != http.StatusOK { |
| 619 | return nil, ReadBodyAsError(res) |
| 620 | } |
| 621 | |
| 622 | var templates []Template |
| 623 | return templates, json.NewDecoder(res.Body).Decode(&templates) |
| 624 | } |
| 625 | |
| 626 | // TemplateByName finds a template inside the organization provided with a case-insensitive name. |
| 627 | func (c *Client) TemplateByName(ctx context.Context, organizationID uuid.UUID, name string) (Template, error) { |