diff --git a/cmd/zrok/adminGenerate.go b/cmd/zrok/adminGenerate.go index 9576646d..d31c9440 100644 --- a/cmd/zrok/adminGenerate.go +++ b/cmd/zrok/adminGenerate.go @@ -27,9 +27,7 @@ func newAdminGenerateCommand() *adminGenerateCommand { } command := &adminGenerateCommand{cmd: cmd} cmd.Run = command.run - cmd.Flags().IntVarP(&command.amount, "count", "n", 5, "Number of tokens to generate") - return command } diff --git a/cmd/zrok/adminGrants.go b/cmd/zrok/adminGrants.go new file mode 100644 index 00000000..eb9af899 --- /dev/null +++ b/cmd/zrok/adminGrants.go @@ -0,0 +1,51 @@ +package main + +import ( + "fmt" + "github.com/openziti/zrok/environment" + "github.com/openziti/zrok/rest_client_zrok/admin" + "github.com/spf13/cobra" +) + +func init() { + adminCmd.AddCommand(newAdminGrantsCommand().cmd) +} + +type adminGrantsCommand struct { + cmd *cobra.Command + email string +} + +func newAdminGrantsCommand() *adminGrantsCommand { + cmd := &cobra.Command{ + Use: "grants ", + Short: "Synchronize ziti objects with account grants", + Args: cobra.ExactArgs(1), + } + command := &adminGrantsCommand{cmd: cmd} + cmd.Run = command.run + cmd.Flags().StringVarP(&command.email, "email", "e", "", "email address") + return command +} + +func (command *adminGrantsCommand) run(_ *cobra.Command, args []string) { + env, err := environment.LoadRoot() + if err != nil { + panic(err) + } + + zrok, err := env.Client() + if err != nil { + panic(err) + } + + req := admin.NewGrantsParams() + req.Body.Email = args[0] + + _, err = zrok.Admin.Grants(req, mustGetAdminAuth()) + if err != nil { + panic(err) + } + + fmt.Println("success.") +}