Skip to content
Open
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
2 changes: 2 additions & 0 deletions cmd/lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ var properNouns = []string{
"ksqlDB Server",
"ksqlDB",
"Node.js",
"Organization",
"Prometheus",
"Python",
"Real Time Context Engine",
Expand Down Expand Up @@ -337,6 +338,7 @@ var vocabWords = []string{
"savepoints",
"scala",
"schemas",
"scim",
"server",
"signup",
"siv",
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/confluentinc/ccloud-sdk-go-v2/networking-gateway v0.7.0
github.com/confluentinc/ccloud-sdk-go-v2/networking-ip v0.2.0
github.com/confluentinc/ccloud-sdk-go-v2/networking-privatelink v0.3.0
github.com/confluentinc/ccloud-sdk-go-v2/org v0.9.0
github.com/confluentinc/ccloud-sdk-go-v2/org v0.11.0
github.com/confluentinc/ccloud-sdk-go-v2/provider-integration v0.2.0
github.com/confluentinc/ccloud-sdk-go-v2/rtce v0.1.0
github.com/confluentinc/ccloud-sdk-go-v2/service-quota v0.2.0
Expand Down Expand Up @@ -297,3 +297,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/confluentinc/ccloud-sdk-go-v2/org => /Users/ameliadong/git/go/src/github.com/confluentinc/cli-terraform-generator/test-suites/specs/org
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ github.com/confluentinc/ccloud-sdk-go-v2/networking-ip v0.2.0 h1:ZHNF2DeqVlNPuKG
github.com/confluentinc/ccloud-sdk-go-v2/networking-ip v0.2.0/go.mod h1:KTShFBZA7WG8LcxlWjJpoZFdWkJ+uOw3dDuwAHs5eKU=
github.com/confluentinc/ccloud-sdk-go-v2/networking-privatelink v0.3.0 h1:mC0E1nKUt57AxMM4Lpdfd+KA/YZwJVwro9ER+dCUFi8=
github.com/confluentinc/ccloud-sdk-go-v2/networking-privatelink v0.3.0/go.mod h1:GIHF2cYOUKx+6ycYokr4i8E4cuNBC22xqvO/IhqZ31U=
github.com/confluentinc/ccloud-sdk-go-v2/org v0.9.0 h1:FtaqHX0kBTK7fCQK+9SJcOso+XpWCWzY2roT3gBQGfw=
github.com/confluentinc/ccloud-sdk-go-v2/org v0.9.0/go.mod h1:X0uaTYPp+mr19W1R/Z1LuB1ePZJZrH7kxnQckDx6zoc=
github.com/confluentinc/ccloud-sdk-go-v2/provider-integration v0.2.0 h1:UN2a+aqYhk95ro+wVLkeB/8W7n+UV2KsE3jNFbbDCSw=
github.com/confluentinc/ccloud-sdk-go-v2/provider-integration v0.2.0/go.mod h1:TzompS9F0G6awN5xMC+nguNG8ULElN5UqX2XOBOIPuM=
github.com/confluentinc/ccloud-sdk-go-v2/rtce v0.1.0 h1:OBa2vm09bOG1oojOP1vNj8V7+M2AfUkYP1sRQ+xlRm4=
Expand Down
2 changes: 2 additions & 0 deletions internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/confluentinc/cli/v4/internal/login"
"github.com/confluentinc/cli/v4/internal/logout"
"github.com/confluentinc/cli/v4/internal/network"
"github.com/confluentinc/cli/v4/internal/org"
"github.com/confluentinc/cli/v4/internal/organization"
"github.com/confluentinc/cli/v4/internal/plugin"
"github.com/confluentinc/cli/v4/internal/prompt"
Expand Down Expand Up @@ -128,6 +129,7 @@ func NewConfluentCommand(cfg *config.Config) *cobra.Command {
cmd.AddCommand(login.New(cfg, prerunner, ccloudClientFactory, mdsClientManager, loginCredentialsManager, loginOrganizationManager, authTokenHandler))
cmd.AddCommand(logout.New(cfg, prerunner, authTokenHandler))
cmd.AddCommand(network.New(cfg, prerunner))
cmd.AddCommand(org.New(cfg, prerunner))
cmd.AddCommand(organization.New(prerunner))
cmd.AddCommand(plugin.New(cfg, prerunner))
cmd.AddCommand(prompt.New(cfg))
Expand Down
22 changes: 22 additions & 0 deletions internal/org/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org

import (
"github.com/spf13/cobra"

pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/config"
)

func New(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command {
cmd := &cobra.Command{
Use: "org",
Short: "Manage Organization.",
}

cmd.AddCommand(
newScimTokenCommand(cfg, prerunner),
// cli-tfgen:cli-subcommands
)

return cmd
}
Comment on lines +10 to +22
85 changes: 85 additions & 0 deletions internal/org/command_scim_token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package org

import (
"github.com/spf13/cobra"

orgv2 "github.com/confluentinc/ccloud-sdk-go-v2/org/v2"

pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/config"
"github.com/confluentinc/cli/v4/pkg/output"
)

type scimTokenCommand struct {
*pcmd.AuthenticatedCLICommand
}

type scimTokenOut struct {
ID string `human:"ID" serialized:"id"`
ConnectionName string `human:"Connection Name" serialized:"connection_name"`
Token string `human:"Token" serialized:"token"`
CreatedAt string `human:"Created At" serialized:"created_at"`
ExpiresAt string `human:"Expires At" serialized:"expires_at"`
}

func newScimTokenCommand(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { //nolint:unparam
cmd := &cobra.Command{
Use: "scim-token",
Short: "Manage org scim tokens.",
Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin},
}

c := &scimTokenCommand{
AuthenticatedCLICommand: pcmd.NewAuthenticatedCLICommand(cmd, prerunner),
}

cmd.AddCommand(
c.newCreateCommand(),
c.newDeleteCommand(),
c.newListCommand(),
)

return cmd
}

func printScimToken(cmd *cobra.Command, scimToken orgv2.OrgV2ScimToken) error {
table := output.NewTable(cmd)
out := &scimTokenOut{
ID: scimToken.GetId(),
ConnectionName: scimToken.GetConnectionName(),
Token: scimToken.GetToken(),
CreatedAt: scimToken.GetCreatedAt().String(),
ExpiresAt: scimToken.GetExpiresAt().String(),
}
table.Add(out)
return table.Print()
}

func (c *scimTokenCommand) validArgs(cmd *cobra.Command, args []string) []string {
if len(args) > 0 {
return nil
}

return c.validArgsMultiple(cmd, args)
}

func (c *scimTokenCommand) validArgsMultiple(cmd *cobra.Command, args []string) []string {
if err := c.PersistentPreRunE(cmd, args); err != nil {
return nil
}

return c.autocompleteScimTokens()
}

func (c *scimTokenCommand) autocompleteScimTokens() []string {
scimTokens, err := c.V2Client.ListOrgScimTokens()
if err != nil {
return nil
}

suggestions := make([]string, len(scimTokens))
for i, scimToken := range scimTokens {
suggestions[i] = scimToken.GetId()
}
return suggestions
}
39 changes: 39 additions & 0 deletions internal/org/command_scim_token_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org

import (
"github.com/spf13/cobra"

orgv2 "github.com/confluentinc/ccloud-sdk-go-v2/org/v2"

pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/errors"
)

func (c *scimTokenCommand) newCreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: "Create an org scim token.",
Args: cobra.NoArgs,
RunE: c.create,
}

// Required flags

// Optional flags

pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddOutputFlag(cmd)

return cmd
}

func (c *scimTokenCommand) create(cmd *cobra.Command, args []string) error {
createReq := orgv2.InlineObject{}

scimToken, httpResp, err := c.V2Client.CreateOrgScimToken(createReq)
if err != nil {
return errors.CatchCCloudV2Error(err, httpResp)
}

return printScimToken(cmd, scimToken)
}
Comment on lines +30 to +39
38 changes: 38 additions & 0 deletions internal/org/command_scim_token_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org

import (
"github.com/spf13/cobra"

pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/deletion"
)

func (c *scimTokenCommand) newDeleteCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "delete <id-1> [id-2] ... [id-n]",
Short: "Delete one or more org scim tokens.",
Args: cobra.MinimumNArgs(1),
ValidArgsFunction: pcmd.NewValidArgsFunction(c.validArgsMultiple),
RunE: c.delete,
}

// Required flags

// Optional flags

pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddForceFlag(cmd)

return cmd
}

