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

Method TemplatesByOrganization

codersdk/organizations.go:547–563  ·  view source on GitHub ↗

TemplatesByOrganization lists all templates inside of an organization.

(ctx context.Context, organizationID uuid.UUID)

Source from the content-addressed store, hash-verified

545
546// TemplatesByOrganization lists all templates inside of an organization.
547func (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
565type TemplateFilter struct {
566 OrganizationID uuid.UUID `typescript:"-"`

Callers 5

selectTemplateFunction · 0.80
resolveTemplateIDFunction · 0.80
parseTemplateFunction · 0.80
TestTemplateAccessFunction · 0.80

Calls 5

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by 2

TestTemplateAccessFunction · 0.64