Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions temporalcloudcli/commands.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,10 @@ func NewCloudNamespaceCommand(cctx *CommandContext, parent *CloudCommand) *Cloud
s.Command.AddCommand(&NewCloudNamespaceMtlsCommand(cctx, &s).Command)
s.Command.AddCommand(&NewCloudNamespaceRetentionCommand(cctx, &s).Command)
s.Command.AddCommand(&NewCloudNamespaceSearchAttributeCommand(cctx, &s).Command)
s.Command.AddCommand(&NewCloudNamespaceServiceAccountCommand(cctx, &s).Command)
s.Command.AddCommand(&NewCloudNamespaceTagCommand(cctx, &s).Command)
s.Command.AddCommand(&NewCloudNamespaceUserCommand(cctx, &s).Command)
s.Command.AddCommand(&NewCloudNamespaceUserGroupCommand(cctx, &s).Command)
return &s
}

Expand Down Expand Up @@ -3955,6 +3958,55 @@ func NewCloudNamespaceSearchAttributeRenameCommand(cctx *CommandContext, parent
return &s
}

type CloudNamespaceServiceAccountCommand struct {
Parent *CloudNamespaceCommand
Command cobra.Command
}

func NewCloudNamespaceServiceAccountCommand(cctx *CommandContext, parent *CloudNamespaceCommand) *CloudNamespaceServiceAccountCommand {
var s CloudNamespaceServiceAccountCommand
s.Parent = parent
s.Command.Use = "service-account"
s.Command.Short = "Inspect service accounts with access to a namespace"
s.Command.Long = "Commands for inspecting the service accounts that have access to a\nTemporal Cloud namespace."
s.Command.Args = cobra.NoArgs
s.Command.AddCommand(&NewCloudNamespaceServiceAccountListCommand(cctx, &s).Command)
return &s
}

type CloudNamespaceServiceAccountListCommand struct {
Parent *CloudNamespaceServiceAccountCommand
Command cobra.Command
ClientOptions
NamespaceOptions
PageSize int
PageToken string
}

func NewCloudNamespaceServiceAccountListCommand(cctx *CommandContext, parent *CloudNamespaceServiceAccountCommand) *CloudNamespaceServiceAccountListCommand {
var s CloudNamespaceServiceAccountListCommand
s.Parent = parent
s.Command.DisableFlagsInUseLine = true
s.Command.Use = "list [flags]"
s.Command.Short = "List service accounts with access to a namespace"
if hasHighlighting {
s.Command.Long = "List the service accounts that have access to a Temporal Cloud namespace,\nincluding both directly-assigned and inherited access.\n\nExample:\n\n\x1b[1mtemporal cloud namespace service-account list --namespace my-namespace.my-account\x1b[0m"
} else {
s.Command.Long = "List the service accounts that have access to a Temporal Cloud namespace,\nincluding both directly-assigned and inherited access.\n\nExample:\n\n```\ntemporal cloud namespace service-account list --namespace my-namespace.my-account\n```"
}
s.Command.Args = cobra.NoArgs
s.Command.Flags().IntVar(&s.PageSize, "page-size", 0, "Number of service accounts to return per page. Use for paginated results.")
s.Command.Flags().StringVar(&s.PageToken, "page-token", "", "Token for retrieving the next page of results in a paginated list.")
s.ClientOptions.BuildFlags(s.Command.Flags())
s.NamespaceOptions.BuildFlags(s.Command.Flags())
s.Command.Run = func(c *cobra.Command, args []string) {
if err := s.run(cctx, args); err != nil {
cctx.Options.Fail(err)
}
}
return &s
}

