| 293 | } |
| 294 | |
| 295 | func patchAdminUserState(ctx context.Context, svc *admin.Service, userKey string, patch *admin.User) (*admin.User, error) { |
| 296 | const attempts = 6 |
| 297 | var lastErr error |
| 298 | for attempt := range attempts { |
| 299 | updated, err := svc.Users.Patch(userKey, patch).Context(ctx).Do() |
| 300 | if err == nil { |
| 301 | return updated, nil |
| 302 | } |
| 303 | lastErr = err |
| 304 | var googleErr *ggoogleapi.Error |
| 305 | if !errors.As(err, &googleErr) || googleErr.Code != 404 || attempt == attempts-1 { |
| 306 | return nil, err |
| 307 | } |
| 308 | select { |
| 309 | case <-ctx.Done(): |
| 310 | return nil, ctx.Err() |
| 311 | case <-time.After(500 * time.Millisecond): |
| 312 | } |
| 313 | } |
| 314 | return nil, lastErr |
| 315 | } |
| 316 | |
| 317 | type AdminUsersDeleteCmd struct { |
| 318 | UserEmail string `arg:"" name:"userEmail" help:"User email to delete"` |