MCPcopy
hub / github.com/supabase/auth / ParseGetAdminUsersResponse

Function ParseGetAdminUsersResponse

client/admin/client.go:2364–2405  ·  view source on GitHub ↗

ParseGetAdminUsersResponse parses an HTTP response from a GetAdminUsersWithResponse call

(rsp *http.Response)

Source from the content-addressed store, hash-verified

2362
2363// ParseGetAdminUsersResponse parses an HTTP response from a GetAdminUsersWithResponse call
2364func ParseGetAdminUsersResponse(rsp *http.Response) (*GetAdminUsersResponse, error) {
2365 bodyBytes, err := io.ReadAll(rsp.Body)
2366 defer func() { _ = rsp.Body.Close() }()
2367 if err != nil {
2368 return nil, err
2369 }
2370
2371 response := &GetAdminUsersResponse{
2372 Body: bodyBytes,
2373 HTTPResponse: rsp,
2374 }
2375
2376 switch {
2377 case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
2378 var dest struct {
2379 // Deprecated:
2380 Aud *string `json:"aud,omitempty"`
2381 Users *[]UserSchema `json:"users,omitempty"`
2382 }
2383 if err := json.Unmarshal(bodyBytes, &dest); err != nil {
2384 return nil, err
2385 }
2386 response.JSON200 = &dest
2387
2388 case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
2389 var dest UnauthorizedResponse
2390 if err := json.Unmarshal(bodyBytes, &dest); err != nil {
2391 return nil, err
2392 }
2393 response.JSON401 = &dest
2394
2395 case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
2396 var dest ForbiddenResponse
2397 if err := json.Unmarshal(bodyBytes, &dest); err != nil {
2398 return nil, err
2399 }
2400 response.JSON403 = &dest
2401
2402 }
2403
2404 return response, nil
2405}
2406
2407// ParseDeleteAdminUsersUserIdResponse parses an HTTP response from a DeleteAdminUsersUserIdWithResponse call
2408func ParseDeleteAdminUsersUserIdResponse(rsp *http.Response) (*DeleteAdminUsersUserIdResponse, error) {

Callers 1

Calls 4

ContainsMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…