type CloudNamespaceTagCommand struct {
Parent *CloudNamespaceCommand
Command cobra.Command
Expand Down Expand Up @@ -4111,6 +4163,104 @@ func NewCloudNamespaceTagUpdateCommand(cctx *CommandContext, parent *CloudNamesp
return &s
}

type CloudNamespaceUserCommand struct {
Parent *CloudNamespaceCommand
Command cobra.Command
}

func NewCloudNamespaceUserCommand(cctx *CommandContext, parent *CloudNamespaceCommand) *CloudNamespaceUserCommand {
var s CloudNamespaceUserCommand
s.Parent = parent
s.Command.Use = "user"
s.Command.Short = "Inspect users with access to a namespace"
s.Command.Long = "Commands for inspecting the users that have access to a Temporal Cloud\nnamespace."
s.Command.Args = cobra.NoArgs
s.Command.AddCommand(&NewCloudNamespaceUserListCommand(cctx, &s).Command)
return &s
}

type CloudNamespaceUserListCommand struct {
Parent *CloudNamespaceUserCommand
Command cobra.Command
ClientOptions
NamespaceOptions
PageSize int
PageToken string
}

func NewCloudNamespaceUserListCommand(cctx *CommandContext, parent *CloudNamespaceUserCommand) *CloudNamespaceUserListCommand {
var s CloudNamespaceUserListCommand
s.Parent = parent
s.Command.DisableFlagsInUseLine = true
s.Command.Use = "list [flags]"
s.Command.Short = "List users with access to a namespace"
if hasHighlighting {
s.Command.Long = "List the users that have access to a Temporal Cloud namespace, including\nboth directly-assigned and inherited access.\n\nExample:\n\n\x1b[1mtemporal cloud namespace user list --namespace my-namespace.my-account\x1b[0m"
} else {
s.Command.Long = "List the users that have access to a Temporal Cloud namespace, including\nboth directly-assigned and inherited access.\n\nExample:\n\n```\ntemporal cloud namespace user list --namespace my-namespace.my-account\n```"
}
s.Command.Args = cobra.NoArgs
s.Command.Flags().IntVar(&s.PageSize, "page-size", 0, "Number of users to return per page. Use for paginated results.")
s.Command.Flags().StringVar(&s.PageToken, "page-token", "", "Token for retrieving the next page of results in a paginated list.")
s.ClientOptions.BuildFlags(s.Command.Flags())
s.NamespaceOptions.BuildFlags(s.Command.Flags())
s.Command.Run = func(c *cobra.Command, args []string) {
if err := s.run(cctx, args); err != nil {
cctx.Options.Fail(err)
}
}
return &s
}

type CloudNamespaceUserGroupCommand struct {
Parent *CloudNamespaceCommand
Command cobra.Command
}

func NewCloudNamespaceUserGroupCommand(cctx *CommandContext, parent *CloudNamespaceCommand) *CloudNamespaceUserGroupCommand {
var s CloudNamespaceUserGroupCommand
s.Parent = parent
s.Command.Use = "user-group"
s.Command.Short = "Inspect user groups with access to a namespace"
s.Command.Long = "Commands for inspecting the user groups that have access to a Temporal\nCloud namespace."
s.Command.Args = cobra.NoArgs
s.Command.AddCommand(&NewCloudNamespaceUserGroupListCommand(cctx, &s).Command)
return &s
}

type CloudNamespaceUserGroupListCommand struct {
Parent *CloudNamespaceUserGroupCommand
Command cobra.Command
ClientOptions
NamespaceOptions
PageSize int
PageToken string
}

func NewCloudNamespaceUserGroupListCommand(cctx *CommandContext, parent *CloudNamespaceUserGroupCommand) *CloudNamespaceUserGroupListCommand {
var s CloudNamespaceUserGroupListCommand
s.Parent = parent
s.Command.DisableFlagsInUseLine = true
s.Command.Use = "list [flags]"
s.Command.Short = "List user groups with access to a namespace"
if hasHighlighting {
s.Command.Long = "List the user groups that have access to a Temporal Cloud namespace,\nincluding both directly-assigned and inherited access.\n\nExample:\n\n\x1b[1mtemporal cloud namespace user-group list --namespace my-namespace.my-account\x1b[0m"
} else {
s.Command.Long = "List the user groups that have access to a Temporal Cloud namespace,\nincluding both directly-assigned and inherited access.\n\nExample:\n\n```\ntemporal cloud namespace user-group list --namespace my-namespace.my-account\n```"
}
s.Command.Args = cobra.NoArgs
s.Command.Flags().IntVar(&s.PageSize, "page-size", 0, "Number of user groups to return per page. Use for paginated results.")
s.Command.Flags().StringVar(&s.PageToken, "page-token", "", "Token for retrieving the next page of results in a paginated list.")
s.ClientOptions.BuildFlags(s.Command.Flags())
s.NamespaceOptions.BuildFlags(s.Command.Flags())
s.Command.Run = func(c *cobra.Command, args []string) {
if err := s.run(cctx, args); err != nil {
cctx.Options.Fail(err)
}
}
return &s
}

type CloudNexusCommand struct {
Parent *CloudCommand
Command cobra.Command
Expand Down
96 changes: 96 additions & 0 deletions temporalcloudcli/commands.namespace.access.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package temporalcloudcli

import (
cloudservice "go.temporal.io/cloud-sdk/api/cloudservice/v1"
identityv1 "go.temporal.io/cloud-sdk/api/identity/v1"

"github.com/temporalio/cloud-cli/temporalcloudcli/internal/printer"
)

// AIDEV-NOTE: These commands wrap the read-only Get*NamespaceAssignments RPCs
// added in cloud-sdk-go v0.14.x. They list the identities (users, service
// accounts, user groups) that have explicit access to a namespace.

func (c *CloudNamespaceUserListCommand) run(cctx *CommandContext, _ []string) error {
client, err := cctx.GetCloudClient(c.ClientOptions)
if err != nil {
return err
}
res, err := client.GetUserNamespaceAssignments(cctx, &cloudservice.GetUserNamespaceAssignmentsRequest{
Namespace: c.Namespace,
PageSize: int32(c.PageSize),
PageToken: c.PageToken,
})
if err != nil {
return err
}
return cctx.Printer.PrintResourceList(
struct {
Users []*identityv1.UserNamespaceAssignment
NextPageToken string
}{
Users: res.Users,
NextPageToken: res.NextPageToken,
},
printer.PrintResourceOptions{
Fields: []string{"Id", "Email", "NamespaceAccess", "InheritedAccess"},
},
Comment thread
cursor[bot] marked this conversation as resolved.
printer.TableOptions{},
)
}

func (c *CloudNamespaceServiceAccountListCommand) run(cctx *CommandContext, _ []string) error {
client, err := cctx.GetCloudClient(c.ClientOptions)
if err != nil {
return err
}
res, err := client.GetServiceAccountNamespaceAssignments(cctx, &cloudservice.GetServiceAccountNamespaceAssignmentsRequest{
Namespace: c.Namespace,
PageSize: int32(c.PageSize),
PageToken: c.PageToken,
})
if err != nil {
return err
}
return cctx.Printer.PrintResourceList(
struct {
ServiceAccounts []*identityv1.ServiceAccountNamespaceAssignment
NextPageToken string
}{
ServiceAccounts: res.ServiceAccounts,
NextPageToken: res.NextPageToken,
},
printer.PrintResourceOptions{
Fields: []string{"Id", "Name", "NamespaceAccess", "InheritedAccess"},
},
Comment thread
cursor[bot] marked this conversation as resolved.
printer.TableOptions{},
)
}

func (c *CloudNamespaceUserGroupListCommand) run(cctx *CommandContext, _ []string) error {
client, err := cctx.GetCloudClient(c.ClientOptions)
if err != nil {
return err
}
res, err := client.GetUserGroupNamespaceAssignments(cctx, &cloudservice.GetUserGroupNamespaceAssignmentsRequest{
Namespace: c.Namespace,
PageSize: int32(c.PageSize),
PageToken: c.PageToken,
})
if err != nil {
return err
}
return cctx.Printer.PrintResourceList(
struct {
Groups []*identityv1.UserGroupNamespaceAssignment
NextPageToken string
}{
Groups: res.Groups,
NextPageToken: res.NextPageToken,
},
printer.PrintResourceOptions{
Fields: []string{"Id", "DisplayName", "NamespaceAccess", "InheritedAccess"},
},
Comment thread
cursor[bot] marked this conversation as resolved.
printer.TableOptions{},
)
}
Loading
Loading