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

Method organizationMember

coderd/members.go:158–205  ·  view source on GitHub ↗

@Summary Get organization member @ID get-organization-member @Security CoderSessionToken @Tags Members @Param organization path string true "Organization ID" @Param user path string true "User ID, name, or me" @Success 200 {object} codersdk.OrganizationMemberWithUserData @Produce json @Router /api/v

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

156// @Produce json
157// @Router /api/v2/organizations/{organization}/members/{user} [get]
158func (api *API) organizationMember(rw http.ResponseWriter, r *http.Request) {
159 var (
160 ctx = r.Context()
161 organization = httpmw.OrganizationParam(r)
162 member = httpmw.OrganizationMemberParam(r)
163 )
164
165 // This is unfortunate to fetch like this, but we need the user table data.
166 // The listing route uses this data format, so it is just easier to reuse the
167 // list query.
168 rows, err := api.Database.OrganizationMembers(ctx, database.OrganizationMembersParams{
169 OrganizationID: organization.ID,
170 UserID: member.UserID,
171 IncludeSystem: false,
172 GithubUserID: 0,
173 })
174 if httpapi.Is404Error(err) || len(rows) == 0 {
175 httpapi.ResourceNotFound(rw)
176 return
177 }
178 if err != nil {
179 httpapi.InternalServerError(rw, err)
180 return
181 }
182
183 var aiSeatSet map[uuid.UUID]struct{}
184 if api.Entitlements.Enabled(codersdk.FeatureAIGovernanceUserLimit) {
185 //nolint:gocritic // AI seat state is a system-level read gated by entitlement.
186 aiSeatSet, err = getAISeatSetByUserIDs(dbauthz.AsSystemRestricted(ctx), api.Database, []uuid.UUID{member.UserID})
187 if err != nil {
188 httpapi.InternalServerError(rw, err)
189 return
190 }
191 }
192
193 resp, err := convertOrganizationMembersWithUserData(ctx, api.Database, rows, aiSeatSet)
194 if err != nil {
195 httpapi.InternalServerError(rw, err)
196 return
197 }
198
199 if len(resp) != 1 {
200 httpapi.InternalServerError(rw, xerrors.Errorf("unexpected organization members, something went wrong"))
201 return
202 }
203
204 httpapi.Write(ctx, rw, http.StatusOK, resp[0])
205}
206
207// @Deprecated use /organizations/{organization}/paginated-members [get]
208// @Summary List organization members

Callers

nothing calls this directly

Calls 13

OrganizationParamFunction · 0.92
OrganizationMemberParamFunction · 0.92
Is404ErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
InternalServerErrorFunction · 0.92
AsSystemRestrictedFunction · 0.92
WriteFunction · 0.92
getAISeatSetByUserIDsFunction · 0.85
ContextMethod · 0.65
OrganizationMembersMethod · 0.65
EnabledMethod · 0.65

Tested by

no test coverage detected