func (c *scimTokenCommand) delete(cmd *cobra.Command, args []string) error {
// Note: existence check skipped because Get operation is not available for this resource

deleteFunc := func(primaryId string) error {
return c.V2Client.DeleteOrgScimToken(primaryId)
}

_, err := deletion.Delete(cmd, args, deleteFunc, "org scim token")
return err
}
47 changes: 47 additions & 0 deletions internal/org/command_scim_token_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org

import (
"github.com/spf13/cobra"

pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/output"
)

func (c *scimTokenCommand) newListCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List org scim tokens.",
Args: cobra.NoArgs,
RunE: c.list,
}

// Required flags

// Optional flags

pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddOutputFlag(cmd)

return cmd
}

func (c *scimTokenCommand) list(cmd *cobra.Command, _ []string) error {

scimTokens, err := c.V2Client.ListOrgScimTokens()
if err != nil {
return err
}

list := output.NewList(cmd)
for _, scimToken := range scimTokens {
out := &scimTokenOut{
ID: scimToken.GetId(),
ConnectionName: scimToken.GetConnectionName(),
Token: scimToken.GetToken(),
CreatedAt: scimToken.GetCreatedAt().String(),
ExpiresAt: scimToken.GetExpiresAt().String(),
}
list.Add(out)
}
return list.Print()
}
47 changes: 47 additions & 0 deletions pkg/ccloudv2/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,50 @@ func (c *Client) executeListOrganizations(pageToken string) (orgv2.OrgV2Organiza
}
return req.Execute()
}

