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

Method UserSecretByName

codersdk/usersecrets.go:73–84  ·  view source on GitHub ↗
(ctx context.Context, user string, name string)

Source from the content-addressed store, hash-verified

71}
72
73func (c *Client) UserSecretByName(ctx context.Context, user string, name string) (UserSecret, error) {
74 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/secrets/%s", user, name), nil)
75 if err != nil {
76 return UserSecret{}, err
77 }
78 defer res.Body.Close()
79 if res.StatusCode != http.StatusOK {
80 return UserSecret{}, ReadBodyAsError(res)
81 }
82 var secret UserSecret
83 return secret, json.NewDecoder(res.Body).Decode(&secret)
84}
85
86func (c *Client) UpdateUserSecret(ctx context.Context, user string, name string, req UpdateUserSecretRequest) (UserSecret, error) {
87 res, err := c.Request(ctx, http.MethodPatch, fmt.Sprintf("/api/v2/users/%s/secrets/%s", user, name), req)

Callers 7

TestUserSecretAuditFunction · 0.80
TestGetUserSecretFunction · 0.80
TestDeleteUserSecretFunction · 0.80
TestSecretCreateFunction · 0.80
TestSecretUpdateFunction · 0.80
TestSecretDeleteFunction · 0.80
secretListMethod · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 6

TestUserSecretAuditFunction · 0.64
TestGetUserSecretFunction · 0.64
TestDeleteUserSecretFunction · 0.64
TestSecretCreateFunction · 0.64
TestSecretUpdateFunction · 0.64
TestSecretDeleteFunction · 0.64