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

Method PostOrganizationMember

codersdk/users.go:711–722  ·  view source on GitHub ↗

PostOrganizationMember adds a user to an organization

(ctx context.Context, organizationID uuid.UUID, user string)

Source from the content-addressed store, hash-verified

709
710// PostOrganizationMember adds a user to an organization
711func (c *Client) PostOrganizationMember(ctx context.Context, organizationID uuid.UUID, user string) (OrganizationMember, error) {
712 res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/organizations/%s/members/%s", organizationID, user), nil)
713 if err != nil {
714 return OrganizationMember{}, err
715 }
716 defer res.Body.Close()
717 if res.StatusCode != http.StatusOK {
718 return OrganizationMember{}, ReadBodyAsError(res)
719 }
720 var member OrganizationMember
721 return member, json.NewDecoder(res.Body).Decode(&member)
722}
723
724// DeleteOrganizationMember removes a user from an organization
725func (c *Client) DeleteOrganizationMember(ctx context.Context, organizationID uuid.UUID, user string) error {

Callers 6

TestAddMemberFunction · 0.80
createAnotherUserRetryFunction · 0.80
addOrganizationMemberMethod · 0.80
setupMultiOrgFunction · 0.80
TestEnterpriseMembersFunction · 0.80
TestUserOIDCFunction · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 3

TestAddMemberFunction · 0.64
TestEnterpriseMembersFunction · 0.64
TestUserOIDCFunction · 0.64