(ctx context.Context, flags *RootFlags)
| 319 | } |
| 320 | |
| 321 | func (c *AdminUsersDeleteCmd) Run(ctx context.Context, flags *RootFlags) error { |
| 322 | userEmail := strings.TrimSpace(c.UserEmail) |
| 323 | if userEmail == "" { |
| 324 | return usage("user email required") |
| 325 | } |
| 326 | |
| 327 | if confirmErr := dryRunAndConfirmDestructive(ctx, flags, "admin.users.delete", map[string]any{ |
| 328 | "email": userEmail, |
| 329 | }, fmt.Sprintf("delete user %s", userEmail)); confirmErr != nil { |
| 330 | return confirmErr |
| 331 | } |
| 332 | |
| 333 | account, err := requireAdminAccount(flags) |
| 334 | if err != nil { |
| 335 | return err |
| 336 | } |
| 337 | |
| 338 | svc, err := adminDirectoryService(ctx, account) |
| 339 | if err != nil { |
| 340 | return wrapAdminDirectoryError(err, account) |
| 341 | } |
| 342 | |
| 343 | if err := svc.Users.Delete(userEmail).Context(ctx).Do(); err != nil { |
| 344 | return wrapAdminDirectoryError(err, account) |
| 345 | } |
| 346 | |
| 347 | if outfmt.IsJSON(ctx) { |
| 348 | return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{ |
| 349 | "email": userEmail, |
| 350 | "deleted": true, |
| 351 | }) |
| 352 | } |
| 353 | |
| 354 | u := ui.FromContext(ctx) |
| 355 | u.Out().Linef("Deleted user: %s", userEmail) |
| 356 | return nil |
| 357 | } |
| 358 | |
| 359 | type AdminUsersSuspendCmd struct { |
| 360 | UserEmail string `arg:"" name:"userEmail" help:"User email to suspend"` |
nothing calls this directly
no test coverage detected