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

Method CreateUserSecret

codersdk/usersecrets.go:47–58  ·  view source on GitHub ↗
(ctx context.Context, user string, req CreateUserSecretRequest)

Source from the content-addressed store, hash-verified

45}
46
47func (c *Client) CreateUserSecret(ctx context.Context, user string, req CreateUserSecretRequest) (UserSecret, error) {
48 res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/users/%s/secrets", user), req)
49 if err != nil {
50 return UserSecret{}, err
51 }
52 defer res.Body.Close()
53 if res.StatusCode != http.StatusCreated {
54 return UserSecret{}, ReadBodyAsError(res)
55 }
56 var secret UserSecret
57 return secret, json.NewDecoder(res.Body).Decode(&secret)
58}
59
60func (c *Client) UserSecrets(ctx context.Context, user string) ([]UserSecret, error) {
61 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/secrets", user), nil)

Callers

nothing calls this directly

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected