| 507 | } |
| 508 | |
| 509 | func (c *Client) TemplateVersionByOrganizationAndName(ctx context.Context, organizationID uuid.UUID, templateName, versionName string) (TemplateVersion, error) { |
| 510 | res, err := c.Request(ctx, http.MethodGet, |
| 511 | fmt.Sprintf("/api/v2/organizations/%s/templates/%s/versions/%s", organizationID.String(), templateName, versionName), |
| 512 | nil, |
| 513 | ) |
| 514 | if err != nil { |
| 515 | return TemplateVersion{}, xerrors.Errorf("execute request: %w", err) |
| 516 | } |
| 517 | defer res.Body.Close() |
| 518 | |
| 519 | if res.StatusCode != http.StatusOK { |
| 520 | return TemplateVersion{}, ReadBodyAsError(res) |
| 521 | } |
| 522 | |
| 523 | var templateVersion TemplateVersion |
| 524 | return templateVersion, json.NewDecoder(res.Body).Decode(&templateVersion) |
| 525 | } |
| 526 | |
| 527 | // CreateTemplate creates a new template inside an organization. |
| 528 | func (c *Client) CreateTemplate(ctx context.Context, organizationID uuid.UUID, request CreateTemplateRequest) (Template, error) { |