snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
This commit is contained in:
80
cmd/identities/list.go
Normal file
80
cmd/identities/list.go
Normal file
@@ -0,0 +1,80 @@
|
||||
// Copyright © 2023 Ory Corp
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package identities
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/ory/x/flagx"
|
||||
|
||||
"github.com/ory/x/pagination/keysetclient"
|
||||
|
||||
"github.com/ory/kratos/cmd/cliclient"
|
||||
"github.com/ory/x/cmdx"
|
||||
)
|
||||
|
||||
func NewListCmd() *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Short: "List resources",
|
||||
}
|
||||
c.AddCommand(NewListIdentitiesCmd())
|
||||
cliclient.RegisterClientFlags(c.PersistentFlags())
|
||||
cmdx.RegisterFormatFlags(c.PersistentFlags())
|
||||
return c
|
||||
}
|
||||
|
||||
func NewListIdentitiesCmd() *cobra.Command {
|
||||
c := &cobra.Command{
|
||||
Use: "identities",
|
||||
Short: "List identities",
|
||||
Long: `Return a list of identities.
|
||||
|
||||
The consistency defaults to ` + "`eventual`" + ` and can be set to ` + "`strong`" + ` or ` + "`eventual`" + `.
|
||||
Eventual consistency means that the list operation will return faster and might not include recently created or updated identities. Replication lag is about 5 seconds.`,
|
||||
Example: "{{ .CommandPath }} --page-size 100 --consistency eventual",
|
||||
Args: func(cmd *cobra.Command, args []string) error {
|
||||
// zero or exactly two args
|
||||
if len(args) != 0 && len(args) != 2 {
|
||||
return fmt.Errorf("expected zero or two args, got %d: %+v", len(args), args)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
c, err := cliclient.NewClient(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
consistency := flagx.MustGetString(cmd, "consistency")
|
||||
req := c.IdentityAPI.ListIdentities(cmd.Context()).Consistency(consistency)
|
||||
page, perPage, err := cmdx.ParseTokenPaginationArgs(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req = req.PageToken(page)
|
||||
req = req.PageSize(int64(perPage))
|
||||
|
||||
identities, res, err := req.Execute()
|
||||
if err != nil {
|
||||
return cmdx.PrintOpenAPIError(cmd, err)
|
||||
}
|
||||
|
||||
pages := keysetclient.ParseHeader(res)
|
||||
cmdx.PrintTable(cmd, &outputIdentityCollection{
|
||||
Identities: identities,
|
||||
NextPageToken: pages.NextToken,
|
||||
includePageToken: true,
|
||||
})
|
||||
return nil
|
||||
},
|
||||
}
|
||||
c.Flags().String("consistency", "eventual", "The read consistency to use. Can be either \"strong\" or \"eventual\". Defaults to \"eventual\".")
|
||||
cmdx.RegisterTokenPaginationFlags(c)
|
||||
return c
|
||||
}
|
||||
Reference in New Issue
Block a user