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

Method Templates

codersdk/organizations.go:607–624  ·  view source on GitHub ↗

Templates lists all viewable templates

(ctx context.Context, filter TemplateFilter)

Source from the content-addressed store, hash-verified

605
606// Templates lists all viewable templates
607func (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.
627func (c *Client) TemplateByName(ctx context.Context, organizationID uuid.UUID, name string) (Template, error) {

Callers 14

TestTemplatesFunction · 0.80
TestDeleteTemplateFunction · 0.80
searchTemplatesFunction · 0.80
TestToolsFunction · 0.80
toolsdk.goFile · 0.80
templateListMethod · 0.80
taskCreateMethod · 0.80
CreateMethod · 0.80

Calls 5

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

Tested by 7

TestTemplatesFunction · 0.64
TestDeleteTemplateFunction · 0.64
TestToolsFunction · 0.64
TestTemplatesFunction · 0.64