TemplatesByOrganization lists all templates inside of an organization.
(ctx context.Context, organizationID uuid.UUID)
| 545 | |
| 546 | // TemplatesByOrganization lists all templates inside of an organization. |
| 547 | func (c *Client) TemplatesByOrganization(ctx context.Context, organizationID uuid.UUID) ([]Template, error) { |
| 548 | res, err := c.Request(ctx, http.MethodGet, |
| 549 | fmt.Sprintf("/api/v2/organizations/%s/templates", organizationID.String()), |
| 550 | nil, |
| 551 | ) |
| 552 | if err != nil { |
| 553 | return nil, xerrors.Errorf("execute request: %w", err) |
| 554 | } |
| 555 | defer res.Body.Close() |
| 556 | |
| 557 | if res.StatusCode != http.StatusOK { |
| 558 | return nil, ReadBodyAsError(res) |
| 559 | } |
| 560 | |
| 561 | var templates []Template |
| 562 | return templates, json.NewDecoder(res.Body).Decode(&templates) |
| 563 | } |
| 564 | |
| 565 | type TemplateFilter struct { |
| 566 | OrganizationID uuid.UUID `typescript:"-"` |