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
91 lines
1.8 KiB
Go
91 lines
1.8 KiB
Go
// Copyright © 2023 Ory Corp
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package identities
|
|
|
|
import (
|
|
"strings"
|
|
|
|
kratos "github.com/ory/kratos/pkg/httpclient"
|
|
|
|
"github.com/ory/x/cmdx"
|
|
)
|
|
|
|
type (
|
|
outputIdentity kratos.Identity
|
|
outputIdentityCollection struct {
|
|
Identities []kratos.Identity `json:"identities"`
|
|
NextPageToken string `json:"next_page_token"`
|
|
includePageToken bool
|
|
}
|
|
)
|
|
|
|
func (outputIdentity) Header() []string {
|
|
return []string{"ID", "EXTERNAL ID", "VERIFIED ADDRESSES", "RECOVERY ADDRESSES", "SCHEMA ID", "SCHEMA URL"}
|
|
}
|
|
|
|
func (i outputIdentity) Columns() []string {
|
|
data := [6]string{
|
|
i.Id,
|
|
cmdx.None,
|
|
cmdx.None,
|
|
cmdx.None,
|
|
cmdx.None,
|
|
cmdx.None,
|
|
}
|
|
|
|
if i.ExternalId != nil && len(*i.ExternalId) > 0 {
|
|
data[1] = *i.ExternalId
|
|
}
|
|
|
|
addresses := make([]string, 0, len(i.VerifiableAddresses))
|
|
for _, a := range i.VerifiableAddresses {
|
|
if len(a.Value) > 0 {
|
|
addresses = append(addresses, a.Value)
|
|
}
|
|
}
|
|
data[2] = strings.Join(addresses, ", ")
|
|
|
|
addresses = addresses[:0]
|
|
for _, a := range i.RecoveryAddresses {
|
|
if len(a.Value) > 0 {
|
|
addresses = append(addresses, a.Value)
|
|
}
|
|
}
|
|
data[3] = strings.Join(addresses, ", ")
|
|
data[4] = i.SchemaId
|
|
data[5] = i.SchemaUrl
|
|
|
|
return data[:]
|
|
}
|
|
|
|
func (i outputIdentity) Interface() interface{} {
|
|
return i
|
|
}
|
|
|
|
func (outputIdentityCollection) Header() []string {
|
|
return outputIdentity{}.Header()
|
|
}
|
|
|
|
func (c outputIdentityCollection) Table() [][]string {
|
|
rows := make([][]string, len(c.Identities))
|
|
for i, ident := range c.Identities {
|
|
rows[i] = outputIdentity(ident).Columns()
|
|
}
|
|
return append(rows,
|
|
[]string{""},
|
|
[]string{"NEXT PAGE TOKEN", c.NextPageToken},
|
|
)
|
|
}
|
|
|
|
func (c outputIdentityCollection) Interface() interface{} {
|
|
if c.includePageToken {
|
|
return c
|
|
}
|
|
return c.Identities
|
|
}
|
|
|
|
func (c *outputIdentityCollection) Len() int {
|
|
return len(c.Identities)
|
|
}
|