GetGroupByName resolves a group by its resource name "groups/{identifier}". The identifier can be an email (contains "@") or an ID. Includes a fallback for legacy SCIM sync where the email was stored as the ID.
(ctx context.Context, workspace, name string)
| 56 | // The identifier can be an email (contains "@") or an ID. |
| 57 | // Includes a fallback for legacy SCIM sync where the email was stored as the ID. |
| 58 | func (s *Store) GetGroupByName(ctx context.Context, workspace, name string) (*GroupMessage, error) { |
| 59 | identifier := strings.TrimPrefix(name, "groups/") |
| 60 | find := &FindGroupMessage{Workspace: workspace} |
| 61 | if strings.Contains(identifier, "@") { |
| 62 | find.Email = &identifier |
| 63 | } else { |
| 64 | find.ID = &identifier |
| 65 | } |
| 66 | group, err := s.GetGroup(ctx, find) |
| 67 | if err != nil { |
| 68 | return nil, err |
| 69 | } |
| 70 | if group == nil && find.ID == nil { |
| 71 | // Fallback: legacy SCIM sync may store email as ID. |
| 72 | return s.GetGroup(ctx, &FindGroupMessage{Workspace: workspace, ID: &identifier}) |
| 73 | } |
| 74 | return group, nil |
| 75 | } |
| 76 | |
| 77 | // GetGroup gets a group. |
| 78 | func (s *Store) GetGroup(ctx context.Context, find *FindGroupMessage) (*GroupMessage, error) { |
no test coverage detected