// ===== org scim tokens API calls =====

func (c *Client) CreateOrgScimToken(req orgv2.InlineObject) (orgv2.OrgV2ScimToken, *http.Response, error) {
createReq := c.OrgClient.ScimTokensOrgV2Api.
CreateOrgV2ScimToken(c.orgApiContext()).
InlineObject(req)
return createReq.Execute()
}

func (c *Client) DeleteOrgScimToken(id string) error {
deleteReq := c.OrgClient.ScimTokensOrgV2Api.
DeleteOrgV2ScimToken(c.orgApiContext(), id)
httpResp, err := deleteReq.Execute()
return errors.CatchCCloudV2Error(err, httpResp)
}

func (c *Client) ListOrgScimTokens() ([]orgv2.OrgV2ScimToken, error) {
var list []orgv2.OrgV2ScimToken

done := false
pageToken := ""
for !done {
page, httpResp, err := c.executeListScimTokens(pageToken)
if err != nil {
return nil, errors.CatchCCloudV2Error(err, httpResp)
}
list = append(list, page.GetData()...)

pageToken, done, err = extractNextPageToken(page.GetMetadata().Next)
if err != nil {
return nil, err
}
}

return list, nil
}

func (c *Client) executeListScimTokens(pageToken string) (orgv2.OrgV2ScimTokenList, *http.Response, error) {
req := c.OrgClient.ScimTokensOrgV2Api.
ListOrgV2ScimTokens(c.orgApiContext()).
PageSize(ccloudV2ListPageSize)
if pageToken != "" {
req = req.PageToken(pageToken)
}
return req.Execute()
}
16 changes: 16 additions & 0 deletions test/fixtures/input/org/scim_token/create_scim_token.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"api_version": "org/v2",
"connection_name": "test-connection",
"created_at": "2026-04-16T10:00:00Z",
"expires_at": "2026-10-16T10:00:00Z",
"id": "dlz-f3a90de",
"kind": "ScimToken",
"metadata": {
"created_at": "2006-01-02T15:04:05-07:00",
"deleted_at": "2006-01-02T15:04:05-07:00",
"resource_name": "crn://confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/scim-token=st-12345",
"self": "https://api.confluent.cloud/org/v2/scim-tokens/st-12345",
"updated_at": "2006-01-02T15:04:05-07:00"
},
"token": "cflt-scim_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
16 changes: 16 additions & 0 deletions test/fixtures/input/org/scim_token/read_created_scim_token.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"api_version": "org/v2",
"connection_name": "test-connection",
"created_at": "2026-04-16T10:00:00Z",
"expires_at": "2026-10-16T10:00:00Z",
"id": "dlz-f3a90de",
"kind": "ScimToken",
"metadata": {
"created_at": "2006-01-02T15:04:05-07:00",
"deleted_at": "2006-01-02T15:04:05-07:00",
"resource_name": "crn://confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/scim-token=st-12345",
"self": "https://api.confluent.cloud/org/v2/scim-tokens/st-12345",
"updated_at": "2006-01-02T15:04:05-07:00"
},
"token": "cflt-scim_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
1 change: 1 addition & 0 deletions test/fixtures/output/help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Available Commands:
login Log in to Confluent Cloud or Confluent Platform.
logout Log out of Confluent Cloud.
network Manage Confluent Cloud networks.
org Manage Organization.
organization Manage your Confluent Cloud organizations.
plugin Manage Confluent plugins.
prompt Add Confluent CLI context to your terminal prompt.
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/output/org/help.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Manage Organization.

Usage:
confluent org [command]

Available Commands:
scim-token Manage org scim tokens.

Global Flags:
-h, --help Show help for this command.
--unsafe-trace Equivalent to -vvvv, but also log HTTP requests and responses which might contain plaintext secrets.
-v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, -vvvv for trace).

Use "confluent org [command] --help" for more information about a command.
Loading