diff --git a/.cli-generation-checksum b/.cli-generation-checksum index 052da31c34..f9e1f0b07c 100644 --- a/.cli-generation-checksum +++ b/.cli-generation-checksum @@ -1 +1 @@ -9c39902d7e866613dbfe066caee3af50081e703e9c114393bf66abdba6abc3e7 +95a34e2970dcde24e8baa0ceaf78d25d36a143fe81a6d8fdfb5c8be80e26dcf7 diff --git a/cmd/lint/main.go b/cmd/lint/main.go index 80e1acfbff..20148522ff 100644 --- a/cmd/lint/main.go +++ b/cmd/lint/main.go @@ -184,6 +184,7 @@ var properNouns = []string{ "Connect", "Control Center", "CRL", + "Cloud Notifications", "Data Encryption Key", "Databricks", "DEK", @@ -214,12 +215,16 @@ var properNouns = []string{ "Tableflow", "Unified Stream Manager", "USM", + "Webhook", "ZooKeeper™", // cli-tfgen:lint-properNouns — DO NOT REMOVE (verified by TestCliTfgenMarkers) } // vocabWords are words that don't appear in the US dictionary, but are Confluent-related words. var vocabWords = []string{ + "24h", + "30d", + "7d", "a2a", "ack", "acks", @@ -299,7 +304,10 @@ var vocabWords = []string{ "jsonschema", "jwks", "JWT", + "crns", + "eg", "enum", + "integrations", "kafka", "kek", "keychain", @@ -387,6 +395,7 @@ var vocabWords = []string{ "vv", "vvv", "vvvv", + "webhook", "whitelist", "wikipedia", "workspace", diff --git a/go.mod b/go.mod index df7a2a5058..86579710c6 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +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/notifications v0.1.0 github.com/confluentinc/ccloud-sdk-go-v2/org v0.14.0 github.com/confluentinc/ccloud-sdk-go-v2/provider-integration v0.2.0 github.com/confluentinc/ccloud-sdk-go-v2/rtce v0.1.0 diff --git a/go.sum b/go.sum index 22ecac73dc..484180c218 100644 --- a/go.sum +++ b/go.sum @@ -225,6 +225,8 @@ 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/notifications v0.1.0 h1:LidTP8SPc9g3Cw56eW73kCbB9JbKZ5iJ0UkgmG6Gn9I= +github.com/confluentinc/ccloud-sdk-go-v2/notifications v0.1.0/go.mod h1:VpOjD3MKw8uRUNhwBEkEbH1a+JTs50FiNANMh0LYOQ8= github.com/confluentinc/ccloud-sdk-go-v2/org v0.14.0 h1:n+4lb+CFCExljsp4Goyb4JTDL/UibGUhT0k++5JNhw8= github.com/confluentinc/ccloud-sdk-go-v2/org v0.14.0/go.mod h1:z+7wtFzDczbMGda7AG7w14BGE3pQSjaFYhNbvkZAlOs= github.com/confluentinc/ccloud-sdk-go-v2/provider-integration v0.2.0 h1:UN2a+aqYhk95ro+wVLkeB/8W7n+UV2KsE3jNFbbDCSw= diff --git a/internal/command.go b/internal/command.go index 66472cd363..147a59acbe 100644 --- a/internal/command.go +++ b/internal/command.go @@ -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/notifications" "github.com/confluentinc/cli/v4/internal/organization" "github.com/confluentinc/cli/v4/internal/plugin" "github.com/confluentinc/cli/v4/internal/prompt" @@ -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(notifications.New(cfg, prerunner)) cmd.AddCommand(organization.New(cfg, prerunner)) cmd.AddCommand(plugin.New(cfg, prerunner)) cmd.AddCommand(prompt.New(cfg)) diff --git a/internal/notifications/command.go b/internal/notifications/command.go new file mode 100644 index 0000000000..2948854a1b --- /dev/null +++ b/internal/notifications/command.go @@ -0,0 +1,29 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +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: "notifications", + Short: "Manage Cloud Notifications.", + } + + cmd.AddCommand( + newIntegrationCommand(cfg, prerunner), + newNotificationTypeCommand(cfg, prerunner), + newResourcePreferenceCommand(cfg, prerunner), + newResourceSubscriptionCommand(cfg, prerunner), + newSubscriptionCommand(cfg, prerunner), + newUserNotificationCommand(cfg, prerunner), + // cli-tfgen:cli-subcommands + ) + + return cmd +} diff --git a/internal/notifications/command_integration.go b/internal/notifications/command_integration.go new file mode 100644 index 0000000000..09d65589cf --- /dev/null +++ b/internal/notifications/command_integration.go @@ -0,0 +1,103 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "fmt" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/config" + "github.com/confluentinc/cli/v4/pkg/output" +) + +type integrationCommand struct { + *pcmd.AuthenticatedCLICommand +} + +type integrationOut struct { + ID string `human:"ID" serialized:"id"` + DisplayName string `human:"Display Name" serialized:"display_name"` + Description string `human:"Description" serialized:"description"` + SlackTargetWebhookUrl string `human:"Slack Target Webhook Url,omitempty" serialized:"slack_target_webhook_url,omitempty"` + RoleEmailTargetRoleName string `human:"Role Email Target Role Name,omitempty" serialized:"role_email_target_role_name,omitempty"` + WebhookTargetUrl string `human:"Webhook Target Url,omitempty" serialized:"webhook_target_url,omitempty"` + MsTeamsTargetWebhookUrl string `human:"Ms Teams Target Webhook Url,omitempty" serialized:"ms_teams_target_webhook_url,omitempty"` +} + +func newIntegrationCommand(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { //nolint:unparam + cmd := &cobra.Command{ + Use: "integration", + Short: "Manage Confluent Cloud notifications integrations.", + Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin}, + } + + c := &integrationCommand{ + AuthenticatedCLICommand: pcmd.NewAuthenticatedCLICommand(cmd, prerunner), + } + + cmd.AddCommand( + c.newCreateCommand(), + c.newDeleteCommand(), + c.newDescribeCommand(), + c.newListCommand(), + c.newUpdateCommand(), + ) + + return cmd +} + +func printIntegration(cmd *cobra.Command, integration notificationsv1.NotificationsV1Integration) error { + table := output.NewTable(cmd) + out := &integrationOut{ + ID: integration.GetId(), + DisplayName: integration.GetDisplayName(), + Description: integration.GetDescription(), + } + if integration.Target.NotificationsV1SlackTarget != nil { + out.SlackTargetWebhookUrl = integration.Target.NotificationsV1SlackTarget.GetWebhookUrl() + } + if integration.Target.NotificationsV1RoleEmailTarget != nil { + out.RoleEmailTargetRoleName = integration.Target.NotificationsV1RoleEmailTarget.GetRoleName() + } + if integration.Target.NotificationsV1WebhookTarget != nil { + out.WebhookTargetUrl = integration.Target.NotificationsV1WebhookTarget.GetUrl() + } + if integration.Target.NotificationsV1MsTeamsTarget != nil { + out.MsTeamsTargetWebhookUrl = integration.Target.NotificationsV1MsTeamsTarget.GetWebhookUrl() + } + table.Add(out) + return table.Print() +} + +func (c *integrationCommand) validArgs(cmd *cobra.Command, args []string) []string { + if len(args) > 0 { + return nil + } + + return c.validArgsMultiple(cmd, args) +} + +func (c *integrationCommand) validArgsMultiple(cmd *cobra.Command, args []string) []string { + if err := c.PersistentPreRunE(cmd, args); err != nil { + return nil + } + + return c.autocompleteIntegrations() +} + +func (c *integrationCommand) autocompleteIntegrations() []string { + integrations, err := c.V2Client.ListNotificationsIntegrations() + if err != nil { + return nil + } + + suggestions := make([]string, len(integrations)) + for i, integration := range integrations { + suggestions[i] = fmt.Sprintf("%s\t%s", integration.GetId(), integration.GetDisplayName()) + } + return suggestions +} diff --git a/internal/notifications/command_integration_create.go b/internal/notifications/command_integration_create.go new file mode 100644 index 0000000000..b5e4a20048 --- /dev/null +++ b/internal/notifications/command_integration_create.go @@ -0,0 +1,112 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *integrationCommand) newCreateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "create ", + Short: "Create a notifications integration.", + Args: cobra.ExactArgs(1), + RunE: c.create, + } + + // Required flags + cmd.Flags().String("kind", "", "Integration-specific details (integration targets). One of: Slack, Webhook, MsTeams.") + cobra.CheckErr(cmd.MarkFlagRequired("kind")) + + // Optional flags + cmd.Flags().String("webhook-url", "", "Slack: Slack Webhook URL for the particular Slack channel. MsTeams: MS Teams Webhook URL for the particular team channel.") + cmd.Flags().String("url", "", "URL endpoint for the webhook.") + cmd.Flags().String("description", "", "A human readable description for the particular integration.") + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *integrationCommand) create(cmd *cobra.Command, args []string) error { + name := args[0] + + createReq := notificationsv1.NotificationsV1Integration{} + + createReq.DisplayName = notificationsv1.PtrString(name) + description, err := cmd.Flags().GetString("description") + if err != nil { + return err + } + if description != "" { + createReq.Description = notificationsv1.PtrString(description) + } + + // oneOf: target + kind, err := cmd.Flags().GetString("kind") + if err != nil { + return err + } + + switch strings.ToLower(kind) { + case "slack": + if !cmd.Flags().Changed("webhook-url") { + return fmt.Errorf(`required flag "--%s" not set for %s`, "webhook-url", "Slack") + } + slackTarget := notificationsv1.NotificationsV1SlackTarget{ + Kind: "Slack", + } + webhookUrl, err := cmd.Flags().GetString("webhook-url") + if err != nil { + return err + } + slackTarget.WebhookUrl = webhookUrl + slackTargetOneOf := notificationsv1.NotificationsV1SlackTargetAsNotificationsV1Target(&slackTarget) + createReq.Target = &slackTargetOneOf + case "webhook": + if !cmd.Flags().Changed("url") { + return fmt.Errorf(`required flag "--%s" not set for %s`, "url", "Webhook") + } + webhookTarget := notificationsv1.NotificationsV1WebhookTarget{ + Kind: "Webhook", + } + url, err := cmd.Flags().GetString("url") + if err != nil { + return err + } + webhookTarget.Url = url + webhookTargetOneOf := notificationsv1.NotificationsV1WebhookTargetAsNotificationsV1Target(&webhookTarget) + createReq.Target = &webhookTargetOneOf + case "msteams": + if !cmd.Flags().Changed("webhook-url") { + return fmt.Errorf(`required flag "--%s" not set for %s`, "webhook-url", "MsTeams") + } + msTeamsTarget := notificationsv1.NotificationsV1MsTeamsTarget{ + Kind: "MsTeams", + } + webhookUrl, err := cmd.Flags().GetString("webhook-url") + if err != nil { + return err + } + msTeamsTarget.WebhookUrl = webhookUrl + msTeamsTargetOneOf := notificationsv1.NotificationsV1MsTeamsTargetAsNotificationsV1Target(&msTeamsTarget) + createReq.Target = &msTeamsTargetOneOf + default: + return fmt.Errorf("unrecognized target type: %s", kind) + } + integration, httpResp, err := c.V2Client.CreateNotificationsIntegration(createReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printIntegration(cmd, integration) +} diff --git a/internal/notifications/command_integration_delete.go b/internal/notifications/command_integration_delete.go new file mode 100644 index 0000000000..141bb7897a --- /dev/null +++ b/internal/notifications/command_integration_delete.go @@ -0,0 +1,47 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/deletion" +) + +func (c *integrationCommand) newDeleteCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete [id-2] ... [id-n]", + Short: "Delete one or more notifications integrations.", + 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 *integrationCommand) delete(cmd *cobra.Command, args []string) error { + existenceFunc := func(primaryId string) bool { + _, _, err := c.V2Client.GetNotificationsIntegration(primaryId) + return err == nil + } + + if err := deletion.ValidateAndConfirm(cmd, args, existenceFunc, "notifications integration"); err != nil { + return err + } + + deleteFunc := func(primaryId string) error { + return c.V2Client.DeleteNotificationsIntegration(primaryId) + } + + _, err := deletion.Delete(cmd, args, deleteFunc, "notifications integration") + return err +} diff --git a/internal/notifications/command_integration_describe.go b/internal/notifications/command_integration_describe.go new file mode 100644 index 0000000000..4fac534ca7 --- /dev/null +++ b/internal/notifications/command_integration_describe.go @@ -0,0 +1,40 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *integrationCommand) newDescribeCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "describe ", + Short: "Describe a notifications integration.", + Args: cobra.ExactArgs(1), + ValidArgsFunction: pcmd.NewValidArgsFunction(c.validArgs), + RunE: c.describe, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *integrationCommand) describe(cmd *cobra.Command, args []string) error { + id := args[0] + + integration, httpResp, err := c.V2Client.GetNotificationsIntegration(id) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printIntegration(cmd, integration) +} diff --git a/internal/notifications/command_integration_list.go b/internal/notifications/command_integration_list.go new file mode 100644 index 0000000000..d93bc9e6b9 --- /dev/null +++ b/internal/notifications/command_integration_list.go @@ -0,0 +1,58 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *integrationCommand) newListCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "List notifications integrations.", + Args: cobra.NoArgs, + RunE: c.list, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *integrationCommand) list(cmd *cobra.Command, _ []string) error { + integrations, err := c.V2Client.ListNotificationsIntegrations() + if err != nil { + return err + } + + list := output.NewList(cmd) + for _, integration := range integrations { + out := &integrationOut{ + ID: integration.GetId(), + DisplayName: integration.GetDisplayName(), + Description: integration.GetDescription(), + } + if integration.Target.NotificationsV1SlackTarget != nil { + out.SlackTargetWebhookUrl = integration.Target.NotificationsV1SlackTarget.GetWebhookUrl() + } + if integration.Target.NotificationsV1RoleEmailTarget != nil { + out.RoleEmailTargetRoleName = integration.Target.NotificationsV1RoleEmailTarget.GetRoleName() + } + if integration.Target.NotificationsV1WebhookTarget != nil { + out.WebhookTargetUrl = integration.Target.NotificationsV1WebhookTarget.GetUrl() + } + if integration.Target.NotificationsV1MsTeamsTarget != nil { + out.MsTeamsTargetWebhookUrl = integration.Target.NotificationsV1MsTeamsTarget.GetWebhookUrl() + } + list.Add(out) + } + return list.Print() +} diff --git a/internal/notifications/command_integration_update.go b/internal/notifications/command_integration_update.go new file mode 100644 index 0000000000..709be3e3a7 --- /dev/null +++ b/internal/notifications/command_integration_update.go @@ -0,0 +1,130 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *integrationCommand) newUpdateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "update ", + Short: "Update an existing notifications integration.", + Args: cobra.ExactArgs(1), + ValidArgsFunction: pcmd.NewValidArgsFunction(c.validArgs), + RunE: c.update, + } + + // Required flags + + // Optional flags + cmd.Flags().String("kind", "", "Integration-specific details (integration targets). One of: Slack, Webhook, MsTeams.") + cmd.Flags().String("webhook-url", "", "Slack: Slack Webhook URL for the particular Slack channel. MsTeams: MS Teams Webhook URL for the particular team channel.") + cmd.Flags().String("url", "", "URL endpoint for the webhook.") + cmd.Flags().String("display-name", "", "A human readable name for the particular integration.") + cmd.Flags().String("description", "", "A human readable description for the particular integration.") + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *integrationCommand) update(cmd *cobra.Command, args []string) error { + id := args[0] + + updateReq := notificationsv1.NotificationsV1Integration{} + + if cmd.Flags().Changed("display-name") { + displayName, err := cmd.Flags().GetString("display-name") + if err != nil { + return err + } + updateReq.DisplayName = notificationsv1.PtrString(displayName) + } + + if cmd.Flags().Changed("description") { + description, err := cmd.Flags().GetString("description") + if err != nil { + return err + } + updateReq.Description = notificationsv1.PtrString(description) + } + + // oneOf: target + kind, err := cmd.Flags().GetString("kind") + if err != nil { + return err + } + if !cmd.Flags().Changed("kind") { + for _, flag := range []string{"webhook-url", "url"} { + if cmd.Flags().Changed(flag) { + return fmt.Errorf("--%s requires --kind", flag) + } + } + } + if cmd.Flags().Changed("kind") { + + switch strings.ToLower(kind) { + case "slack": + slackTarget := notificationsv1.NotificationsV1SlackTarget{ + Kind: "Slack", + } + webhookUrl, err := cmd.Flags().GetString("webhook-url") + if err != nil { + return err + } + if cmd.Flags().Changed("webhook-url") { + slackTarget.WebhookUrl = webhookUrl + } + slackTargetOneOf := notificationsv1.NotificationsV1SlackTargetAsNotificationsV1Target(&slackTarget) + updateReq.Target = &slackTargetOneOf + case "webhook": + webhookTarget := notificationsv1.NotificationsV1WebhookTarget{ + Kind: "Webhook", + } + url, err := cmd.Flags().GetString("url") + if err != nil { + return err + } + if cmd.Flags().Changed("url") { + webhookTarget.Url = url + } + webhookTargetOneOf := notificationsv1.NotificationsV1WebhookTargetAsNotificationsV1Target(&webhookTarget) + updateReq.Target = &webhookTargetOneOf + case "msteams": + msTeamsTarget := notificationsv1.NotificationsV1MsTeamsTarget{ + Kind: "MsTeams", + } + webhookUrl, err := cmd.Flags().GetString("webhook-url") + if err != nil { + return err + } + if cmd.Flags().Changed("webhook-url") { + msTeamsTarget.WebhookUrl = webhookUrl + } + msTeamsTargetOneOf := notificationsv1.NotificationsV1MsTeamsTargetAsNotificationsV1Target(&msTeamsTarget) + updateReq.Target = &msTeamsTargetOneOf + default: + return fmt.Errorf("unrecognized target type: %s", kind) + } + } + integration, httpResp, err := c.V2Client.UpdateNotificationsIntegration(id, updateReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + if output.GetFormat(cmd) == output.Human { + output.Printf(c.Config.EnableColor, "Updated notifications integration \"%s\".\n", id) + } + return printIntegration(cmd, integration) +} diff --git a/internal/notifications/command_notification_type.go b/internal/notifications/command_notification_type.go new file mode 100644 index 0000000000..3eaa2a73f9 --- /dev/null +++ b/internal/notifications/command_notification_type.go @@ -0,0 +1,92 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "fmt" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/config" + "github.com/confluentinc/cli/v4/pkg/output" +) + +type notificationTypeCommand struct { + *pcmd.AuthenticatedCLICommand +} + +type notificationTypeOut struct { + ID string `human:"ID" serialized:"id"` + DisplayName string `human:"Display Name" serialized:"display_name"` + Category string `human:"Category" serialized:"category"` + Description string `human:"Description" serialized:"description"` + SubscriptionPriority string `human:"Subscription Priority" serialized:"subscription_priority"` + IsIncludedInPlan bool `human:"Is Included In Plan" serialized:"is_included_in_plan"` + Severity string `human:"Severity" serialized:"severity"` +} + +func newNotificationTypeCommand(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { //nolint:unparam + cmd := &cobra.Command{ + Use: "notification-type", + Short: "Manage Confluent Cloud notifications notification types.", + Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin}, + } + + c := ¬ificationTypeCommand{ + AuthenticatedCLICommand: pcmd.NewAuthenticatedCLICommand(cmd, prerunner), + } + + cmd.AddCommand( + c.newDescribeCommand(), + c.newListCommand(), + ) + + return cmd +} + +func printNotificationType(cmd *cobra.Command, notificationType notificationsv1.NotificationsV1NotificationType) error { + table := output.NewTable(cmd) + out := ¬ificationTypeOut{ + ID: notificationType.GetId(), + DisplayName: notificationType.GetDisplayName(), + Category: notificationType.GetCategory(), + Description: notificationType.GetDescription(), + SubscriptionPriority: notificationType.GetSubscriptionPriority(), + IsIncludedInPlan: notificationType.GetIsIncludedInPlan(), + Severity: notificationType.GetSeverity(), + } + table.Add(out) + return table.Print() +} + +func (c *notificationTypeCommand) validArgs(cmd *cobra.Command, args []string) []string { + if len(args) > 0 { + return nil + } + + return c.validArgsMultiple(cmd, args) +} + +func (c *notificationTypeCommand) validArgsMultiple(cmd *cobra.Command, args []string) []string { + if err := c.PersistentPreRunE(cmd, args); err != nil { + return nil + } + + return c.autocompleteNotificationTypes() +} + +func (c *notificationTypeCommand) autocompleteNotificationTypes() []string { + notificationTypes, err := c.V2Client.ListNotificationsNotificationTypes("") + if err != nil { + return nil + } + + suggestions := make([]string, len(notificationTypes)) + for i, notificationType := range notificationTypes { + suggestions[i] = fmt.Sprintf("%s\t%s", notificationType.GetId(), notificationType.GetDisplayName()) + } + return suggestions +} diff --git a/internal/notifications/command_notification_type_describe.go b/internal/notifications/command_notification_type_describe.go new file mode 100644 index 0000000000..6756d3143f --- /dev/null +++ b/internal/notifications/command_notification_type_describe.go @@ -0,0 +1,40 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *notificationTypeCommand) newDescribeCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "describe ", + Short: "Describe a notifications notification type.", + Args: cobra.ExactArgs(1), + ValidArgsFunction: pcmd.NewValidArgsFunction(c.validArgs), + RunE: c.describe, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *notificationTypeCommand) describe(cmd *cobra.Command, args []string) error { + id := args[0] + + notificationType, httpResp, err := c.V2Client.GetNotificationsNotificationType(id) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printNotificationType(cmd, notificationType) +} diff --git a/internal/notifications/command_notification_type_list.go b/internal/notifications/command_notification_type_list.go new file mode 100644 index 0000000000..ec76490cfe --- /dev/null +++ b/internal/notifications/command_notification_type_list.go @@ -0,0 +1,56 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *notificationTypeCommand) newListCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "List notifications notification types.", + Args: cobra.NoArgs, + RunE: c.list, + } + + // Required flags + + // Optional flags + cmd.Flags().String("resource-type", "", "Confluent Cloud resource type.") + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *notificationTypeCommand) list(cmd *cobra.Command, _ []string) error { + resourceType, err := cmd.Flags().GetString("resource-type") + if err != nil { + return err + } + + notificationTypes, err := c.V2Client.ListNotificationsNotificationTypes(resourceType) + if err != nil { + return err + } + + list := output.NewList(cmd) + for _, notificationType := range notificationTypes { + out := ¬ificationTypeOut{ + ID: notificationType.GetId(), + DisplayName: notificationType.GetDisplayName(), + Category: notificationType.GetCategory(), + Description: notificationType.GetDescription(), + SubscriptionPriority: notificationType.GetSubscriptionPriority(), + IsIncludedInPlan: notificationType.GetIsIncludedInPlan(), + Severity: notificationType.GetSeverity(), + } + list.Add(out) + } + return list.Print() +} diff --git a/internal/notifications/command_resource_preference.go b/internal/notifications/command_resource_preference.go new file mode 100644 index 0000000000..7369331de8 --- /dev/null +++ b/internal/notifications/command_resource_preference.go @@ -0,0 +1,57 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/config" + "github.com/confluentinc/cli/v4/pkg/output" +) + +type resourcePreferenceCommand struct { + *pcmd.AuthenticatedCLICommand +} + +type resourcePreferenceOut struct { + ID string `human:"ID" serialized:"id"` + Resource string `human:"Resource" serialized:"resource"` + ResourceType string `human:"Resource Type" serialized:"resource_type"` + CurrentState string `human:"Current State" serialized:"current_state"` +} + +func newResourcePreferenceCommand(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { //nolint:unparam + cmd := &cobra.Command{ + Use: "resource-preference", + Short: "Manage Confluent Cloud notifications resource preferences.", + Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin}, + } + + c := &resourcePreferenceCommand{ + AuthenticatedCLICommand: pcmd.NewAuthenticatedCLICommand(cmd, prerunner), + } + + cmd.AddCommand( + c.newCreateCommand(), + c.newDeleteCommand(), + c.newDescribeCommand(), + c.newUpdateCommand(), + ) + + return cmd +} + +func printResourcePreference(cmd *cobra.Command, resourcePreference notificationsv1.NotificationsV1ResourcePreference) error { + table := output.NewTable(cmd) + out := &resourcePreferenceOut{ + ID: resourcePreference.GetId(), + Resource: resourcePreference.GetResource(), + ResourceType: resourcePreference.GetResourceType(), + CurrentState: resourcePreference.GetCurrentState(), + } + table.Add(out) + return table.Print() +} diff --git a/internal/notifications/command_resource_preference_create.go b/internal/notifications/command_resource_preference_create.go new file mode 100644 index 0000000000..fc75e744ac --- /dev/null +++ b/internal/notifications/command_resource_preference_create.go @@ -0,0 +1,74 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "strings" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *resourcePreferenceCommand) newCreateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "create", + Short: "Create a notifications resource preference.", + Args: cobra.NoArgs, + RunE: c.create, + } + + // Required flags + cmd.Flags().String("resource", "", "Denotes the Confluent Cloud resource definition.") + cmd.Flags().String("resource-type", "", "Denotes the Confluent Cloud resource type.") + pcmd.RegisterFlagCompletionFunc(cmd, "resource-type", func(_ *cobra.Command, _ []string) []string { + return []string{"ORGANIZATION", "ENVIRONMENT", "CLUSTER", "CONNECTOR", "FLINK_COMPUTE_POOL", "FLINK_STATEMENT"} + }) + cobra.CheckErr(cmd.MarkFlagRequired("resource")) + cobra.CheckErr(cmd.MarkFlagRequired("resource-type")) + + // Optional flags + cmd.Flags().String("current-state", "", "Denotes the state of the resource preference. When the resource preference is ENABLED, the user will receive notifications for the Confluent Cloud resource. If the resource preference is DISABLED, the user will not receive any notification for the resource. Note that, you will still receive notifications for `REQUIRED` notification type even when it is DISABLED.") + pcmd.RegisterFlagCompletionFunc(cmd, "current-state", func(_ *cobra.Command, _ []string) []string { return []string{"ENABLED", "DISABLED"} }) + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *resourcePreferenceCommand) create(cmd *cobra.Command, args []string) error { + createReq := notificationsv1.NotificationsV1ResourcePreference{} + + resource, err := cmd.Flags().GetString("resource") + if err != nil { + return err + } + createReq.Resource = notificationsv1.PtrString(resource) + + resourceType, err := cmd.Flags().GetString("resource-type") + if err != nil { + return err + } + resourceType = strings.ToUpper(resourceType) + createReq.ResourceType = notificationsv1.PtrString(resourceType) + + currentState, err := cmd.Flags().GetString("current-state") + if err != nil { + return err + } + currentState = strings.ToUpper(currentState) + if currentState != "" { + createReq.CurrentState = notificationsv1.PtrString(currentState) + } + + resourcePreference, httpResp, err := c.V2Client.CreateNotificationsResourcePreference(createReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printResourcePreference(cmd, resourcePreference) +} diff --git a/internal/notifications/command_resource_preference_delete.go b/internal/notifications/command_resource_preference_delete.go new file mode 100644 index 0000000000..b6d4167bcd --- /dev/null +++ b/internal/notifications/command_resource_preference_delete.go @@ -0,0 +1,46 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/deletion" +) + +func (c *resourcePreferenceCommand) newDeleteCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete [id-2] ... [id-n]", + Short: "Delete one or more notifications resource preferences.", + Args: cobra.MinimumNArgs(1), + RunE: c.delete, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddForceFlag(cmd) + + return cmd +} + +func (c *resourcePreferenceCommand) delete(cmd *cobra.Command, args []string) error { + existenceFunc := func(primaryId string) bool { + _, _, err := c.V2Client.GetNotificationsResourcePreference(primaryId) + return err == nil + } + + if err := deletion.ValidateAndConfirm(cmd, args, existenceFunc, "notifications resource preference"); err != nil { + return err + } + + deleteFunc := func(primaryId string) error { + return c.V2Client.DeleteNotificationsResourcePreference(primaryId) + } + + _, err := deletion.Delete(cmd, args, deleteFunc, "notifications resource preference") + return err +} diff --git a/internal/notifications/command_resource_preference_describe.go b/internal/notifications/command_resource_preference_describe.go new file mode 100644 index 0000000000..9243744ac4 --- /dev/null +++ b/internal/notifications/command_resource_preference_describe.go @@ -0,0 +1,39 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *resourcePreferenceCommand) newDescribeCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "describe ", + Short: "Describe a notifications resource preference.", + Args: cobra.ExactArgs(1), + RunE: c.describe, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *resourcePreferenceCommand) describe(cmd *cobra.Command, args []string) error { + id := args[0] + + resourcePreference, httpResp, err := c.V2Client.GetNotificationsResourcePreference(id) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printResourcePreference(cmd, resourcePreference) +} diff --git a/internal/notifications/command_resource_preference_update.go b/internal/notifications/command_resource_preference_update.go new file mode 100644 index 0000000000..639b1d43b0 --- /dev/null +++ b/internal/notifications/command_resource_preference_update.go @@ -0,0 +1,82 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "strings" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *resourcePreferenceCommand) newUpdateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "update ", + Short: "Update an existing notifications resource preference.", + Args: cobra.ExactArgs(1), + RunE: c.update, + } + + // Required flags + + // Optional flags + cmd.Flags().String("resource", "", "Denotes the Confluent Cloud resource definition.") + cmd.Flags().String("resource-type", "", "Denotes the Confluent Cloud resource type.") + pcmd.RegisterFlagCompletionFunc(cmd, "resource-type", func(_ *cobra.Command, _ []string) []string { + return []string{"ORGANIZATION", "ENVIRONMENT", "CLUSTER", "CONNECTOR", "FLINK_COMPUTE_POOL", "FLINK_STATEMENT"} + }) + cmd.Flags().String("current-state", "", "Denotes the state of the resource preference. When the resource preference is ENABLED, the user will receive notifications for the Confluent Cloud resource. If the resource preference is DISABLED, the user will not receive any notification for the resource. Note that, you will still receive notifications for `REQUIRED` notification type even when it is DISABLED.") + pcmd.RegisterFlagCompletionFunc(cmd, "current-state", func(_ *cobra.Command, _ []string) []string { return []string{"ENABLED", "DISABLED"} }) + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *resourcePreferenceCommand) update(cmd *cobra.Command, args []string) error { + id := args[0] + + updateReq := notificationsv1.NotificationsV1ResourcePreference{} + + if cmd.Flags().Changed("resource") { + resource, err := cmd.Flags().GetString("resource") + if err != nil { + return err + } + updateReq.Resource = notificationsv1.PtrString(resource) + } + + if cmd.Flags().Changed("resource-type") { + resourceType, err := cmd.Flags().GetString("resource-type") + if err != nil { + return err + } + resourceType = strings.ToUpper(resourceType) + updateReq.ResourceType = notificationsv1.PtrString(resourceType) + } + + if cmd.Flags().Changed("current-state") { + currentState, err := cmd.Flags().GetString("current-state") + if err != nil { + return err + } + currentState = strings.ToUpper(currentState) + updateReq.CurrentState = notificationsv1.PtrString(currentState) + } + + resourcePreference, httpResp, err := c.V2Client.UpdateNotificationsResourcePreference(id, updateReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + if output.GetFormat(cmd) == output.Human { + output.Printf(c.Config.EnableColor, "Updated notifications resource preference \"%s\".\n", id) + } + return printResourcePreference(cmd, resourcePreference) +} diff --git a/internal/notifications/command_resource_subscription.go b/internal/notifications/command_resource_subscription.go new file mode 100644 index 0000000000..c9839613fd --- /dev/null +++ b/internal/notifications/command_resource_subscription.go @@ -0,0 +1,59 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/config" + "github.com/confluentinc/cli/v4/pkg/output" +) + +type resourceSubscriptionCommand struct { + *pcmd.AuthenticatedCLICommand +} + +type resourceSubscriptionOut struct { + ID string `human:"ID" serialized:"id"` + Resource string `human:"Resource" serialized:"resource"` + ResourceType string `human:"Resource Type" serialized:"resource_type"` + NotificationType string `human:"Notification Type" serialized:"notification_type"` + CurrentState string `human:"Current State" serialized:"current_state"` +} + +func newResourceSubscriptionCommand(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { //nolint:unparam + cmd := &cobra.Command{ + Use: "resource-subscription", + Short: "Manage Confluent Cloud notifications resource subscriptions.", + Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin}, + } + + c := &resourceSubscriptionCommand{ + AuthenticatedCLICommand: pcmd.NewAuthenticatedCLICommand(cmd, prerunner), + } + + cmd.AddCommand( + c.newCreateCommand(), + c.newDeleteCommand(), + c.newDescribeCommand(), + c.newUpdateCommand(), + ) + + return cmd +} + +func printResourceSubscription(cmd *cobra.Command, resourceSubscription notificationsv1.NotificationsV1ResourceSubscription) error { + table := output.NewTable(cmd) + out := &resourceSubscriptionOut{ + ID: resourceSubscription.GetId(), + Resource: resourceSubscription.GetResource(), + ResourceType: resourceSubscription.GetResourceType(), + NotificationType: resourceSubscription.NotificationType.GetId(), + CurrentState: resourceSubscription.GetCurrentState(), + } + table.Add(out) + return table.Print() +} diff --git a/internal/notifications/command_resource_subscription_create.go b/internal/notifications/command_resource_subscription_create.go new file mode 100644 index 0000000000..132d6351ac --- /dev/null +++ b/internal/notifications/command_resource_subscription_create.go @@ -0,0 +1,94 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "strings" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *resourceSubscriptionCommand) newCreateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "create", + Short: "Create a notifications resource subscription.", + Args: cobra.NoArgs, + RunE: c.create, + } + + // Required flags + cmd.Flags().String("resource", "", "Denotes the Confluent Cloud resource definition.") + cmd.Flags().String("resource-type", "", "Denotes the Confluent Cloud resource type.") + pcmd.RegisterFlagCompletionFunc(cmd, "resource-type", func(_ *cobra.Command, _ []string) []string { + return []string{"ENVIRONMENT", "CLUSTER", "CONNECTOR", "FLINK_COMPUTE_POOL", "FLINK_STATEMENT"} + }) + cmd.Flags().String("notification-type", "", "The type of notification to subscribe to.") + cmd.Flags().StringSlice("integrations", nil, "A comma-separated list of integration IDs to notify.") + cobra.CheckErr(cmd.MarkFlagRequired("integrations")) + cobra.CheckErr(cmd.MarkFlagRequired("notification-type")) + cobra.CheckErr(cmd.MarkFlagRequired("resource")) + cobra.CheckErr(cmd.MarkFlagRequired("resource-type")) + + // Optional flags + cmd.Flags().String("current-state", "", "Denotes the state of the resource subscription. When the resource subscription is ENABLED, the user will receive notifications of the configured notification type for the Confluent Cloud resource. If the resource subscription is DISABLED, the user will not receive them. Note that, you will still receive notifications for `REQUIRED` notification type even when it is DISABLED.") + pcmd.RegisterFlagCompletionFunc(cmd, "current-state", func(_ *cobra.Command, _ []string) []string { return []string{"ENABLED", "DISABLED"} }) + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *resourceSubscriptionCommand) create(cmd *cobra.Command, args []string) error { + createReq := notificationsv1.NotificationsV1ResourceSubscription{} + + resource, err := cmd.Flags().GetString("resource") + if err != nil { + return err + } + createReq.Resource = notificationsv1.PtrString(resource) + + resourceType, err := cmd.Flags().GetString("resource-type") + if err != nil { + return err + } + resourceType = strings.ToUpper(resourceType) + createReq.ResourceType = notificationsv1.PtrString(resourceType) + + currentState, err := cmd.Flags().GetString("current-state") + if err != nil { + return err + } + currentState = strings.ToUpper(currentState) + if currentState != "" { + createReq.CurrentState = notificationsv1.PtrString(currentState) + } + + notificationTypeId, err := cmd.Flags().GetString("notification-type") + if err != nil { + return err + } + createReq.NotificationType = ¬ificationsv1.GlobalObjectReference{Id: notificationTypeId, Related: "https://confluent.cloud/_", ResourceName: "https://confluent.cloud/_"} + + integrations, err := cmd.Flags().GetStringSlice("integrations") + if err != nil { + return err + } + integrationsRefs := make([]notificationsv1.GlobalObjectReference, len(integrations)) + for i, id := range integrations { + integrationsRefs[i] = notificationsv1.GlobalObjectReference{Id: id, Related: "https://confluent.cloud/_", ResourceName: "https://confluent.cloud/_"} + } + createReq.Integrations = &integrationsRefs + + resourceSubscription, httpResp, err := c.V2Client.CreateNotificationsResourceSubscription(createReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printResourceSubscription(cmd, resourceSubscription) +} diff --git a/internal/notifications/command_resource_subscription_delete.go b/internal/notifications/command_resource_subscription_delete.go new file mode 100644 index 0000000000..472e4694ed --- /dev/null +++ b/internal/notifications/command_resource_subscription_delete.go @@ -0,0 +1,46 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/deletion" +) + +func (c *resourceSubscriptionCommand) newDeleteCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete [id-2] ... [id-n]", + Short: "Delete one or more notifications resource subscriptions.", + Args: cobra.MinimumNArgs(1), + RunE: c.delete, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddForceFlag(cmd) + + return cmd +} + +func (c *resourceSubscriptionCommand) delete(cmd *cobra.Command, args []string) error { + existenceFunc := func(primaryId string) bool { + _, _, err := c.V2Client.GetNotificationsResourceSubscription(primaryId) + return err == nil + } + + if err := deletion.ValidateAndConfirm(cmd, args, existenceFunc, "notifications resource subscription"); err != nil { + return err + } + + deleteFunc := func(primaryId string) error { + return c.V2Client.DeleteNotificationsResourceSubscription(primaryId) + } + + _, err := deletion.Delete(cmd, args, deleteFunc, "notifications resource subscription") + return err +} diff --git a/internal/notifications/command_resource_subscription_describe.go b/internal/notifications/command_resource_subscription_describe.go new file mode 100644 index 0000000000..b010f3a9b1 --- /dev/null +++ b/internal/notifications/command_resource_subscription_describe.go @@ -0,0 +1,39 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *resourceSubscriptionCommand) newDescribeCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "describe ", + Short: "Describe a notifications resource subscription.", + Args: cobra.ExactArgs(1), + RunE: c.describe, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *resourceSubscriptionCommand) describe(cmd *cobra.Command, args []string) error { + id := args[0] + + resourceSubscription, httpResp, err := c.V2Client.GetNotificationsResourceSubscription(id) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printResourceSubscription(cmd, resourceSubscription) +} diff --git a/internal/notifications/command_resource_subscription_update.go b/internal/notifications/command_resource_subscription_update.go new file mode 100644 index 0000000000..e605382e41 --- /dev/null +++ b/internal/notifications/command_resource_subscription_update.go @@ -0,0 +1,95 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "strings" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *resourceSubscriptionCommand) newUpdateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "update ", + Short: "Update an existing notifications resource subscription.", + Args: cobra.ExactArgs(1), + RunE: c.update, + } + + // Required flags + + // Optional flags + cmd.Flags().String("resource", "", "Denotes the Confluent Cloud resource definition.") + cmd.Flags().String("resource-type", "", "Denotes the Confluent Cloud resource type.") + pcmd.RegisterFlagCompletionFunc(cmd, "resource-type", func(_ *cobra.Command, _ []string) []string { + return []string{"ENVIRONMENT", "CLUSTER", "CONNECTOR", "FLINK_COMPUTE_POOL", "FLINK_STATEMENT"} + }) + cmd.Flags().String("current-state", "", "Denotes the state of the resource subscription. When the resource subscription is ENABLED, the user will receive notifications of the configured notification type for the Confluent Cloud resource. If the resource subscription is DISABLED, the user will not receive them. Note that, you will still receive notifications for `REQUIRED` notification type even when it is DISABLED.") + pcmd.RegisterFlagCompletionFunc(cmd, "current-state", func(_ *cobra.Command, _ []string) []string { return []string{"ENABLED", "DISABLED"} }) + cmd.Flags().StringSlice("integrations", nil, "A comma-separated list of integration IDs to notify.") + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *resourceSubscriptionCommand) update(cmd *cobra.Command, args []string) error { + id := args[0] + + updateReq := notificationsv1.NotificationsV1ResourceSubscriptionUpdate{} + + if cmd.Flags().Changed("resource") { + resource, err := cmd.Flags().GetString("resource") + if err != nil { + return err + } + updateReq.Resource = notificationsv1.PtrString(resource) + } + + if cmd.Flags().Changed("resource-type") { + resourceType, err := cmd.Flags().GetString("resource-type") + if err != nil { + return err + } + resourceType = strings.ToUpper(resourceType) + updateReq.ResourceType = notificationsv1.PtrString(resourceType) + } + + if cmd.Flags().Changed("current-state") { + currentState, err := cmd.Flags().GetString("current-state") + if err != nil { + return err + } + currentState = strings.ToUpper(currentState) + updateReq.CurrentState = notificationsv1.PtrString(currentState) + } + + integrations, err := cmd.Flags().GetStringSlice("integrations") + if err != nil { + return err + } + if len(integrations) > 0 { + integrationsRefs := make([]notificationsv1.GlobalObjectReference, len(integrations)) + for i, id := range integrations { + integrationsRefs[i] = notificationsv1.GlobalObjectReference{Id: id, Related: "https://confluent.cloud/_", ResourceName: "https://confluent.cloud/_"} + } + updateReq.Integrations = &integrationsRefs + } + + resourceSubscription, httpResp, err := c.V2Client.UpdateNotificationsResourceSubscription(id, updateReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + if output.GetFormat(cmd) == output.Human { + output.Printf(c.Config.EnableColor, "Updated notifications resource subscription \"%s\".\n", id) + } + return printResourceSubscription(cmd, resourceSubscription) +} diff --git a/internal/notifications/command_subscription.go b/internal/notifications/command_subscription.go new file mode 100644 index 0000000000..982c578409 --- /dev/null +++ b/internal/notifications/command_subscription.go @@ -0,0 +1,85 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/config" + "github.com/confluentinc/cli/v4/pkg/output" +) + +type subscriptionCommand struct { + *pcmd.AuthenticatedCLICommand +} + +type subscriptionOut struct { + ID string `human:"ID" serialized:"id"` + NotificationType string `human:"Notification Type" serialized:"notification_type"` + CurrentState string `human:"Current State" serialized:"current_state"` +} + +func newSubscriptionCommand(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { //nolint:unparam + cmd := &cobra.Command{ + Use: "subscription", + Short: "Manage Confluent Cloud notifications subscriptions.", + Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin}, + } + + c := &subscriptionCommand{ + AuthenticatedCLICommand: pcmd.NewAuthenticatedCLICommand(cmd, prerunner), + } + + cmd.AddCommand( + c.newCreateCommand(), + c.newDeleteCommand(), + c.newDescribeCommand(), + c.newListCommand(), + c.newUpdateCommand(), + ) + + return cmd +} + +func printSubscription(cmd *cobra.Command, subscription notificationsv1.NotificationsV1Subscription) error { + table := output.NewTable(cmd) + out := &subscriptionOut{ + ID: subscription.GetId(), + NotificationType: subscription.NotificationType.GetId(), + CurrentState: subscription.GetCurrentState(), + } + table.Add(out) + return table.Print() +} + +func (c *subscriptionCommand) validArgs(cmd *cobra.Command, args []string) []string { + if len(args) > 0 { + return nil + } + + return c.validArgsMultiple(cmd, args) +} + +func (c *subscriptionCommand) validArgsMultiple(cmd *cobra.Command, args []string) []string { + if err := c.PersistentPreRunE(cmd, args); err != nil { + return nil + } + + return c.autocompleteSubscriptions() +} + +func (c *subscriptionCommand) autocompleteSubscriptions() []string { + subscriptions, err := c.V2Client.ListNotificationsSubscriptions() + if err != nil { + return nil + } + + suggestions := make([]string, len(subscriptions)) + for i, subscription := range subscriptions { + suggestions[i] = subscription.GetId() + } + return suggestions +} diff --git a/internal/notifications/command_subscription_create.go b/internal/notifications/command_subscription_create.go new file mode 100644 index 0000000000..3d12892e83 --- /dev/null +++ b/internal/notifications/command_subscription_create.go @@ -0,0 +1,74 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "strings" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *subscriptionCommand) newCreateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "create", + Short: "Create a notifications subscription.", + Args: cobra.NoArgs, + RunE: c.create, + } + + // Required flags + cmd.Flags().String("notification-type", "", "The type of notification to subscribe to.") + cmd.Flags().StringSlice("integrations", nil, "A comma-separated list of integration IDs to notify.") + cobra.CheckErr(cmd.MarkFlagRequired("integrations")) + cobra.CheckErr(cmd.MarkFlagRequired("notification-type")) + + // Optional flags + cmd.Flags().String("current-state", "", "Denotes the state of the subscription. When the subscription is ENABLED, the user will receive notification on the configured integrations. If the subscription is DISABLED, the user will not receive any notification for the configured notification type. Note that, you cannot disable a subscription for `REQUIRED` notification type.") + pcmd.RegisterFlagCompletionFunc(cmd, "current-state", func(_ *cobra.Command, _ []string) []string { return []string{"ENABLED", "DISABLED"} }) + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *subscriptionCommand) create(cmd *cobra.Command, args []string) error { + createReq := notificationsv1.NotificationsV1Subscription{} + + currentState, err := cmd.Flags().GetString("current-state") + if err != nil { + return err + } + currentState = strings.ToUpper(currentState) + if currentState != "" { + createReq.CurrentState = notificationsv1.PtrString(currentState) + } + + notificationTypeId, err := cmd.Flags().GetString("notification-type") + if err != nil { + return err + } + createReq.NotificationType = ¬ificationsv1.GlobalObjectReference{Id: notificationTypeId, Related: "https://confluent.cloud/_", ResourceName: "https://confluent.cloud/_"} + + integrations, err := cmd.Flags().GetStringSlice("integrations") + if err != nil { + return err + } + integrationsRefs := make([]notificationsv1.GlobalObjectReference, len(integrations)) + for i, id := range integrations { + integrationsRefs[i] = notificationsv1.GlobalObjectReference{Id: id, Related: "https://confluent.cloud/_", ResourceName: "https://confluent.cloud/_"} + } + createReq.Integrations = &integrationsRefs + + subscription, httpResp, err := c.V2Client.CreateNotificationsSubscription(createReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printSubscription(cmd, subscription) +} diff --git a/internal/notifications/command_subscription_delete.go b/internal/notifications/command_subscription_delete.go new file mode 100644 index 0000000000..353fcbd0fe --- /dev/null +++ b/internal/notifications/command_subscription_delete.go @@ -0,0 +1,47 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/deletion" +) + +func (c *subscriptionCommand) newDeleteCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete [id-2] ... [id-n]", + Short: "Delete one or more notifications subscriptions.", + 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 *subscriptionCommand) delete(cmd *cobra.Command, args []string) error { + existenceFunc := func(primaryId string) bool { + _, _, err := c.V2Client.GetNotificationsSubscription(primaryId) + return err == nil + } + + if err := deletion.ValidateAndConfirm(cmd, args, existenceFunc, "notifications subscription"); err != nil { + return err + } + + deleteFunc := func(primaryId string) error { + return c.V2Client.DeleteNotificationsSubscription(primaryId) + } + + _, err := deletion.Delete(cmd, args, deleteFunc, "notifications subscription") + return err +} diff --git a/internal/notifications/command_subscription_describe.go b/internal/notifications/command_subscription_describe.go new file mode 100644 index 0000000000..886fee33c3 --- /dev/null +++ b/internal/notifications/command_subscription_describe.go @@ -0,0 +1,40 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *subscriptionCommand) newDescribeCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "describe ", + Short: "Describe a notifications subscription.", + Args: cobra.ExactArgs(1), + ValidArgsFunction: pcmd.NewValidArgsFunction(c.validArgs), + RunE: c.describe, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *subscriptionCommand) describe(cmd *cobra.Command, args []string) error { + id := args[0] + + subscription, httpResp, err := c.V2Client.GetNotificationsSubscription(id) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printSubscription(cmd, subscription) +} diff --git a/internal/notifications/command_subscription_list.go b/internal/notifications/command_subscription_list.go new file mode 100644 index 0000000000..42fe5f390a --- /dev/null +++ b/internal/notifications/command_subscription_list.go @@ -0,0 +1,46 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *subscriptionCommand) newListCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "List notifications subscriptions.", + Args: cobra.NoArgs, + RunE: c.list, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *subscriptionCommand) list(cmd *cobra.Command, _ []string) error { + subscriptions, err := c.V2Client.ListNotificationsSubscriptions() + if err != nil { + return err + } + + list := output.NewList(cmd) + for _, subscription := range subscriptions { + out := &subscriptionOut{ + ID: subscription.GetId(), + NotificationType: subscription.NotificationType.GetId(), + CurrentState: subscription.GetCurrentState(), + } + list.Add(out) + } + return list.Print() +} diff --git a/internal/notifications/command_subscription_update.go b/internal/notifications/command_subscription_update.go new file mode 100644 index 0000000000..034e4dedca --- /dev/null +++ b/internal/notifications/command_subscription_update.go @@ -0,0 +1,74 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package notifications + +import ( + "strings" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *subscriptionCommand) newUpdateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "update ", + Short: "Update an existing notifications subscription.", + Args: cobra.ExactArgs(1), + ValidArgsFunction: pcmd.NewValidArgsFunction(c.validArgs), + RunE: c.update, + } + + // Required flags + + // Optional flags + cmd.Flags().String("current-state", "", "Denotes the state of the subscription. When the subscription is ENABLED, the user will receive notification on the configured integrations. If the subscription is DISABLED, the user will not receive any notification for the configured notification type. Note that, you cannot disable a subscription for `REQUIRED` notification type.") + pcmd.RegisterFlagCompletionFunc(cmd, "current-state", func(_ *cobra.Command, _ []string) []string { return []string{"ENABLED", "DISABLED"} }) + cmd.Flags().StringSlice("integrations", nil, "A comma-separated list of integration IDs to notify.") + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *subscriptionCommand) update(cmd *cobra.Command, args []string) error { + id := args[0] + + updateReq := notificationsv1.NotificationsV1SubscriptionUpdate{} + + if cmd.Flags().Changed("current-state") { + currentState, err := cmd.Flags().GetString("current-state") + if err != nil { + return err + } + currentState = strings.ToUpper(currentState) + updateReq.CurrentState = notificationsv1.PtrString(currentState) + } + + integrations, err := cmd.Flags().GetStringSlice("integrations") + if err != nil { + return err + } + if len(integrations) > 0 { + integrationsRefs := make([]notificationsv1.GlobalObjectReference, len(integrations)) + for i, id := range integrations { + integrationsRefs[i] = notificationsv1.GlobalObjectReference{Id: id, Related: "https://confluent.cloud/_", ResourceName: "https://confluent.cloud/_"} + } + updateReq.Integrations = &integrationsRefs + } + + subscription, httpResp, err := c.V2Client.UpdateNotificationsSubscription(id, updateReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + if output.GetFormat(cmd) == output.Human { + output.Printf(c.Config.EnableColor, "Updated notifications subscription \"%s\".\n", id) + } + return printSubscription(cmd, subscription) +} diff --git a/internal/notifications/command_user_notification.go b/internal/notifications/command_user_notification.go new file mode 100644 index 0000000000..cc635aae32 --- /dev/null +++ b/internal/notifications/command_user_notification.go @@ -0,0 +1,89 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "time" + + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/config" + "github.com/confluentinc/cli/v4/pkg/output" +) + +type userNotificationCommand struct { + *pcmd.AuthenticatedCLICommand +} + +type userNotificationOut struct { + ID string `human:"ID" serialized:"id"` + ReadAt string `human:"Read At" serialized:"read_at"` + Severity string `human:"Severity" serialized:"severity"` + ReceivedAt string `human:"Received At" serialized:"received_at"` + Read bool `human:"Read" serialized:"read"` +} + +func newUserNotificationCommand(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { //nolint:unparam + cmd := &cobra.Command{ + Use: "user-notification", + Short: "Manage Confluent Cloud notifications user notifications.", + Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin}, + } + + c := &userNotificationCommand{ + AuthenticatedCLICommand: pcmd.NewAuthenticatedCLICommand(cmd, prerunner), + } + + cmd.AddCommand( + c.newDescribeCommand(), + c.newListCommand(), + c.newUpdateCommand(), + ) + + return cmd +} + +func printUserNotification(cmd *cobra.Command, userNotification notificationsv1.NotificationsV1UserNotification) error { + table := output.NewTable(cmd) + out := &userNotificationOut{ + ID: userNotification.GetId(), + ReadAt: userNotification.GetReadAt().Format(time.RFC3339), + Severity: userNotification.GetSeverity(), + ReceivedAt: userNotification.GetReceivedAt().Format(time.RFC3339), + Read: userNotification.GetRead(), + } + table.Add(out) + return table.Print() +} + +func (c *userNotificationCommand) validArgs(cmd *cobra.Command, args []string) []string { + if len(args) > 0 { + return nil + } + + return c.validArgsMultiple(cmd, args) +} + +func (c *userNotificationCommand) validArgsMultiple(cmd *cobra.Command, args []string) []string { + if err := c.PersistentPreRunE(cmd, args); err != nil { + return nil + } + + return c.autocompleteUserNotifications() +} + +func (c *userNotificationCommand) autocompleteUserNotifications() []string { + userNotifications, err := c.V2Client.ListNotificationsUserNotifications(nil, nil, "", nil, nil, "", "", nil) + if err != nil { + return nil + } + + suggestions := make([]string, len(userNotifications)) + for i, userNotification := range userNotifications { + suggestions[i] = userNotification.GetId() + } + return suggestions +} diff --git a/internal/notifications/command_user_notification_describe.go b/internal/notifications/command_user_notification_describe.go new file mode 100644 index 0000000000..2f530e25dc --- /dev/null +++ b/internal/notifications/command_user_notification_describe.go @@ -0,0 +1,40 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" +) + +func (c *userNotificationCommand) newDescribeCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "describe ", + Short: "Describe a notifications user notification.", + Args: cobra.ExactArgs(1), + ValidArgsFunction: pcmd.NewValidArgsFunction(c.validArgs), + RunE: c.describe, + } + + // Required flags + + // Optional flags + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *userNotificationCommand) describe(cmd *cobra.Command, args []string) error { + id := args[0] + + userNotification, httpResp, err := c.V2Client.GetNotificationsUserNotification(id) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + return printUserNotification(cmd, userNotification) +} diff --git a/internal/notifications/command_user_notification_list.go b/internal/notifications/command_user_notification_list.go new file mode 100644 index 0000000000..4a27befaa7 --- /dev/null +++ b/internal/notifications/command_user_notification_list.go @@ -0,0 +1,102 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "time" + + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *userNotificationCommand) newListCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "List notifications user notifications.", + Args: cobra.NoArgs, + RunE: c.list, + } + + // Required flags + + // Optional flags + cmd.Flags().Bool("read", false, "Filter the results where read is true or false.") + cmd.Flags().StringSlice("severity", nil, "A comma-separated list of severity levels to filter by.") + cmd.Flags().String("include", "", "Comma-separated list of optional fields to populate in the response items. Allowed values: `integrations`, `recommended_actions`. By default these fields are omitted from list responses to keep collection payloads slim; set this parameter to opt in. This is a partial-response selector, not a value filter.") + cmd.Flags().StringSlice("type", nil, "A comma-separated list of Confluent Cloud resource types to filter by.") + cmd.Flags().StringSlice("crn", nil, "A comma-separated list of Confluent Cloud resource CRNs to filter by.") + cmd.Flags().String("search", "", "Free-text partial-match search across the embedded notification type's `display_name` and `description`.") + cmd.Flags().String("time-range", "", "Filter notifications by a preset time window relative to now. Allowed values: `PAST_24H` (last 24 hours), `PAST_7D` (last 7 days), `PAST_30D` (last 30 days).") + cmd.Flags().StringSlice("sort", nil, "A comma-separated list of fields and directions to sort by.") + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *userNotificationCommand) list(cmd *cobra.Command, _ []string) error { + var read *bool + if cmd.Flags().Changed("read") { + v, err := cmd.Flags().GetBool("read") + if err != nil { + return err + } + read = &v + } + + severity, err := cmd.Flags().GetStringSlice("severity") + if err != nil { + return err + } + + include, err := cmd.Flags().GetString("include") + if err != nil { + return err + } + + typeValue, err := cmd.Flags().GetStringSlice("type") + if err != nil { + return err + } + + crn, err := cmd.Flags().GetStringSlice("crn") + if err != nil { + return err + } + + search, err := cmd.Flags().GetString("search") + if err != nil { + return err + } + + timeRange, err := cmd.Flags().GetString("time-range") + if err != nil { + return err + } + + sort, err := cmd.Flags().GetStringSlice("sort") + if err != nil { + return err + } + + userNotifications, err := c.V2Client.ListNotificationsUserNotifications(read, severity, include, typeValue, crn, search, timeRange, sort) + if err != nil { + return err + } + + list := output.NewList(cmd) + for _, userNotification := range userNotifications { + out := &userNotificationOut{ + ID: userNotification.GetId(), + ReadAt: userNotification.GetReadAt().Format(time.RFC3339), + Severity: userNotification.GetSeverity(), + ReceivedAt: userNotification.GetReceivedAt().Format(time.RFC3339), + Read: userNotification.GetRead(), + } + list.Add(out) + } + return list.Print() +} diff --git a/internal/notifications/command_user_notification_update.go b/internal/notifications/command_user_notification_update.go new file mode 100644 index 0000000000..a572c2239e --- /dev/null +++ b/internal/notifications/command_user_notification_update.go @@ -0,0 +1,57 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package notifications + +import ( + "github.com/spf13/cobra" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *userNotificationCommand) newUpdateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "update ", + Short: "Update an existing notifications user notification.", + Args: cobra.ExactArgs(1), + ValidArgsFunction: pcmd.NewValidArgsFunction(c.validArgs), + RunE: c.update, + } + + // Required flags + + // Optional flags + cmd.Flags().Bool("read", false, "Whether the notification has been read by the user.") + + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *userNotificationCommand) update(cmd *cobra.Command, args []string) error { + id := args[0] + + updateReq := notificationsv1.NotificationsV1UserNotification{} + + if cmd.Flags().Changed("read") { + read, err := cmd.Flags().GetBool("read") + if err != nil { + return err + } + updateReq.Read = notificationsv1.PtrBool(read) + } + + userNotification, httpResp, err := c.V2Client.UpdateNotificationsUserNotification(id, updateReq) + if err != nil { + return errors.CatchCCloudV2Error(err, httpResp) + } + + if output.GetFormat(cmd) == output.Human { + output.Printf(c.Config.EnableColor, "Updated notifications user notification \"%s\".\n", id) + } + return printUserNotification(cmd, userNotification) +} diff --git a/pkg/ccloudv2/client.go b/pkg/ccloudv2/client.go index a736857f5b..d49831ceca 100644 --- a/pkg/ccloudv2/client.go +++ b/pkg/ccloudv2/client.go @@ -28,6 +28,7 @@ import ( networkingipv1 "github.com/confluentinc/ccloud-sdk-go-v2/networking-ip/v1" networkingprivatelinkv1 "github.com/confluentinc/ccloud-sdk-go-v2/networking-privatelink/v1" networkingv1 "github.com/confluentinc/ccloud-sdk-go-v2/networking/v1" + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" orgv2 "github.com/confluentinc/ccloud-sdk-go-v2/org/v2" pi "github.com/confluentinc/ccloud-sdk-go-v2/provider-integration/v1" piv2 "github.com/confluentinc/ccloud-sdk-go-v2/provider-integration/v2" @@ -73,6 +74,7 @@ type Client struct { NetworkingGatewayClient *networkinggatewayv1.APIClient NetworkingIpClient *networkingipv1.APIClient NetworkingPrivateLinkClient *networkingprivatelinkv1.APIClient + NotificationsClient *notificationsv1.APIClient OrgClient *orgv2.APIClient ProviderIntegrationClient *pi.APIClient ProviderIntegrationV2Client *piv2.APIClient @@ -125,6 +127,7 @@ func NewClient(cfg *config.Config, unsafeTrace bool) *Client { NetworkingGatewayClient: newNetworkingGatewayClient(httpClient, url, userAgent, unsafeTrace), NetworkingIpClient: newNetworkingIpClient(httpClient, url, userAgent, unsafeTrace), NetworkingPrivateLinkClient: newNetworkingPrivateLinkClient(httpClient, url, userAgent, unsafeTrace), + NotificationsClient: newNotificationsClient(httpClient, url, userAgent, unsafeTrace), OrgClient: newOrgClient(httpClient, url, userAgent, unsafeTrace), ProviderIntegrationClient: newProviderIntegrationClient(httpClient, url, userAgent, unsafeTrace), ProviderIntegrationV2Client: newProviderIntegrationV2Client(httpClient, url, userAgent, unsafeTrace), diff --git a/pkg/ccloudv2/notifications.go b/pkg/ccloudv2/notifications.go new file mode 100644 index 0000000000..64e47c3cde --- /dev/null +++ b/pkg/ccloudv2/notifications.go @@ -0,0 +1,318 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package ccloudv2 + +import ( + "context" + "net/http" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" + + "github.com/confluentinc/cli/v4/pkg/errors" +) + +// ===== API group client bootstrap ===== + +func newNotificationsClient(httpClient *http.Client, url, userAgent string, unsafeTrace bool) *notificationsv1.APIClient { + cfg := notificationsv1.NewConfiguration() + cfg.Debug = unsafeTrace + cfg.HTTPClient = httpClient + cfg.Servers = notificationsv1.ServerConfigurations{{URL: url}} + cfg.UserAgent = userAgent + + return notificationsv1.NewAPIClient(cfg) +} + +func (c *Client) notificationsApiContext() context.Context { + return context.WithValue(context.Background(), notificationsv1.ContextAccessToken, c.cfg.Context().GetAuthToken()) +} + +// ===== notifications integrations API calls ===== + +func (c *Client) CreateNotificationsIntegration(req notificationsv1.NotificationsV1Integration) (notificationsv1.NotificationsV1Integration, *http.Response, error) { + createReq := c.NotificationsClient.IntegrationsNotificationsV1Api. + CreateNotificationsV1Integration(c.notificationsApiContext()). + NotificationsV1Integration(req) + return createReq.Execute() +} + +func (c *Client) GetNotificationsIntegration(id string) (notificationsv1.NotificationsV1Integration, *http.Response, error) { + getReq := c.NotificationsClient.IntegrationsNotificationsV1Api. + GetNotificationsV1Integration(c.notificationsApiContext(), id) + return getReq.Execute() +} + +func (c *Client) UpdateNotificationsIntegration(id string, update notificationsv1.NotificationsV1Integration) (notificationsv1.NotificationsV1Integration, *http.Response, error) { + updateReq := c.NotificationsClient.IntegrationsNotificationsV1Api. + UpdateNotificationsV1Integration(c.notificationsApiContext(), id). + NotificationsV1Integration(update) + return updateReq.Execute() +} + +func (c *Client) DeleteNotificationsIntegration(id string) error { + deleteReq := c.NotificationsClient.IntegrationsNotificationsV1Api. + DeleteNotificationsV1Integration(c.notificationsApiContext(), id) + httpResp, err := deleteReq.Execute() + return errors.CatchCCloudV2Error(err, httpResp) +} + +func (c *Client) ListNotificationsIntegrations() ([]notificationsv1.NotificationsV1Integration, error) { + var list []notificationsv1.NotificationsV1Integration + + done := false + pageToken := "" + for !done { + page, httpResp, err := c.executeListNotificationsIntegrations(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) executeListNotificationsIntegrations(pageToken string) (notificationsv1.NotificationsV1IntegrationList, *http.Response, error) { + req := c.NotificationsClient.IntegrationsNotificationsV1Api. + ListNotificationsV1Integrations(c.notificationsApiContext()). + PageSize(ccloudV2ListPageSize) + if pageToken != "" { + req = req.PageToken(pageToken) + } + return req.Execute() +} + +// ===== notifications notification types API calls ===== + +func (c *Client) GetNotificationsNotificationType(id string) (notificationsv1.NotificationsV1NotificationType, *http.Response, error) { + getReq := c.NotificationsClient.NotificationTypesNotificationsV1Api. + GetNotificationsV1NotificationType(c.notificationsApiContext(), id) + return getReq.Execute() +} + +func (c *Client) ListNotificationsNotificationTypes(resourceType string) ([]notificationsv1.NotificationsV1NotificationType, error) { + var list []notificationsv1.NotificationsV1NotificationType + + done := false + pageToken := "" + for !done { + page, httpResp, err := c.executeListNotificationsNotificationTypes(resourceType, 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) executeListNotificationsNotificationTypes(resourceType string, pageToken string) (notificationsv1.NotificationsV1NotificationTypeList, *http.Response, error) { + req := c.NotificationsClient.NotificationTypesNotificationsV1Api. + ListNotificationsV1NotificationTypes(c.notificationsApiContext()). + PageSize(ccloudV2ListPageSize) + if resourceType != "" { + req = req.ResourceType(resourceType) + } + if pageToken != "" { + req = req.PageToken(pageToken) + } + return req.Execute() +} + +// ===== notifications resource preferences API calls ===== + +func (c *Client) CreateNotificationsResourcePreference(req notificationsv1.NotificationsV1ResourcePreference) (notificationsv1.NotificationsV1ResourcePreference, *http.Response, error) { + createReq := c.NotificationsClient.ResourcePreferencesNotificationsV1Api. + CreateNotificationsV1ResourcePreference(c.notificationsApiContext()). + NotificationsV1ResourcePreference(req) + return createReq.Execute() +} + +func (c *Client) GetNotificationsResourcePreference(id string) (notificationsv1.NotificationsV1ResourcePreference, *http.Response, error) { + getReq := c.NotificationsClient.ResourcePreferencesNotificationsV1Api. + GetNotificationsV1ResourcePreference(c.notificationsApiContext(), id) + return getReq.Execute() +} + +func (c *Client) UpdateNotificationsResourcePreference(id string, update notificationsv1.NotificationsV1ResourcePreference) (notificationsv1.NotificationsV1ResourcePreference, *http.Response, error) { + updateReq := c.NotificationsClient.ResourcePreferencesNotificationsV1Api. + UpdateNotificationsV1ResourcePreference(c.notificationsApiContext(), id). + NotificationsV1ResourcePreference(update) + return updateReq.Execute() +} + +func (c *Client) DeleteNotificationsResourcePreference(id string) error { + deleteReq := c.NotificationsClient.ResourcePreferencesNotificationsV1Api. + DeleteNotificationsV1ResourcePreference(c.notificationsApiContext(), id) + httpResp, err := deleteReq.Execute() + return errors.CatchCCloudV2Error(err, httpResp) +} + +// ===== notifications resource subscriptions API calls ===== + +func (c *Client) CreateNotificationsResourceSubscription(req notificationsv1.NotificationsV1ResourceSubscription) (notificationsv1.NotificationsV1ResourceSubscription, *http.Response, error) { + createReq := c.NotificationsClient.ResourceSubscriptionsNotificationsV1Api. + CreateNotificationsV1ResourceSubscription(c.notificationsApiContext()). + NotificationsV1ResourceSubscription(req) + return createReq.Execute() +} + +func (c *Client) GetNotificationsResourceSubscription(id string) (notificationsv1.NotificationsV1ResourceSubscription, *http.Response, error) { + getReq := c.NotificationsClient.ResourceSubscriptionsNotificationsV1Api. + GetNotificationsV1ResourceSubscription(c.notificationsApiContext(), id) + return getReq.Execute() +} + +func (c *Client) UpdateNotificationsResourceSubscription(id string, update notificationsv1.NotificationsV1ResourceSubscriptionUpdate) (notificationsv1.NotificationsV1ResourceSubscription, *http.Response, error) { + updateReq := c.NotificationsClient.ResourceSubscriptionsNotificationsV1Api. + UpdateNotificationsV1ResourceSubscription(c.notificationsApiContext(), id). + NotificationsV1ResourceSubscriptionUpdate(update) + return updateReq.Execute() +} + +func (c *Client) DeleteNotificationsResourceSubscription(id string) error { + deleteReq := c.NotificationsClient.ResourceSubscriptionsNotificationsV1Api. + DeleteNotificationsV1ResourceSubscription(c.notificationsApiContext(), id) + httpResp, err := deleteReq.Execute() + return errors.CatchCCloudV2Error(err, httpResp) +} + +// ===== notifications subscriptions API calls ===== + +func (c *Client) CreateNotificationsSubscription(req notificationsv1.NotificationsV1Subscription) (notificationsv1.NotificationsV1Subscription, *http.Response, error) { + createReq := c.NotificationsClient.SubscriptionsNotificationsV1Api. + CreateNotificationsV1Subscription(c.notificationsApiContext()). + NotificationsV1Subscription(req) + return createReq.Execute() +} + +func (c *Client) GetNotificationsSubscription(id string) (notificationsv1.NotificationsV1Subscription, *http.Response, error) { + getReq := c.NotificationsClient.SubscriptionsNotificationsV1Api. + GetNotificationsV1Subscription(c.notificationsApiContext(), id) + return getReq.Execute() +} + +func (c *Client) UpdateNotificationsSubscription(id string, update notificationsv1.NotificationsV1SubscriptionUpdate) (notificationsv1.NotificationsV1Subscription, *http.Response, error) { + updateReq := c.NotificationsClient.SubscriptionsNotificationsV1Api. + UpdateNotificationsV1Subscription(c.notificationsApiContext(), id). + NotificationsV1SubscriptionUpdate(update) + return updateReq.Execute() +} + +func (c *Client) DeleteNotificationsSubscription(id string) error { + deleteReq := c.NotificationsClient.SubscriptionsNotificationsV1Api. + DeleteNotificationsV1Subscription(c.notificationsApiContext(), id) + httpResp, err := deleteReq.Execute() + return errors.CatchCCloudV2Error(err, httpResp) +} + +func (c *Client) ListNotificationsSubscriptions() ([]notificationsv1.NotificationsV1Subscription, error) { + var list []notificationsv1.NotificationsV1Subscription + + done := false + pageToken := "" + for !done { + page, httpResp, err := c.executeListNotificationsSubscriptions(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) executeListNotificationsSubscriptions(pageToken string) (notificationsv1.NotificationsV1SubscriptionList, *http.Response, error) { + req := c.NotificationsClient.SubscriptionsNotificationsV1Api. + ListNotificationsV1Subscriptions(c.notificationsApiContext()). + PageSize(ccloudV2ListPageSize) + if pageToken != "" { + req = req.PageToken(pageToken) + } + return req.Execute() +} + +// ===== notifications user notifications API calls ===== + +func (c *Client) GetNotificationsUserNotification(id string) (notificationsv1.NotificationsV1UserNotification, *http.Response, error) { + getReq := c.NotificationsClient.UserNotificationsNotificationsV1Api. + GetNotificationsV1UserNotification(c.notificationsApiContext(), id) + return getReq.Execute() +} + +func (c *Client) UpdateNotificationsUserNotification(id string, update notificationsv1.NotificationsV1UserNotification) (notificationsv1.NotificationsV1UserNotification, *http.Response, error) { + updateReq := c.NotificationsClient.UserNotificationsNotificationsV1Api. + UpdateNotificationsV1UserNotification(c.notificationsApiContext(), id). + NotificationsV1UserNotification(update) + return updateReq.Execute() +} + +func (c *Client) ListNotificationsUserNotifications(read *bool, severity []string, include string, resourceType []string, resourceCrn []string, search string, timeRange string, sort []string) ([]notificationsv1.NotificationsV1UserNotification, error) { + var list []notificationsv1.NotificationsV1UserNotification + + done := false + pageToken := "" + for !done { + page, httpResp, err := c.executeListNotificationsUserNotifications(read, severity, include, resourceType, resourceCrn, search, timeRange, sort, 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) executeListNotificationsUserNotifications(read *bool, severity []string, include string, resourceType []string, resourceCrn []string, search string, timeRange string, sort []string, pageToken string) (notificationsv1.NotificationsV1UserNotificationList, *http.Response, error) { + req := c.NotificationsClient.UserNotificationsNotificationsV1Api. + ListNotificationsV1UserNotifications(c.notificationsApiContext()). + PageSize(ccloudV2ListPageSize) + if read != nil { + req = req.Read(*read) + } + if len(severity) > 0 { + req = req.Severity(notificationsv1.MultipleSearchFilter{Items: severity}) + } + if include != "" { + req = req.Include(include) + } + if len(resourceType) > 0 { + req = req.ResourceType(notificationsv1.MultipleSearchFilter{Items: resourceType}) + } + if len(resourceCrn) > 0 { + req = req.ResourceCrn(notificationsv1.MultipleSearchFilter{Items: resourceCrn}) + } + if search != "" { + req = req.Search(search) + } + if timeRange != "" { + req = req.TimeRange(timeRange) + } + if len(sort) > 0 { + req = req.Sort(sort) + } + if pageToken != "" { + req = req.PageToken(pageToken) + } + return req.Execute() +} diff --git a/test/fixtures/input/notifications/integration/create_in_app_target.json b/test/fixtures/input/notifications/integration/create_in_app_target.json new file mode 100644 index 0000000000..75af35f0ba --- /dev/null +++ b/test/fixtures/input/notifications/integration/create_in_app_target.json @@ -0,0 +1,22 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "InApp", + "user": { + "id": "u-abc123", + "related": "https://example.com", + "resource_name": "https://example.com" + } + } +} diff --git a/test/fixtures/input/notifications/integration/create_ms_teams_target.json b/test/fixtures/input/notifications/integration/create_ms_teams_target.json new file mode 100644 index 0000000000..93e9e14938 --- /dev/null +++ b/test/fixtures/input/notifications/integration/create_ms_teams_target.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "MsTeams", + "webhook_url": "https://admin.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000/IncomingWebhook/00000000000000000000000000000000/00000000-0000-0000-0000-000000000000" + } +} diff --git a/test/fixtures/input/notifications/integration/create_role_email_target.json b/test/fixtures/input/notifications/integration/create_role_email_target.json new file mode 100644 index 0000000000..fd800145b5 --- /dev/null +++ b/test/fixtures/input/notifications/integration/create_role_email_target.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "RoleEmail", + "role_name": "OrganizationAdmin" + } +} diff --git a/test/fixtures/input/notifications/integration/create_slack_target.json b/test/fixtures/input/notifications/integration/create_slack_target.json new file mode 100644 index 0000000000..d8e007f9ce --- /dev/null +++ b/test/fixtures/input/notifications/integration/create_slack_target.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "Slack", + "webhook_url": "https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx" + } +} diff --git a/test/fixtures/input/notifications/integration/create_user_email_target.json b/test/fixtures/input/notifications/integration/create_user_email_target.json new file mode 100644 index 0000000000..be6b4710fa --- /dev/null +++ b/test/fixtures/input/notifications/integration/create_user_email_target.json @@ -0,0 +1,22 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "UserEmail", + "user": { + "id": "u-abc123", + "related": "https://example.com", + "resource_name": "https://example.com" + } + } +} diff --git a/test/fixtures/input/notifications/integration/create_webhook_target.json b/test/fixtures/input/notifications/integration/create_webhook_target.json new file mode 100644 index 0000000000..55f8beb4d3 --- /dev/null +++ b/test/fixtures/input/notifications/integration/create_webhook_target.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "Webhook", + "url": "https://my.webhook.url/00000000-0000-0000-0000-000000000000" + } +} diff --git a/test/fixtures/input/notifications/integration/read_created_in_app_target.json b/test/fixtures/input/notifications/integration/read_created_in_app_target.json new file mode 100644 index 0000000000..75af35f0ba --- /dev/null +++ b/test/fixtures/input/notifications/integration/read_created_in_app_target.json @@ -0,0 +1,22 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "InApp", + "user": { + "id": "u-abc123", + "related": "https://example.com", + "resource_name": "https://example.com" + } + } +} diff --git a/test/fixtures/input/notifications/integration/read_created_ms_teams_target.json b/test/fixtures/input/notifications/integration/read_created_ms_teams_target.json new file mode 100644 index 0000000000..93e9e14938 --- /dev/null +++ b/test/fixtures/input/notifications/integration/read_created_ms_teams_target.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "MsTeams", + "webhook_url": "https://admin.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000/IncomingWebhook/00000000000000000000000000000000/00000000-0000-0000-0000-000000000000" + } +} diff --git a/test/fixtures/input/notifications/integration/read_created_role_email_target.json b/test/fixtures/input/notifications/integration/read_created_role_email_target.json new file mode 100644 index 0000000000..fd800145b5 --- /dev/null +++ b/test/fixtures/input/notifications/integration/read_created_role_email_target.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "RoleEmail", + "role_name": "OrganizationAdmin" + } +} diff --git a/test/fixtures/input/notifications/integration/read_created_slack_target.json b/test/fixtures/input/notifications/integration/read_created_slack_target.json new file mode 100644 index 0000000000..d8e007f9ce --- /dev/null +++ b/test/fixtures/input/notifications/integration/read_created_slack_target.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "Slack", + "webhook_url": "https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx" + } +} diff --git a/test/fixtures/input/notifications/integration/read_created_user_email_target.json b/test/fixtures/input/notifications/integration/read_created_user_email_target.json new file mode 100644 index 0000000000..be6b4710fa --- /dev/null +++ b/test/fixtures/input/notifications/integration/read_created_user_email_target.json @@ -0,0 +1,22 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "UserEmail", + "user": { + "id": "u-abc123", + "related": "https://example.com", + "resource_name": "https://example.com" + } + } +} diff --git a/test/fixtures/input/notifications/integration/read_created_webhook_target.json b/test/fixtures/input/notifications/integration/read_created_webhook_target.json new file mode 100644 index 0000000000..55f8beb4d3 --- /dev/null +++ b/test/fixtures/input/notifications/integration/read_created_webhook_target.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "Webhook", + "url": "https://my.webhook.url/00000000-0000-0000-0000-000000000000" + } +} diff --git a/test/fixtures/input/notifications/notification-type/create_notification_type.json b/test/fixtures/input/notifications/notification-type/create_notification_type.json new file mode 100644 index 0000000000..0a5e6064c4 --- /dev/null +++ b/test/fixtures/input/notifications/notification-type/create_notification_type.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "category": "BILLING_LICENSING", + "description": "Cluster shrink operation is completed", + "display_name": "Cluster Shrink", + "id": "dlz-f3a90de", + "is_included_in_plan": false, + "kind": "NotificationType", + "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/notification-type=nt-12345", + "self": "https://api.confluent.cloud/notifications/v1/notification-types/nt-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "severity": "INFO", + "subscription_priority": "REQUIRED" +} diff --git a/test/fixtures/input/notifications/notification-type/read_created_notification_type.json b/test/fixtures/input/notifications/notification-type/read_created_notification_type.json new file mode 100644 index 0000000000..0a5e6064c4 --- /dev/null +++ b/test/fixtures/input/notifications/notification-type/read_created_notification_type.json @@ -0,0 +1,18 @@ +{ + "api_version": "notifications/v1", + "category": "BILLING_LICENSING", + "description": "Cluster shrink operation is completed", + "display_name": "Cluster Shrink", + "id": "dlz-f3a90de", + "is_included_in_plan": false, + "kind": "NotificationType", + "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/notification-type=nt-12345", + "self": "https://api.confluent.cloud/notifications/v1/notification-types/nt-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "severity": "INFO", + "subscription_priority": "REQUIRED" +} diff --git a/test/fixtures/input/notifications/resource-preference/create_resource_preference.json b/test/fixtures/input/notifications/resource-preference/create_resource_preference.json new file mode 100644 index 0000000000..afc9424b10 --- /dev/null +++ b/test/fixtures/input/notifications/resource-preference/create_resource_preference.json @@ -0,0 +1,15 @@ +{ + "api_version": "notifications/v1", + "current_state": "ENABLED", + "id": "dlz-f3a90de", + "kind": "ResourcePreference", + "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/resource-preference=rp-12345", + "self": "https://api.confluent.cloud/notifications/v1/resource-preferences/rp-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "resource": "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector", + "resource_type": "CONNECTOR" +} diff --git a/test/fixtures/input/notifications/resource-preference/read_created_resource_preference.json b/test/fixtures/input/notifications/resource-preference/read_created_resource_preference.json new file mode 100644 index 0000000000..afc9424b10 --- /dev/null +++ b/test/fixtures/input/notifications/resource-preference/read_created_resource_preference.json @@ -0,0 +1,15 @@ +{ + "api_version": "notifications/v1", + "current_state": "ENABLED", + "id": "dlz-f3a90de", + "kind": "ResourcePreference", + "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/resource-preference=rp-12345", + "self": "https://api.confluent.cloud/notifications/v1/resource-preferences/rp-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "resource": "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector", + "resource_type": "CONNECTOR" +} diff --git a/test/fixtures/input/notifications/resource-subscription/create_resource_subscription.json b/test/fixtures/input/notifications/resource-subscription/create_resource_subscription.json new file mode 100644 index 0000000000..a76734546c --- /dev/null +++ b/test/fixtures/input/notifications/resource-subscription/create_resource_subscription.json @@ -0,0 +1,27 @@ +{ + "api_version": "notifications/v1", + "current_state": "ENABLED", + "id": "dlz-f3a90de", + "integrations": [ + { + "id": "", + "related": "https://example.com", + "resource_name": "https://example.com" + } + ], + "kind": "ResourceSubscription", + "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/resource-subscription=rs-12345", + "self": "https://api.confluent.cloud/notifications/v1/resource-subscriptions/rs-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "notification_type": { + "id": "not-abc123", + "related": "https://example.com", + "resource_name": "https://example.com" + }, + "resource": "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector", + "resource_type": "CONNECTOR" +} diff --git a/test/fixtures/input/notifications/resource-subscription/read_created_resource_subscription.json b/test/fixtures/input/notifications/resource-subscription/read_created_resource_subscription.json new file mode 100644 index 0000000000..a76734546c --- /dev/null +++ b/test/fixtures/input/notifications/resource-subscription/read_created_resource_subscription.json @@ -0,0 +1,27 @@ +{ + "api_version": "notifications/v1", + "current_state": "ENABLED", + "id": "dlz-f3a90de", + "integrations": [ + { + "id": "", + "related": "https://example.com", + "resource_name": "https://example.com" + } + ], + "kind": "ResourceSubscription", + "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/resource-subscription=rs-12345", + "self": "https://api.confluent.cloud/notifications/v1/resource-subscriptions/rs-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "notification_type": { + "id": "not-abc123", + "related": "https://example.com", + "resource_name": "https://example.com" + }, + "resource": "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector", + "resource_type": "CONNECTOR" +} diff --git a/test/fixtures/input/notifications/subscription/create_subscription.json b/test/fixtures/input/notifications/subscription/create_subscription.json new file mode 100644 index 0000000000..7cb3995708 --- /dev/null +++ b/test/fixtures/input/notifications/subscription/create_subscription.json @@ -0,0 +1,25 @@ +{ + "api_version": "notifications/v1", + "current_state": "ENABLED", + "id": "dlz-f3a90de", + "integrations": [ + { + "id": "", + "related": "https://example.com", + "resource_name": "https://example.com" + } + ], + "kind": "Subscription", + "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/subscription=s-12345", + "self": "https://api.confluent.cloud/notifications/v1/subscriptions/s-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "notification_type": { + "id": "not-abc123", + "related": "https://example.com", + "resource_name": "https://example.com" + } +} diff --git a/test/fixtures/input/notifications/subscription/read_created_subscription.json b/test/fixtures/input/notifications/subscription/read_created_subscription.json new file mode 100644 index 0000000000..7cb3995708 --- /dev/null +++ b/test/fixtures/input/notifications/subscription/read_created_subscription.json @@ -0,0 +1,25 @@ +{ + "api_version": "notifications/v1", + "current_state": "ENABLED", + "id": "dlz-f3a90de", + "integrations": [ + { + "id": "", + "related": "https://example.com", + "resource_name": "https://example.com" + } + ], + "kind": "Subscription", + "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/subscription=s-12345", + "self": "https://api.confluent.cloud/notifications/v1/subscriptions/s-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "notification_type": { + "id": "not-abc123", + "related": "https://example.com", + "resource_name": "https://example.com" + } +} diff --git a/test/fixtures/input/notifications/user-notification/create_user_notification.json b/test/fixtures/input/notifications/user-notification/create_user_notification.json new file mode 100644 index 0000000000..0196382c2a --- /dev/null +++ b/test/fixtures/input/notifications/user-notification/create_user_notification.json @@ -0,0 +1,70 @@ +{ + "actions": [ + { + "identifier": "manage_cluster_settings", + "role": "PRIMARY", + "url": "https://confluent.cloud/environments/env-xyz/clusters/lkc-ds23ad/settings" + } + ], + "api_version": "notifications/v1", + "id": "dlz-f3a90de", + "integrations": [ + { + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "Slack", + "webhook_url": "https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx" + } + } + ], + "kind": "UserNotification", + "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/user-notification=un-12345", + "self": "https://api.confluent.cloud/notifications/v1/user-notifications/un-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "notification_type": { + "api_version": "notifications/v1", + "category": "BILLING_LICENSING", + "description": "Cluster shrink operation is completed", + "display_name": "Cluster Shrink", + "id": "dlz-f3a90de", + "is_included_in_plan": false, + "kind": "NotificationType", + "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/notification-type=nt-12345", + "self": "https://api.confluent.cloud/notifications/v1/notification-types/nt-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "severity": "INFO", + "subscription_priority": "REQUIRED" + }, + "read": false, + "read_at": "2026-01-31T11:00:00Z", + "received_at": "2026-01-31T10:35:00Z", + "recommended_actions": { + "content": "Restart the cluster from the Confluent Cloud console.", + "version": 1 + }, + "resource": { + "crn": "crn://confluent.cloud/organization=org-abc/environment=env-xyz/kafka-cluster=lkc-ds23ad", + "display_name": "prod-kafka-cluster", + "type": "CLUSTER" + }, + "severity": "CRITICAL" +} diff --git a/test/fixtures/input/notifications/user-notification/read_created_user_notification.json b/test/fixtures/input/notifications/user-notification/read_created_user_notification.json new file mode 100644 index 0000000000..0196382c2a --- /dev/null +++ b/test/fixtures/input/notifications/user-notification/read_created_user_notification.json @@ -0,0 +1,70 @@ +{ + "actions": [ + { + "identifier": "manage_cluster_settings", + "role": "PRIMARY", + "url": "https://confluent.cloud/environments/env-xyz/clusters/lkc-ds23ad/settings" + } + ], + "api_version": "notifications/v1", + "id": "dlz-f3a90de", + "integrations": [ + { + "api_version": "notifications/v1", + "description": "A Slack channel integration", + "display_name": "Slack integration", + "id": "dlz-f3a90de", + "kind": "Integration", + "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/integration=i-12345", + "self": "https://api.confluent.cloud/notifications/v1/integrations/i-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "target": { + "kind": "Slack", + "webhook_url": "https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx" + } + } + ], + "kind": "UserNotification", + "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/user-notification=un-12345", + "self": "https://api.confluent.cloud/notifications/v1/user-notifications/un-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "notification_type": { + "api_version": "notifications/v1", + "category": "BILLING_LICENSING", + "description": "Cluster shrink operation is completed", + "display_name": "Cluster Shrink", + "id": "dlz-f3a90de", + "is_included_in_plan": false, + "kind": "NotificationType", + "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/notification-type=nt-12345", + "self": "https://api.confluent.cloud/notifications/v1/notification-types/nt-12345", + "updated_at": "2006-01-02T15:04:05-07:00" + }, + "severity": "INFO", + "subscription_priority": "REQUIRED" + }, + "read": false, + "read_at": "2026-01-31T11:00:00Z", + "received_at": "2026-01-31T10:35:00Z", + "recommended_actions": { + "content": "Restart the cluster from the Confluent Cloud console.", + "version": 1 + }, + "resource": { + "crn": "crn://confluent.cloud/organization=org-abc/environment=env-xyz/kafka-cluster=lkc-ds23ad", + "display_name": "prod-kafka-cluster", + "type": "CLUSTER" + }, + "severity": "CRITICAL" +} diff --git a/test/fixtures/output/help.golden b/test/fixtures/output/help.golden index ab91e2ed10..ac054b0b5b 100644 --- a/test/fixtures/output/help.golden +++ b/test/fixtures/output/help.golden @@ -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. + notifications Manage Cloud Notifications. organization Manage Confluent Cloud organizations. plugin Manage Confluent plugins. prompt Add Confluent CLI context to your terminal prompt. diff --git a/test/fixtures/output/notifications/help.golden b/test/fixtures/output/notifications/help.golden new file mode 100644 index 0000000000..f8b25c3658 --- /dev/null +++ b/test/fixtures/output/notifications/help.golden @@ -0,0 +1,19 @@ +Manage Cloud Notifications. + +Usage: + confluent notifications [command] + +Available Commands: + integration Manage Confluent Cloud notifications integrations. + notification-type Manage Confluent Cloud notifications notification types. + resource-preference Manage Confluent Cloud notifications resource preferences. + resource-subscription Manage Confluent Cloud notifications resource subscriptions. + subscription Manage Confluent Cloud notifications subscriptions. + user-notification Manage Confluent Cloud notifications user notifications. + +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 notifications [command] --help" for more information about a command. diff --git a/test/fixtures/output/notifications/integration/create-help.golden b/test/fixtures/output/notifications/integration/create-help.golden new file mode 100644 index 0000000000..ab3a834abf --- /dev/null +++ b/test/fixtures/output/notifications/integration/create-help.golden @@ -0,0 +1,17 @@ +Create a notifications integration. + +Usage: + confluent notifications integration create [flags] + +Flags: + --kind string REQUIRED: Integration-specific details (integration targets). One of: Slack, Webhook, MsTeams. + --webhook-url string Slack: Slack Webhook URL for the particular Slack channel. MsTeams: MS Teams Webhook URL for the particular team channel. + --url string URL endpoint for the webhook. + --description string A human readable description for the particular integration. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/integration/create/create-description.golden b/test/fixtures/output/notifications/integration/create/create-description.golden new file mode 100644 index 0000000000..f364e93a55 --- /dev/null +++ b/test/fixtures/output/notifications/integration/create/create-description.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | test-name | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/create/create-ms-teams-target.golden b/test/fixtures/output/notifications/integration/create/create-ms-teams-target.golden new file mode 100644 index 0000000000..6a2381a851 --- /dev/null +++ b/test/fixtures/output/notifications/integration/create/create-ms-teams-target.golden @@ -0,0 +1,6 @@ ++-----------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | test-name | +| Description | A Slack channel integration | +| Ms Teams Target Webhook Url | https://admin.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000/IncomingWebhook/00000000000000000000000000000000/00000000-0000-0000-0000-000000000000 | ++-----------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/create/create-slack-target.golden b/test/fixtures/output/notifications/integration/create/create-slack-target.golden new file mode 100644 index 0000000000..f364e93a55 --- /dev/null +++ b/test/fixtures/output/notifications/integration/create/create-slack-target.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | test-name | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/create/create-webhook-target.golden b/test/fixtures/output/notifications/integration/create/create-webhook-target.golden new file mode 100644 index 0000000000..f364e93a55 --- /dev/null +++ b/test/fixtures/output/notifications/integration/create/create-webhook-target.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | test-name | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/delete-help.golden b/test/fixtures/output/notifications/integration/delete-help.golden new file mode 100644 index 0000000000..65daaab269 --- /dev/null +++ b/test/fixtures/output/notifications/integration/delete-help.golden @@ -0,0 +1,13 @@ +Delete one or more notifications integrations. + +Usage: + confluent notifications integration delete [id-2] ... [id-n] [flags] + +Flags: + --context string CLI context name. + --force Skip the deletion confirmation prompt. + +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). diff --git a/test/fixtures/output/notifications/integration/delete/delete-autocomplete.golden b/test/fixtures/output/notifications/integration/delete/delete-autocomplete.golden new file mode 100644 index 0000000000..f3cfeb73be --- /dev/null +++ b/test/fixtures/output/notifications/integration/delete/delete-autocomplete.golden @@ -0,0 +1,3 @@ +dlz-f3a90de Slack integration +:4 +Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/test/fixtures/output/notifications/integration/delete/delete-invalid.golden b/test/fixtures/output/notifications/integration/delete/delete-invalid.golden new file mode 100644 index 0000000000..6d3c64140e --- /dev/null +++ b/test/fixtures/output/notifications/integration/delete/delete-invalid.golden @@ -0,0 +1,4 @@ +Error: notifications integration "invalid" not found + +Suggestions: + List available notifications integrations with `confluent notifications integration list`. diff --git a/test/fixtures/output/notifications/integration/delete/delete-multiple.golden b/test/fixtures/output/notifications/integration/delete/delete-multiple.golden new file mode 100644 index 0000000000..c7288d050c --- /dev/null +++ b/test/fixtures/output/notifications/integration/delete/delete-multiple.golden @@ -0,0 +1 @@ +Are you sure you want to delete notifications integrations "integration-1" and "integration-2"? (y/n): Deleted notifications integrations "integration-1" and "integration-2". diff --git a/test/fixtures/output/notifications/integration/delete/delete-no-force.golden b/test/fixtures/output/notifications/integration/delete/delete-no-force.golden new file mode 100644 index 0000000000..65df01b0fb --- /dev/null +++ b/test/fixtures/output/notifications/integration/delete/delete-no-force.golden @@ -0,0 +1 @@ +Are you sure you want to delete notifications integration "integration-1"? (y/n): Deleted notifications integration "integration-1". diff --git a/test/fixtures/output/notifications/integration/delete/delete.golden b/test/fixtures/output/notifications/integration/delete/delete.golden new file mode 100644 index 0000000000..2ae58fe834 --- /dev/null +++ b/test/fixtures/output/notifications/integration/delete/delete.golden @@ -0,0 +1 @@ +Deleted notifications integration "integration-1". diff --git a/test/fixtures/output/notifications/integration/describe-help.golden b/test/fixtures/output/notifications/integration/describe-help.golden new file mode 100644 index 0000000000..1bface2867 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe-help.golden @@ -0,0 +1,13 @@ +Describe a notifications integration. + +Usage: + confluent notifications integration describe [flags] + +Flags: + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/integration/describe/describe-autocomplete.golden b/test/fixtures/output/notifications/integration/describe/describe-autocomplete.golden new file mode 100644 index 0000000000..f3cfeb73be --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-autocomplete.golden @@ -0,0 +1,3 @@ +dlz-f3a90de Slack integration +:4 +Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/test/fixtures/output/notifications/integration/describe/describe-in-app-target.golden b/test/fixtures/output/notifications/integration/describe/describe-in-app-target.golden new file mode 100644 index 0000000000..96d72c5113 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-in-app-target.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/describe/describe-invalid.golden b/test/fixtures/output/notifications/integration/describe/describe-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/integration/describe/describe-json.golden b/test/fixtures/output/notifications/integration/describe/describe-json.golden new file mode 100644 index 0000000000..53efd1a980 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-json.golden @@ -0,0 +1,6 @@ +{ + "id": "dlz-f3a90de", + "display_name": "Slack integration", + "description": "A Slack channel integration", + "slack_target_webhook_url": "https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx" +} diff --git a/test/fixtures/output/notifications/integration/describe/describe-ms-teams-target.golden b/test/fixtures/output/notifications/integration/describe/describe-ms-teams-target.golden new file mode 100644 index 0000000000..96d72c5113 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-ms-teams-target.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/describe/describe-role-email-target.golden b/test/fixtures/output/notifications/integration/describe/describe-role-email-target.golden new file mode 100644 index 0000000000..96d72c5113 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-role-email-target.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/describe/describe-slack-target.golden b/test/fixtures/output/notifications/integration/describe/describe-slack-target.golden new file mode 100644 index 0000000000..96d72c5113 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-slack-target.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/describe/describe-user-email-target.golden b/test/fixtures/output/notifications/integration/describe/describe-user-email-target.golden new file mode 100644 index 0000000000..96d72c5113 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-user-email-target.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/describe/describe-webhook-target.golden b/test/fixtures/output/notifications/integration/describe/describe-webhook-target.golden new file mode 100644 index 0000000000..96d72c5113 --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-webhook-target.golden @@ -0,0 +1,6 @@ ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/describe/describe-yaml.golden b/test/fixtures/output/notifications/integration/describe/describe-yaml.golden new file mode 100644 index 0000000000..02f7f321dc --- /dev/null +++ b/test/fixtures/output/notifications/integration/describe/describe-yaml.golden @@ -0,0 +1,4 @@ +id: dlz-f3a90de +display_name: Slack integration +description: A Slack channel integration +slack_target_webhook_url: https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx diff --git a/test/fixtures/output/notifications/integration/help.golden b/test/fixtures/output/notifications/integration/help.golden new file mode 100644 index 0000000000..2bc14abee4 --- /dev/null +++ b/test/fixtures/output/notifications/integration/help.golden @@ -0,0 +1,18 @@ +Manage Confluent Cloud notifications integrations. + +Usage: + confluent notifications integration [command] + +Available Commands: + create Create a notifications integration. + delete Delete one or more notifications integrations. + describe Describe a notifications integration. + list List notifications integrations. + update Update an existing notifications integration. + +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 notifications integration [command] --help" for more information about a command. diff --git a/test/fixtures/output/notifications/integration/list-help.golden b/test/fixtures/output/notifications/integration/list-help.golden new file mode 100644 index 0000000000..d06c8d9269 --- /dev/null +++ b/test/fixtures/output/notifications/integration/list-help.golden @@ -0,0 +1,13 @@ +List notifications integrations. + +Usage: + confluent notifications integration list [flags] + +Flags: + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/integration/list/list-json.golden b/test/fixtures/output/notifications/integration/list/list-json.golden new file mode 100644 index 0000000000..87598dcdaa --- /dev/null +++ b/test/fixtures/output/notifications/integration/list/list-json.golden @@ -0,0 +1,8 @@ +[ + { + "id": "dlz-f3a90de", + "display_name": "Slack integration", + "description": "A Slack channel integration", + "slack_target_webhook_url": "https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx" + } +] diff --git a/test/fixtures/output/notifications/integration/list/list-yaml.golden b/test/fixtures/output/notifications/integration/list/list-yaml.golden new file mode 100644 index 0000000000..e11c483548 --- /dev/null +++ b/test/fixtures/output/notifications/integration/list/list-yaml.golden @@ -0,0 +1,4 @@ +- id: dlz-f3a90de + display_name: Slack integration + description: A Slack channel integration + slack_target_webhook_url: https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx diff --git a/test/fixtures/output/notifications/integration/list/list.golden b/test/fixtures/output/notifications/integration/list/list.golden new file mode 100644 index 0000000000..cf44d09b52 --- /dev/null +++ b/test/fixtures/output/notifications/integration/list/list.golden @@ -0,0 +1,3 @@ + ID | Display Name | Description | Slack Target Webhook Url | Role Email Target Role Name | Webhook Target Url | Ms Teams Target Webhook Url +--------------+-------------------+-----------------------------+-------------------------------------------------------------------------------+-----------------------------+--------------------+------------------------------ + dlz-f3a90de | Slack integration | A Slack channel integration | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | | | diff --git a/test/fixtures/output/notifications/integration/update-help.golden b/test/fixtures/output/notifications/integration/update-help.golden new file mode 100644 index 0000000000..95e173fa65 --- /dev/null +++ b/test/fixtures/output/notifications/integration/update-help.golden @@ -0,0 +1,18 @@ +Update an existing notifications integration. + +Usage: + confluent notifications integration update [flags] + +Flags: + --kind string Integration-specific details (integration targets). One of: Slack, Webhook, MsTeams. + --webhook-url string Slack: Slack Webhook URL for the particular Slack channel. MsTeams: MS Teams Webhook URL for the particular team channel. + --url string URL endpoint for the webhook. + --display-name string A human readable name for the particular integration. + --description string A human readable description for the particular integration. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/integration/update/update-description.golden b/test/fixtures/output/notifications/integration/update/update-description.golden new file mode 100644 index 0000000000..e0f9e5bb7c --- /dev/null +++ b/test/fixtures/output/notifications/integration/update/update-description.golden @@ -0,0 +1,7 @@ +Updated notifications integration "integration-1". ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/update/update-display-name.golden b/test/fixtures/output/notifications/integration/update/update-display-name.golden new file mode 100644 index 0000000000..e0f9e5bb7c --- /dev/null +++ b/test/fixtures/output/notifications/integration/update/update-display-name.golden @@ -0,0 +1,7 @@ +Updated notifications integration "integration-1". ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/update/update-invalid.golden b/test/fixtures/output/notifications/integration/update/update-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/integration/update/update-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/integration/update/update-ms-teams-target.golden b/test/fixtures/output/notifications/integration/update/update-ms-teams-target.golden new file mode 100644 index 0000000000..97894b1624 --- /dev/null +++ b/test/fixtures/output/notifications/integration/update/update-ms-teams-target.golden @@ -0,0 +1,7 @@ +Updated notifications integration "integration-1". ++-----------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Ms Teams Target Webhook Url | https://admin.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000/IncomingWebhook/00000000000000000000000000000000/00000000-0000-0000-0000-000000000000 | ++-----------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/update/update-slack-target.golden b/test/fixtures/output/notifications/integration/update/update-slack-target.golden new file mode 100644 index 0000000000..e0f9e5bb7c --- /dev/null +++ b/test/fixtures/output/notifications/integration/update/update-slack-target.golden @@ -0,0 +1,7 @@ +Updated notifications integration "integration-1". ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/integration/update/update-webhook-target.golden b/test/fixtures/output/notifications/integration/update/update-webhook-target.golden new file mode 100644 index 0000000000..e0f9e5bb7c --- /dev/null +++ b/test/fixtures/output/notifications/integration/update/update-webhook-target.golden @@ -0,0 +1,7 @@ +Updated notifications integration "integration-1". ++--------------------------+-------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Slack integration | +| Description | A Slack channel integration | +| Slack Target Webhook Url | https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx | ++--------------------------+-------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/notification-type/describe-help.golden b/test/fixtures/output/notifications/notification-type/describe-help.golden new file mode 100644 index 0000000000..bb60d8ba9c --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/describe-help.golden @@ -0,0 +1,13 @@ +Describe a notifications notification type. + +Usage: + confluent notifications notification-type describe [flags] + +Flags: + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/notification-type/describe/describe-autocomplete.golden b/test/fixtures/output/notifications/notification-type/describe/describe-autocomplete.golden new file mode 100644 index 0000000000..12c06ba7f5 --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/describe/describe-autocomplete.golden @@ -0,0 +1,3 @@ +dlz-f3a90de Cluster Shrink +:4 +Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/test/fixtures/output/notifications/notification-type/describe/describe-invalid.golden b/test/fixtures/output/notifications/notification-type/describe/describe-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/describe/describe-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/notification-type/describe/describe-json.golden b/test/fixtures/output/notifications/notification-type/describe/describe-json.golden new file mode 100644 index 0000000000..ee3d98094d --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/describe/describe-json.golden @@ -0,0 +1,9 @@ +{ + "id": "dlz-f3a90de", + "display_name": "Cluster Shrink", + "category": "BILLING_LICENSING", + "description": "Cluster shrink operation is completed", + "subscription_priority": "REQUIRED", + "is_included_in_plan": false, + "severity": "INFO" +} diff --git a/test/fixtures/output/notifications/notification-type/describe/describe-yaml.golden b/test/fixtures/output/notifications/notification-type/describe/describe-yaml.golden new file mode 100644 index 0000000000..3f3cccb005 --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/describe/describe-yaml.golden @@ -0,0 +1,7 @@ +id: dlz-f3a90de +display_name: Cluster Shrink +category: BILLING_LICENSING +description: Cluster shrink operation is completed +subscription_priority: REQUIRED +is_included_in_plan: false +severity: INFO diff --git a/test/fixtures/output/notifications/notification-type/describe/describe.golden b/test/fixtures/output/notifications/notification-type/describe/describe.golden new file mode 100644 index 0000000000..ad1c4e9d71 --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/describe/describe.golden @@ -0,0 +1,10 @@ ++-----------------------+--------------------------------+ +| ID | dlz-f3a90de | +| Display Name | Cluster Shrink | +| Category | BILLING_LICENSING | +| Description | Cluster shrink operation is | +| | completed | +| Subscription Priority | REQUIRED | +| Is Included In Plan | false | +| Severity | INFO | ++-----------------------+--------------------------------+ diff --git a/test/fixtures/output/notifications/notification-type/help.golden b/test/fixtures/output/notifications/notification-type/help.golden new file mode 100644 index 0000000000..04753d850e --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/help.golden @@ -0,0 +1,15 @@ +Manage Confluent Cloud notifications notification types. + +Usage: + confluent notifications notification-type [command] + +Available Commands: + describe Describe a notifications notification type. + list List notifications notification types. + +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 notifications notification-type [command] --help" for more information about a command. diff --git a/test/fixtures/output/notifications/notification-type/list-help.golden b/test/fixtures/output/notifications/notification-type/list-help.golden new file mode 100644 index 0000000000..2f19ce3a45 --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/list-help.golden @@ -0,0 +1,14 @@ +List notifications notification types. + +Usage: + confluent notifications notification-type list [flags] + +Flags: + --resource-type string Confluent Cloud resource type. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/notification-type/list/list-json.golden b/test/fixtures/output/notifications/notification-type/list/list-json.golden new file mode 100644 index 0000000000..2bed26dbf7 --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/list/list-json.golden @@ -0,0 +1,11 @@ +[ + { + "id": "dlz-f3a90de", + "display_name": "Cluster Shrink", + "category": "BILLING_LICENSING", + "description": "Cluster shrink operation is completed", + "subscription_priority": "REQUIRED", + "is_included_in_plan": false, + "severity": "INFO" + } +] diff --git a/test/fixtures/output/notifications/notification-type/list/list-resource-type.golden b/test/fixtures/output/notifications/notification-type/list/list-resource-type.golden new file mode 100644 index 0000000000..fcea44cd65 --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/list/list-resource-type.golden @@ -0,0 +1,4 @@ + ID | Display Name | Category | Description | Subscription Priority | Is Included In Plan | Severity +--------------+----------------+-------------------+--------------------------------+-----------------------+---------------------+----------- + dlz-f3a90de | Cluster Shrink | BILLING_LICENSING | Cluster shrink operation is | REQUIRED | false | INFO + | | | completed | | | diff --git a/test/fixtures/output/notifications/notification-type/list/list-yaml.golden b/test/fixtures/output/notifications/notification-type/list/list-yaml.golden new file mode 100644 index 0000000000..a7e65948ac --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/list/list-yaml.golden @@ -0,0 +1,7 @@ +- id: dlz-f3a90de + display_name: Cluster Shrink + category: BILLING_LICENSING + description: Cluster shrink operation is completed + subscription_priority: REQUIRED + is_included_in_plan: false + severity: INFO diff --git a/test/fixtures/output/notifications/notification-type/list/list.golden b/test/fixtures/output/notifications/notification-type/list/list.golden new file mode 100644 index 0000000000..fcea44cd65 --- /dev/null +++ b/test/fixtures/output/notifications/notification-type/list/list.golden @@ -0,0 +1,4 @@ + ID | Display Name | Category | Description | Subscription Priority | Is Included In Plan | Severity +--------------+----------------+-------------------+--------------------------------+-----------------------+---------------------+----------- + dlz-f3a90de | Cluster Shrink | BILLING_LICENSING | Cluster shrink operation is | REQUIRED | false | INFO + | | | completed | | | diff --git a/test/fixtures/output/notifications/resource-preference/create-help.golden b/test/fixtures/output/notifications/resource-preference/create-help.golden new file mode 100644 index 0000000000..31136ca94a --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/create-help.golden @@ -0,0 +1,16 @@ +Create a notifications resource preference. + +Usage: + confluent notifications resource-preference create [flags] + +Flags: + --resource string REQUIRED: Denotes the Confluent Cloud resource definition. + --resource-type string REQUIRED: Denotes the Confluent Cloud resource type. + --current-state REQUIRED Denotes the state of the resource preference. When the resource preference is ENABLED, the user will receive notifications for the Confluent Cloud resource. If the resource preference is DISABLED, the user will not receive any notification for the resource. Note that, you will still receive notifications for REQUIRED notification type even when it is DISABLED. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/resource-preference/create/create-current-state.golden b/test/fixtures/output/notifications/resource-preference/create/create-current-state.golden new file mode 100644 index 0000000000..7d7b28287c --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/create/create-current-state.golden @@ -0,0 +1,6 @@ ++---------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | ORGANIZATION | +| Current State | ENABLED | ++---------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-preference/create/create.golden b/test/fixtures/output/notifications/resource-preference/create/create.golden new file mode 100644 index 0000000000..7d7b28287c --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/create/create.golden @@ -0,0 +1,6 @@ ++---------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | ORGANIZATION | +| Current State | ENABLED | ++---------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-preference/delete-help.golden b/test/fixtures/output/notifications/resource-preference/delete-help.golden new file mode 100644 index 0000000000..536758ee31 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/delete-help.golden @@ -0,0 +1,13 @@ +Delete one or more notifications resource preferences. + +Usage: + confluent notifications resource-preference delete [id-2] ... [id-n] [flags] + +Flags: + --context string CLI context name. + --force Skip the deletion confirmation prompt. + +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). diff --git a/test/fixtures/output/notifications/resource-preference/delete/delete-invalid.golden b/test/fixtures/output/notifications/resource-preference/delete/delete-invalid.golden new file mode 100644 index 0000000000..2a3b5088d2 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/delete/delete-invalid.golden @@ -0,0 +1,4 @@ +Error: notifications resource preference "invalid" not found + +Suggestions: + List available notifications resource preferences with `confluent notifications resource-preference list`. diff --git a/test/fixtures/output/notifications/resource-preference/delete/delete-multiple.golden b/test/fixtures/output/notifications/resource-preference/delete/delete-multiple.golden new file mode 100644 index 0000000000..5a06767d97 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/delete/delete-multiple.golden @@ -0,0 +1 @@ +Are you sure you want to delete notifications resource preferences "resource-preference-1" and "resource-preference-2"? (y/n): Deleted notifications resource preferences "resource-preference-1" and "resource-preference-2". diff --git a/test/fixtures/output/notifications/resource-preference/delete/delete-no-force.golden b/test/fixtures/output/notifications/resource-preference/delete/delete-no-force.golden new file mode 100644 index 0000000000..c367cef022 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/delete/delete-no-force.golden @@ -0,0 +1 @@ +Are you sure you want to delete notifications resource preference "resource-preference-1"? (y/n): Deleted notifications resource preference "resource-preference-1". diff --git a/test/fixtures/output/notifications/resource-preference/delete/delete.golden b/test/fixtures/output/notifications/resource-preference/delete/delete.golden new file mode 100644 index 0000000000..22010dc143 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/delete/delete.golden @@ -0,0 +1 @@ +Deleted notifications resource preference "resource-preference-1". diff --git a/test/fixtures/output/notifications/resource-preference/describe-help.golden b/test/fixtures/output/notifications/resource-preference/describe-help.golden new file mode 100644 index 0000000000..5226573d7f --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/describe-help.golden @@ -0,0 +1,13 @@ +Describe a notifications resource preference. + +Usage: + confluent notifications resource-preference describe [flags] + +Flags: + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/resource-preference/describe/describe-invalid.golden b/test/fixtures/output/notifications/resource-preference/describe/describe-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/describe/describe-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/resource-preference/describe/describe-json.golden b/test/fixtures/output/notifications/resource-preference/describe/describe-json.golden new file mode 100644 index 0000000000..48484a7246 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/describe/describe-json.golden @@ -0,0 +1,6 @@ +{ + "id": "dlz-f3a90de", + "resource": "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector", + "resource_type": "CONNECTOR", + "current_state": "ENABLED" +} diff --git a/test/fixtures/output/notifications/resource-preference/describe/describe-yaml.golden b/test/fixtures/output/notifications/resource-preference/describe/describe-yaml.golden new file mode 100644 index 0000000000..9fb30d040e --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/describe/describe-yaml.golden @@ -0,0 +1,4 @@ +id: dlz-f3a90de +resource: environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector +resource_type: CONNECTOR +current_state: ENABLED diff --git a/test/fixtures/output/notifications/resource-preference/describe/describe.golden b/test/fixtures/output/notifications/resource-preference/describe/describe.golden new file mode 100644 index 0000000000..4b133e183f --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/describe/describe.golden @@ -0,0 +1,6 @@ ++---------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | CONNECTOR | +| Current State | ENABLED | ++---------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-preference/help.golden b/test/fixtures/output/notifications/resource-preference/help.golden new file mode 100644 index 0000000000..7b4658f3fd --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/help.golden @@ -0,0 +1,17 @@ +Manage Confluent Cloud notifications resource preferences. + +Usage: + confluent notifications resource-preference [command] + +Available Commands: + create Create a notifications resource preference. + delete Delete one or more notifications resource preferences. + describe Describe a notifications resource preference. + update Update an existing notifications resource preference. + +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 notifications resource-preference [command] --help" for more information about a command. diff --git a/test/fixtures/output/notifications/resource-preference/update-help.golden b/test/fixtures/output/notifications/resource-preference/update-help.golden new file mode 100644 index 0000000000..c28717b8e0 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/update-help.golden @@ -0,0 +1,16 @@ +Update an existing notifications resource preference. + +Usage: + confluent notifications resource-preference update [flags] + +Flags: + --resource string Denotes the Confluent Cloud resource definition. + --resource-type string Denotes the Confluent Cloud resource type. + --current-state REQUIRED Denotes the state of the resource preference. When the resource preference is ENABLED, the user will receive notifications for the Confluent Cloud resource. If the resource preference is DISABLED, the user will not receive any notification for the resource. Note that, you will still receive notifications for REQUIRED notification type even when it is DISABLED. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/resource-preference/update/update-current-state.golden b/test/fixtures/output/notifications/resource-preference/update/update-current-state.golden new file mode 100644 index 0000000000..1ba653427a --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/update/update-current-state.golden @@ -0,0 +1,7 @@ +Updated notifications resource preference "resource-preference-1". ++---------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | CONNECTOR | +| Current State | ENABLED | ++---------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-preference/update/update-invalid.golden b/test/fixtures/output/notifications/resource-preference/update/update-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/update/update-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/resource-preference/update/update-resource-type.golden b/test/fixtures/output/notifications/resource-preference/update/update-resource-type.golden new file mode 100644 index 0000000000..1ac5c7c302 --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/update/update-resource-type.golden @@ -0,0 +1,7 @@ +Updated notifications resource preference "resource-preference-1". ++---------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | ORGANIZATION | +| Current State | ENABLED | ++---------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-preference/update/update-resource.golden b/test/fixtures/output/notifications/resource-preference/update/update-resource.golden new file mode 100644 index 0000000000..1ba653427a --- /dev/null +++ b/test/fixtures/output/notifications/resource-preference/update/update-resource.golden @@ -0,0 +1,7 @@ +Updated notifications resource preference "resource-preference-1". ++---------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | CONNECTOR | +| Current State | ENABLED | ++---------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-subscription/create-help.golden b/test/fixtures/output/notifications/resource-subscription/create-help.golden new file mode 100644 index 0000000000..d9b9c8da98 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/create-help.golden @@ -0,0 +1,18 @@ +Create a notifications resource subscription. + +Usage: + confluent notifications resource-subscription create [flags] + +Flags: + --resource string REQUIRED: Denotes the Confluent Cloud resource definition. + --resource-type string REQUIRED: Denotes the Confluent Cloud resource type. + --notification-type string REQUIRED: The type of notification to subscribe to. + --integrations strings REQUIRED: A comma-separated list of integration IDs to notify. + --current-state REQUIRED Denotes the state of the resource subscription. When the resource subscription is ENABLED, the user will receive notifications of the configured notification type for the Confluent Cloud resource. If the resource subscription is DISABLED, the user will not receive them. Note that, you will still receive notifications for REQUIRED notification type even when it is DISABLED. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/resource-subscription/create/create-current-state.golden b/test/fixtures/output/notifications/resource-subscription/create/create-current-state.golden new file mode 100644 index 0000000000..8386333e0b --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/create/create-current-state.golden @@ -0,0 +1,7 @@ ++-------------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | ENVIRONMENT | +| Notification Type | notification-type-value | +| Current State | ENABLED | ++-------------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-subscription/create/create.golden b/test/fixtures/output/notifications/resource-subscription/create/create.golden new file mode 100644 index 0000000000..8386333e0b --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/create/create.golden @@ -0,0 +1,7 @@ ++-------------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | ENVIRONMENT | +| Notification Type | notification-type-value | +| Current State | ENABLED | ++-------------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-subscription/delete-help.golden b/test/fixtures/output/notifications/resource-subscription/delete-help.golden new file mode 100644 index 0000000000..f898d77b01 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/delete-help.golden @@ -0,0 +1,13 @@ +Delete one or more notifications resource subscriptions. + +Usage: + confluent notifications resource-subscription delete [id-2] ... [id-n] [flags] + +Flags: + --context string CLI context name. + --force Skip the deletion confirmation prompt. + +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). diff --git a/test/fixtures/output/notifications/resource-subscription/delete/delete-invalid.golden b/test/fixtures/output/notifications/resource-subscription/delete/delete-invalid.golden new file mode 100644 index 0000000000..bb27ce59a4 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/delete/delete-invalid.golden @@ -0,0 +1,4 @@ +Error: notifications resource subscription "invalid" not found + +Suggestions: + List available notifications resource subscriptions with `confluent notifications resource-subscription list`. diff --git a/test/fixtures/output/notifications/resource-subscription/delete/delete-multiple.golden b/test/fixtures/output/notifications/resource-subscription/delete/delete-multiple.golden new file mode 100644 index 0000000000..cfd7a4c1a7 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/delete/delete-multiple.golden @@ -0,0 +1 @@ +Are you sure you want to delete notifications resource subscriptions "resource-subscription-1" and "resource-subscription-2"? (y/n): Deleted notifications resource subscriptions "resource-subscription-1" and "resource-subscription-2". diff --git a/test/fixtures/output/notifications/resource-subscription/delete/delete-no-force.golden b/test/fixtures/output/notifications/resource-subscription/delete/delete-no-force.golden new file mode 100644 index 0000000000..6389e4bcb3 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/delete/delete-no-force.golden @@ -0,0 +1 @@ +Are you sure you want to delete notifications resource subscription "resource-subscription-1"? (y/n): Deleted notifications resource subscription "resource-subscription-1". diff --git a/test/fixtures/output/notifications/resource-subscription/delete/delete.golden b/test/fixtures/output/notifications/resource-subscription/delete/delete.golden new file mode 100644 index 0000000000..a6b0c44d7e --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/delete/delete.golden @@ -0,0 +1 @@ +Deleted notifications resource subscription "resource-subscription-1". diff --git a/test/fixtures/output/notifications/resource-subscription/describe-help.golden b/test/fixtures/output/notifications/resource-subscription/describe-help.golden new file mode 100644 index 0000000000..b7b217027f --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/describe-help.golden @@ -0,0 +1,13 @@ +Describe a notifications resource subscription. + +Usage: + confluent notifications resource-subscription describe [flags] + +Flags: + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/resource-subscription/describe/describe-invalid.golden b/test/fixtures/output/notifications/resource-subscription/describe/describe-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/describe/describe-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/resource-subscription/describe/describe-json.golden b/test/fixtures/output/notifications/resource-subscription/describe/describe-json.golden new file mode 100644 index 0000000000..b7d706febe --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/describe/describe-json.golden @@ -0,0 +1,7 @@ +{ + "id": "dlz-f3a90de", + "resource": "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector", + "resource_type": "CONNECTOR", + "notification_type": "not-abc123", + "current_state": "ENABLED" +} diff --git a/test/fixtures/output/notifications/resource-subscription/describe/describe-yaml.golden b/test/fixtures/output/notifications/resource-subscription/describe/describe-yaml.golden new file mode 100644 index 0000000000..a1745b290c --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/describe/describe-yaml.golden @@ -0,0 +1,5 @@ +id: dlz-f3a90de +resource: environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector +resource_type: CONNECTOR +notification_type: not-abc123 +current_state: ENABLED diff --git a/test/fixtures/output/notifications/resource-subscription/describe/describe.golden b/test/fixtures/output/notifications/resource-subscription/describe/describe.golden new file mode 100644 index 0000000000..123e6ba837 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/describe/describe.golden @@ -0,0 +1,7 @@ ++-------------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | CONNECTOR | +| Notification Type | not-abc123 | +| Current State | ENABLED | ++-------------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-subscription/help.golden b/test/fixtures/output/notifications/resource-subscription/help.golden new file mode 100644 index 0000000000..776741a549 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/help.golden @@ -0,0 +1,17 @@ +Manage Confluent Cloud notifications resource subscriptions. + +Usage: + confluent notifications resource-subscription [command] + +Available Commands: + create Create a notifications resource subscription. + delete Delete one or more notifications resource subscriptions. + describe Describe a notifications resource subscription. + update Update an existing notifications resource subscription. + +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 notifications resource-subscription [command] --help" for more information about a command. diff --git a/test/fixtures/output/notifications/resource-subscription/update-help.golden b/test/fixtures/output/notifications/resource-subscription/update-help.golden new file mode 100644 index 0000000000..ec76696b69 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/update-help.golden @@ -0,0 +1,17 @@ +Update an existing notifications resource subscription. + +Usage: + confluent notifications resource-subscription update [flags] + +Flags: + --resource string Denotes the Confluent Cloud resource definition. + --resource-type string Denotes the Confluent Cloud resource type. + --current-state REQUIRED Denotes the state of the resource subscription. When the resource subscription is ENABLED, the user will receive notifications of the configured notification type for the Confluent Cloud resource. If the resource subscription is DISABLED, the user will not receive them. Note that, you will still receive notifications for REQUIRED notification type even when it is DISABLED. + --integrations strings A comma-separated list of integration IDs to notify. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/resource-subscription/update/update-current-state.golden b/test/fixtures/output/notifications/resource-subscription/update/update-current-state.golden new file mode 100644 index 0000000000..8f87d9c89f --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/update/update-current-state.golden @@ -0,0 +1,8 @@ +Updated notifications resource subscription "resource-subscription-1". ++-------------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | CONNECTOR | +| Notification Type | not-abc123 | +| Current State | ENABLED | ++-------------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-subscription/update/update-integrations.golden b/test/fixtures/output/notifications/resource-subscription/update/update-integrations.golden new file mode 100644 index 0000000000..8f87d9c89f --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/update/update-integrations.golden @@ -0,0 +1,8 @@ +Updated notifications resource subscription "resource-subscription-1". ++-------------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | CONNECTOR | +| Notification Type | not-abc123 | +| Current State | ENABLED | ++-------------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-subscription/update/update-invalid.golden b/test/fixtures/output/notifications/resource-subscription/update/update-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/update/update-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/resource-subscription/update/update-resource-type.golden b/test/fixtures/output/notifications/resource-subscription/update/update-resource-type.golden new file mode 100644 index 0000000000..ff7e9c3cb8 --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/update/update-resource-type.golden @@ -0,0 +1,8 @@ +Updated notifications resource subscription "resource-subscription-1". ++-------------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | ENVIRONMENT | +| Notification Type | not-abc123 | +| Current State | ENABLED | ++-------------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/resource-subscription/update/update-resource.golden b/test/fixtures/output/notifications/resource-subscription/update/update-resource.golden new file mode 100644 index 0000000000..8f87d9c89f --- /dev/null +++ b/test/fixtures/output/notifications/resource-subscription/update/update-resource.golden @@ -0,0 +1,8 @@ +Updated notifications resource subscription "resource-subscription-1". ++-------------------+------------------------------------------------------------------------------+ +| ID | dlz-f3a90de | +| Resource | environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector | +| Resource Type | CONNECTOR | +| Notification Type | not-abc123 | +| Current State | ENABLED | ++-------------------+------------------------------------------------------------------------------+ diff --git a/test/fixtures/output/notifications/subscription/create-help.golden b/test/fixtures/output/notifications/subscription/create-help.golden new file mode 100644 index 0000000000..efb96f70dc --- /dev/null +++ b/test/fixtures/output/notifications/subscription/create-help.golden @@ -0,0 +1,16 @@ +Create a notifications subscription. + +Usage: + confluent notifications subscription create [flags] + +Flags: + --notification-type string REQUIRED: The type of notification to subscribe to. + --integrations strings REQUIRED: A comma-separated list of integration IDs to notify. + --current-state REQUIRED Denotes the state of the subscription. When the subscription is ENABLED, the user will receive notification on the configured integrations. If the subscription is DISABLED, the user will not receive any notification for the configured notification type. Note that, you cannot disable a subscription for REQUIRED notification type. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/subscription/create/create-current-state.golden b/test/fixtures/output/notifications/subscription/create/create-current-state.golden new file mode 100644 index 0000000000..1ceb1571f4 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/create/create-current-state.golden @@ -0,0 +1,5 @@ ++-------------------+-------------------------+ +| ID | dlz-f3a90de | +| Notification Type | notification-type-value | +| Current State | ENABLED | ++-------------------+-------------------------+ diff --git a/test/fixtures/output/notifications/subscription/create/create.golden b/test/fixtures/output/notifications/subscription/create/create.golden new file mode 100644 index 0000000000..1ceb1571f4 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/create/create.golden @@ -0,0 +1,5 @@ ++-------------------+-------------------------+ +| ID | dlz-f3a90de | +| Notification Type | notification-type-value | +| Current State | ENABLED | ++-------------------+-------------------------+ diff --git a/test/fixtures/output/notifications/subscription/delete-help.golden b/test/fixtures/output/notifications/subscription/delete-help.golden new file mode 100644 index 0000000000..cecb70a44c --- /dev/null +++ b/test/fixtures/output/notifications/subscription/delete-help.golden @@ -0,0 +1,13 @@ +Delete one or more notifications subscriptions. + +Usage: + confluent notifications subscription delete [id-2] ... [id-n] [flags] + +Flags: + --context string CLI context name. + --force Skip the deletion confirmation prompt. + +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). diff --git a/test/fixtures/output/notifications/subscription/delete/delete-autocomplete.golden b/test/fixtures/output/notifications/subscription/delete/delete-autocomplete.golden new file mode 100644 index 0000000000..675ab91838 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/delete/delete-autocomplete.golden @@ -0,0 +1,3 @@ +dlz-f3a90de +:4 +Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/test/fixtures/output/notifications/subscription/delete/delete-invalid.golden b/test/fixtures/output/notifications/subscription/delete/delete-invalid.golden new file mode 100644 index 0000000000..7d9ed5e044 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/delete/delete-invalid.golden @@ -0,0 +1,4 @@ +Error: notifications subscription "invalid" not found + +Suggestions: + List available notifications subscriptions with `confluent notifications subscription list`. diff --git a/test/fixtures/output/notifications/subscription/delete/delete-multiple.golden b/test/fixtures/output/notifications/subscription/delete/delete-multiple.golden new file mode 100644 index 0000000000..45ccb959bb --- /dev/null +++ b/test/fixtures/output/notifications/subscription/delete/delete-multiple.golden @@ -0,0 +1 @@ +Are you sure you want to delete notifications subscriptions "subscription-1" and "subscription-2"? (y/n): Deleted notifications subscriptions "subscription-1" and "subscription-2". diff --git a/test/fixtures/output/notifications/subscription/delete/delete-no-force.golden b/test/fixtures/output/notifications/subscription/delete/delete-no-force.golden new file mode 100644 index 0000000000..3fcb5cc2ea --- /dev/null +++ b/test/fixtures/output/notifications/subscription/delete/delete-no-force.golden @@ -0,0 +1 @@ +Are you sure you want to delete notifications subscription "subscription-1"? (y/n): Deleted notifications subscription "subscription-1". diff --git a/test/fixtures/output/notifications/subscription/delete/delete.golden b/test/fixtures/output/notifications/subscription/delete/delete.golden new file mode 100644 index 0000000000..8540007984 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/delete/delete.golden @@ -0,0 +1 @@ +Deleted notifications subscription "subscription-1". diff --git a/test/fixtures/output/notifications/subscription/describe-help.golden b/test/fixtures/output/notifications/subscription/describe-help.golden new file mode 100644 index 0000000000..4cacd73fa4 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/describe-help.golden @@ -0,0 +1,13 @@ +Describe a notifications subscription. + +Usage: + confluent notifications subscription describe [flags] + +Flags: + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/subscription/describe/describe-autocomplete.golden b/test/fixtures/output/notifications/subscription/describe/describe-autocomplete.golden new file mode 100644 index 0000000000..675ab91838 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/describe/describe-autocomplete.golden @@ -0,0 +1,3 @@ +dlz-f3a90de +:4 +Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/test/fixtures/output/notifications/subscription/describe/describe-invalid.golden b/test/fixtures/output/notifications/subscription/describe/describe-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/describe/describe-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/subscription/describe/describe-json.golden b/test/fixtures/output/notifications/subscription/describe/describe-json.golden new file mode 100644 index 0000000000..645327c353 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/describe/describe-json.golden @@ -0,0 +1,5 @@ +{ + "id": "dlz-f3a90de", + "notification_type": "not-abc123", + "current_state": "ENABLED" +} diff --git a/test/fixtures/output/notifications/subscription/describe/describe-yaml.golden b/test/fixtures/output/notifications/subscription/describe/describe-yaml.golden new file mode 100644 index 0000000000..8b662e123e --- /dev/null +++ b/test/fixtures/output/notifications/subscription/describe/describe-yaml.golden @@ -0,0 +1,3 @@ +id: dlz-f3a90de +notification_type: not-abc123 +current_state: ENABLED diff --git a/test/fixtures/output/notifications/subscription/describe/describe.golden b/test/fixtures/output/notifications/subscription/describe/describe.golden new file mode 100644 index 0000000000..5f6fd415a5 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/describe/describe.golden @@ -0,0 +1,5 @@ ++-------------------+-------------+ +| ID | dlz-f3a90de | +| Notification Type | not-abc123 | +| Current State | ENABLED | ++-------------------+-------------+ diff --git a/test/fixtures/output/notifications/subscription/help.golden b/test/fixtures/output/notifications/subscription/help.golden new file mode 100644 index 0000000000..ae9d23a354 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/help.golden @@ -0,0 +1,18 @@ +Manage Confluent Cloud notifications subscriptions. + +Usage: + confluent notifications subscription [command] + +Available Commands: + create Create a notifications subscription. + delete Delete one or more notifications subscriptions. + describe Describe a notifications subscription. + list List notifications subscriptions. + update Update an existing notifications subscription. + +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 notifications subscription [command] --help" for more information about a command. diff --git a/test/fixtures/output/notifications/subscription/list-help.golden b/test/fixtures/output/notifications/subscription/list-help.golden new file mode 100644 index 0000000000..1b74e7e006 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/list-help.golden @@ -0,0 +1,13 @@ +List notifications subscriptions. + +Usage: + confluent notifications subscription list [flags] + +Flags: + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/subscription/list/list-json.golden b/test/fixtures/output/notifications/subscription/list/list-json.golden new file mode 100644 index 0000000000..f96d2b6c04 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/list/list-json.golden @@ -0,0 +1,7 @@ +[ + { + "id": "dlz-f3a90de", + "notification_type": "not-abc123", + "current_state": "ENABLED" + } +] diff --git a/test/fixtures/output/notifications/subscription/list/list-yaml.golden b/test/fixtures/output/notifications/subscription/list/list-yaml.golden new file mode 100644 index 0000000000..f084192e2a --- /dev/null +++ b/test/fixtures/output/notifications/subscription/list/list-yaml.golden @@ -0,0 +1,3 @@ +- id: dlz-f3a90de + notification_type: not-abc123 + current_state: ENABLED diff --git a/test/fixtures/output/notifications/subscription/list/list.golden b/test/fixtures/output/notifications/subscription/list/list.golden new file mode 100644 index 0000000000..9c47adad23 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/list/list.golden @@ -0,0 +1,3 @@ + ID | Notification Type | Current State +--------------+-------------------+---------------- + dlz-f3a90de | not-abc123 | ENABLED diff --git a/test/fixtures/output/notifications/subscription/update-help.golden b/test/fixtures/output/notifications/subscription/update-help.golden new file mode 100644 index 0000000000..4ff87bc794 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/update-help.golden @@ -0,0 +1,15 @@ +Update an existing notifications subscription. + +Usage: + confluent notifications subscription update [flags] + +Flags: + --current-state REQUIRED Denotes the state of the subscription. When the subscription is ENABLED, the user will receive notification on the configured integrations. If the subscription is DISABLED, the user will not receive any notification for the configured notification type. Note that, you cannot disable a subscription for REQUIRED notification type. + --integrations strings A comma-separated list of integration IDs to notify. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/subscription/update/update-current-state.golden b/test/fixtures/output/notifications/subscription/update/update-current-state.golden new file mode 100644 index 0000000000..20ee7b5a5a --- /dev/null +++ b/test/fixtures/output/notifications/subscription/update/update-current-state.golden @@ -0,0 +1,6 @@ +Updated notifications subscription "subscription-1". ++-------------------+-------------+ +| ID | dlz-f3a90de | +| Notification Type | not-abc123 | +| Current State | ENABLED | ++-------------------+-------------+ diff --git a/test/fixtures/output/notifications/subscription/update/update-integrations.golden b/test/fixtures/output/notifications/subscription/update/update-integrations.golden new file mode 100644 index 0000000000..20ee7b5a5a --- /dev/null +++ b/test/fixtures/output/notifications/subscription/update/update-integrations.golden @@ -0,0 +1,6 @@ +Updated notifications subscription "subscription-1". ++-------------------+-------------+ +| ID | dlz-f3a90de | +| Notification Type | not-abc123 | +| Current State | ENABLED | ++-------------------+-------------+ diff --git a/test/fixtures/output/notifications/subscription/update/update-invalid.golden b/test/fixtures/output/notifications/subscription/update/update-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/subscription/update/update-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/user-notification/describe-help.golden b/test/fixtures/output/notifications/user-notification/describe-help.golden new file mode 100644 index 0000000000..532322269e --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/describe-help.golden @@ -0,0 +1,13 @@ +Describe a notifications user notification. + +Usage: + confluent notifications user-notification describe [flags] + +Flags: + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/user-notification/describe/describe-autocomplete.golden b/test/fixtures/output/notifications/user-notification/describe/describe-autocomplete.golden new file mode 100644 index 0000000000..675ab91838 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/describe/describe-autocomplete.golden @@ -0,0 +1,3 @@ +dlz-f3a90de +:4 +Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/test/fixtures/output/notifications/user-notification/describe/describe-invalid.golden b/test/fixtures/output/notifications/user-notification/describe/describe-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/describe/describe-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/user-notification/describe/describe-json.golden b/test/fixtures/output/notifications/user-notification/describe/describe-json.golden new file mode 100644 index 0000000000..56ff11d9e8 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/describe/describe-json.golden @@ -0,0 +1,7 @@ +{ + "id": "dlz-f3a90de", + "read_at": "2026-01-31T11:00:00Z", + "severity": "CRITICAL", + "received_at": "2026-01-31T10:35:00Z", + "read": false +} diff --git a/test/fixtures/output/notifications/user-notification/describe/describe-yaml.golden b/test/fixtures/output/notifications/user-notification/describe/describe-yaml.golden new file mode 100644 index 0000000000..0b6a26f37c --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/describe/describe-yaml.golden @@ -0,0 +1,5 @@ +id: dlz-f3a90de +read_at: "2026-01-31T11:00:00Z" +severity: CRITICAL +received_at: "2026-01-31T10:35:00Z" +read: false diff --git a/test/fixtures/output/notifications/user-notification/describe/describe.golden b/test/fixtures/output/notifications/user-notification/describe/describe.golden new file mode 100644 index 0000000000..6b619eaeac --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/describe/describe.golden @@ -0,0 +1,7 @@ ++-------------+----------------------+ +| ID | dlz-f3a90de | +| Read At | 2026-01-31T11:00:00Z | +| Severity | CRITICAL | +| Received At | 2026-01-31T10:35:00Z | +| Read | false | ++-------------+----------------------+ diff --git a/test/fixtures/output/notifications/user-notification/help.golden b/test/fixtures/output/notifications/user-notification/help.golden new file mode 100644 index 0000000000..b63486e8c3 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/help.golden @@ -0,0 +1,16 @@ +Manage Confluent Cloud notifications user notifications. + +Usage: + confluent notifications user-notification [command] + +Available Commands: + describe Describe a notifications user notification. + list List notifications user notifications. + update Update an existing notifications user notification. + +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 notifications user-notification [command] --help" for more information about a command. diff --git a/test/fixtures/output/notifications/user-notification/list-help.golden b/test/fixtures/output/notifications/user-notification/list-help.golden new file mode 100644 index 0000000000..991989fbea --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list-help.golden @@ -0,0 +1,21 @@ +List notifications user notifications. + +Usage: + confluent notifications user-notification list [flags] + +Flags: + --read Filter the results where read is true or false. + --severity strings A comma-separated list of severity levels to filter by. + --include integrations Comma-separated list of optional fields to populate in the response items. Allowed values: integrations, `recommended_actions`. By default these fields are omitted from list responses to keep collection payloads slim; set this parameter to opt in. This is a partial-response selector, not a value filter. + --type strings A comma-separated list of Confluent Cloud resource types to filter by. + --crn strings A comma-separated list of Confluent Cloud resource CRNs to filter by. + --search display_name Free-text partial-match search across the embedded notification type's display_name and `description`. + --time-range PAST_24H Filter notifications by a preset time window relative to now. Allowed values: PAST_24H (last 24 hours), `PAST_7D` (last 7 days), `PAST_30D` (last 30 days). + --sort strings A comma-separated list of fields and directions to sort by. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/user-notification/list/list-crn.golden b/test/fixtures/output/notifications/user-notification/list/list-crn.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-crn.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/list/list-include.golden b/test/fixtures/output/notifications/user-notification/list/list-include.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-include.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/list/list-json.golden b/test/fixtures/output/notifications/user-notification/list/list-json.golden new file mode 100644 index 0000000000..37b2256b74 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-json.golden @@ -0,0 +1,9 @@ +[ + { + "id": "dlz-f3a90de", + "read_at": "2026-01-31T11:00:00Z", + "severity": "CRITICAL", + "received_at": "2026-01-31T10:35:00Z", + "read": false + } +] diff --git a/test/fixtures/output/notifications/user-notification/list/list-read.golden b/test/fixtures/output/notifications/user-notification/list/list-read.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-read.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/list/list-search.golden b/test/fixtures/output/notifications/user-notification/list/list-search.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-search.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/list/list-severity.golden b/test/fixtures/output/notifications/user-notification/list/list-severity.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-severity.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/list/list-sort.golden b/test/fixtures/output/notifications/user-notification/list/list-sort.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-sort.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/list/list-time-range.golden b/test/fixtures/output/notifications/user-notification/list/list-time-range.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-time-range.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/list/list-type.golden b/test/fixtures/output/notifications/user-notification/list/list-type.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-type.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/list/list-yaml.golden b/test/fixtures/output/notifications/user-notification/list/list-yaml.golden new file mode 100644 index 0000000000..fcc48424c0 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list-yaml.golden @@ -0,0 +1,5 @@ +- id: dlz-f3a90de + read_at: "2026-01-31T11:00:00Z" + severity: CRITICAL + received_at: "2026-01-31T10:35:00Z" + read: false diff --git a/test/fixtures/output/notifications/user-notification/list/list.golden b/test/fixtures/output/notifications/user-notification/list/list.golden new file mode 100644 index 0000000000..ac8af4eb40 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/list/list.golden @@ -0,0 +1,3 @@ + ID | Read At | Severity | Received At | Read +--------------+----------------------+----------+----------------------+-------- + dlz-f3a90de | 2026-01-31T11:00:00Z | CRITICAL | 2026-01-31T10:35:00Z | false diff --git a/test/fixtures/output/notifications/user-notification/update-help.golden b/test/fixtures/output/notifications/user-notification/update-help.golden new file mode 100644 index 0000000000..4c57f383f4 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/update-help.golden @@ -0,0 +1,14 @@ +Update an existing notifications user notification. + +Usage: + confluent notifications user-notification update [flags] + +Flags: + --read Whether the notification has been read by the user. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") + +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). diff --git a/test/fixtures/output/notifications/user-notification/update/update-invalid.golden b/test/fixtures/output/notifications/user-notification/update/update-invalid.golden new file mode 100644 index 0000000000..716b863527 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/update/update-invalid.golden @@ -0,0 +1 @@ +Error: 404 Not Found diff --git a/test/fixtures/output/notifications/user-notification/update/update-read.golden b/test/fixtures/output/notifications/user-notification/update/update-read.golden new file mode 100644 index 0000000000..18e1772312 --- /dev/null +++ b/test/fixtures/output/notifications/user-notification/update/update-read.golden @@ -0,0 +1,8 @@ +Updated notifications user notification "user-notification-1". ++-------------+----------------------+ +| ID | dlz-f3a90de | +| Read At | 2026-01-31T11:00:00Z | +| Severity | CRITICAL | +| Received At | 2026-01-31T10:35:00Z | +| Read | true | ++-------------+----------------------+ diff --git a/test/live/live_test.go b/test/live/live_test.go index e067c6993e..5e7f872d05 100644 --- a/test/live/live_test.go +++ b/test/live/live_test.go @@ -378,29 +378,30 @@ func substituteStateVars(t *testing.T, s string, state *LiveTestState) string { return buf.String() } -// extractID extracts the "id" field from JSON output. +// extractID extracts the "id" field from JSON output. A list command's JSON output is a +// top-level array, so the id comes from its first element; a describe command's is a top-level +// object. func extractID(t *testing.T, output string) string { t.Helper() trimmed := strings.TrimSpace(output) - var parsed map[string]interface{} - if err := json.Unmarshal([]byte(trimmed), &parsed); err != nil { - // Not JSON — try to extract from table-style output (first column of second line) - lines := strings.Split(trimmed, "\n") - for i, line := range lines { - if i == 0 { - continue // skip header - } - fields := strings.Fields(line) - if len(fields) > 0 { - return fields[0] - } + + var array []map[string]interface{} + if err := json.Unmarshal([]byte(trimmed), &array); err == nil { + if len(array) == 0 { + return "" + } + if id, ok := array[0]["id"]; ok { + return fmt.Sprintf("%v", id) } return "" } - if id, ok := parsed["id"]; ok { - return fmt.Sprintf("%v", id) + var object map[string]interface{} + if err := json.Unmarshal([]byte(trimmed), &object); err == nil { + if id, ok := object["id"]; ok { + return fmt.Sprintf("%v", id) + } } return "" } diff --git a/test/live/notifications_integration_live_test.go b/test/live/notifications_integration_live_test.go new file mode 100644 index 0000000000..7af8af8c02 --- /dev/null +++ b/test/live/notifications_integration_live_test.go @@ -0,0 +1,258 @@ +//go:build live_test && (all || notifications) + +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package live + +import ( + "testing" +) + +func (s *CLILiveTestSuite) TestNotificationsIntegrationSlackTargetCRUDLive() { + t := s.T() + t.Parallel() + state := s.setupTestContext(t) + + // Variables + integrationName := uniqueName("integr") + kindVariant := "slack" + webhookUrl := "https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx" + updatedDescription := "updated-live-test-description" + + // Cleanup (LIFO — execution is reverse-registration order) + s.registerCleanup(t, "notifications integration delete {{.integration_id}} --force", state) + + steps := []CLILiveTest{ + { + Name: "Create notifications integration (slack_target)", + Args: "notifications integration create " + integrationName + " --kind " + kindVariant + " --webhook-url " + webhookUrl + " -o json", + ExitCode: 0, + JSONFields: map[string]string{ + "name": integrationName, + }, + JSONFieldsExist: []string{"id"}, + CaptureID: "integration_id", + }, + { + Name: "Describe notifications integration", + Args: "notifications integration describe {{.integration_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "name": integrationName, + }, + }, + { + Name: "List notifications integrations", + Args: "notifications integration list -o json", + UseStateVars: true, + ExitCode: 0, + Contains: []string{integrationName}, + }, + { + Name: "Update notifications integration name", + Args: "notifications integration update {{.integration_id}} --display-name " + integrationName + "-updated", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications integration description", + Args: "notifications integration update {{.integration_id}} --description " + updatedDescription, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify notifications integration update", + Args: "notifications integration describe {{.integration_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "description": updatedDescription, + }, + }, + { + Name: "Delete notifications integration", + Args: "notifications integration delete {{.integration_id}} --force", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify deletion", + Args: "notifications integration describe {{.integration_id}}", + UseStateVars: true, + ExitCode: 1, + }, + } + + for _, step := range steps { + t.Run(step.Name, func(t *testing.T) { + s.runLiveCommand(t, step, state) + }) + } +} + +func (s *CLILiveTestSuite) TestNotificationsIntegrationWebhookTargetCRUDLive() { + t := s.T() + t.Parallel() + state := s.setupTestContext(t) + + // Variables + integrationName := uniqueName("integr") + kindVariant := "webhook" + url := "https://my.webhook.url/00000000-0000-0000-0000-000000000000" + updatedDescription := "updated-live-test-description" + + // Cleanup (LIFO — execution is reverse-registration order) + s.registerCleanup(t, "notifications integration delete {{.integration_id}} --force", state) + + steps := []CLILiveTest{ + { + Name: "Create notifications integration (webhook_target)", + Args: "notifications integration create " + integrationName + " --kind " + kindVariant + " --url " + url + " -o json", + ExitCode: 0, + JSONFields: map[string]string{ + "name": integrationName, + }, + JSONFieldsExist: []string{"id"}, + CaptureID: "integration_id", + }, + { + Name: "Describe notifications integration", + Args: "notifications integration describe {{.integration_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "name": integrationName, + }, + }, + { + Name: "List notifications integrations", + Args: "notifications integration list -o json", + UseStateVars: true, + ExitCode: 0, + Contains: []string{integrationName}, + }, + { + Name: "Update notifications integration name", + Args: "notifications integration update {{.integration_id}} --display-name " + integrationName + "-updated", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications integration description", + Args: "notifications integration update {{.integration_id}} --description " + updatedDescription, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify notifications integration update", + Args: "notifications integration describe {{.integration_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "description": updatedDescription, + }, + }, + { + Name: "Delete notifications integration", + Args: "notifications integration delete {{.integration_id}} --force", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify deletion", + Args: "notifications integration describe {{.integration_id}}", + UseStateVars: true, + ExitCode: 1, + }, + } + + for _, step := range steps { + t.Run(step.Name, func(t *testing.T) { + s.runLiveCommand(t, step, state) + }) + } +} + +func (s *CLILiveTestSuite) TestNotificationsIntegrationMsTeamsTargetCRUDLive() { + t := s.T() + t.Parallel() + state := s.setupTestContext(t) + + // Variables + integrationName := uniqueName("integr") + kindVariant := "msteams" + webhookUrl := "https://admin.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000/IncomingWebhook/00000000000000000000000000000000/00000000-0000-0000-0000-000000000000" + updatedDescription := "updated-live-test-description" + + // Cleanup (LIFO — execution is reverse-registration order) + s.registerCleanup(t, "notifications integration delete {{.integration_id}} --force", state) + + steps := []CLILiveTest{ + { + Name: "Create notifications integration (ms_teams_target)", + Args: "notifications integration create " + integrationName + " --kind " + kindVariant + " --webhook-url " + webhookUrl + " -o json", + ExitCode: 0, + JSONFields: map[string]string{ + "name": integrationName, + }, + JSONFieldsExist: []string{"id"}, + CaptureID: "integration_id", + }, + { + Name: "Describe notifications integration", + Args: "notifications integration describe {{.integration_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "name": integrationName, + }, + }, + { + Name: "List notifications integrations", + Args: "notifications integration list -o json", + UseStateVars: true, + ExitCode: 0, + Contains: []string{integrationName}, + }, + { + Name: "Update notifications integration name", + Args: "notifications integration update {{.integration_id}} --display-name " + integrationName + "-updated", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications integration description", + Args: "notifications integration update {{.integration_id}} --description " + updatedDescription, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify notifications integration update", + Args: "notifications integration describe {{.integration_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "description": updatedDescription, + }, + }, + { + Name: "Delete notifications integration", + Args: "notifications integration delete {{.integration_id}} --force", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify deletion", + Args: "notifications integration describe {{.integration_id}}", + UseStateVars: true, + ExitCode: 1, + }, + } + + for _, step := range steps { + t.Run(step.Name, func(t *testing.T) { + s.runLiveCommand(t, step, state) + }) + } +} diff --git a/test/live/notifications_notification_type_live_test.go b/test/live/notifications_notification_type_live_test.go new file mode 100644 index 0000000000..8a9a09d2a1 --- /dev/null +++ b/test/live/notifications_notification_type_live_test.go @@ -0,0 +1,39 @@ +//go:build live_test && (all || notifications) + +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package live + +import ( + "testing" +) + +func (s *CLILiveTestSuite) TestNotificationsNotificationTypeCRUDLive() { + t := s.T() + t.Parallel() + state := s.setupTestContext(t) + + // Cleanup (LIFO — execution is reverse-registration order) + + steps := []CLILiveTest{ + { + Name: "List notifications notification types", + Args: "notifications notification-type list -o json", + UseStateVars: true, + ExitCode: 0, + CaptureID: "notification_type_id", + }, + { + Name: "Describe notifications notification type", + Args: "notifications notification-type describe {{.notification_type_id}} -o json", + UseStateVars: true, + ExitCode: 0, + }, + } + + for _, step := range steps { + t.Run(step.Name, func(t *testing.T) { + s.runLiveCommand(t, step, state) + }) + } +} diff --git a/test/live/notifications_resource_preference_live_test.go b/test/live/notifications_resource_preference_live_test.go new file mode 100644 index 0000000000..1690438f65 --- /dev/null +++ b/test/live/notifications_resource_preference_live_test.go @@ -0,0 +1,89 @@ +//go:build live_test && (all || notifications) + +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package live + +import ( + "testing" +) + +func (s *CLILiveTestSuite) TestNotificationsResourcePreferenceCRUDLive() { + t := s.T() + t.Parallel() + state := s.setupTestContext(t) + + // Variables + resource := "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector" + resourceType := "CONNECTOR" + updatedResource := "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector-updated" + updatedResourceType := "CONNECTOR-updated" + updatedCurrentState := "ENABLED-updated" + + // Cleanup (LIFO — execution is reverse-registration order) + s.registerCleanup(t, "notifications resource-preference delete {{.resource_preference_id}} --force", state) + + steps := []CLILiveTest{ + { + Name: "Create notifications resource preference", + Args: "notifications resource-preference create --resource " + resource + " --resource-type " + resourceType + " -o json", + ExitCode: 0, + JSONFieldsExist: []string{"id", "resource", "resource_type"}, + CaptureID: "resource_preference_id", + }, + { + Name: "Describe notifications resource preference", + Args: "notifications resource-preference describe {{.resource_preference_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFieldsExist: []string{"resource", "resource_type"}, + }, + { + Name: "Update notifications resource preference resource", + Args: "notifications resource-preference update {{.resource_preference_id}} --resource " + updatedResource, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications resource preference resource-type", + Args: "notifications resource-preference update {{.resource_preference_id}} --resource-type " + updatedResourceType, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications resource preference current-state", + Args: "notifications resource-preference update {{.resource_preference_id}} --current-state " + updatedCurrentState, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify notifications resource preference update", + Args: "notifications resource-preference describe {{.resource_preference_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "resource": updatedResource, + "resource_type": updatedResourceType, + "current_state": updatedCurrentState, + }, + }, + { + Name: "Delete notifications resource preference", + Args: "notifications resource-preference delete {{.resource_preference_id}} --force", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify deletion", + Args: "notifications resource-preference describe {{.resource_preference_id}}", + UseStateVars: true, + ExitCode: 1, + }, + } + + for _, step := range steps { + t.Run(step.Name, func(t *testing.T) { + s.runLiveCommand(t, step, state) + }) + } +} diff --git a/test/live/notifications_resource_subscription_live_test.go b/test/live/notifications_resource_subscription_live_test.go new file mode 100644 index 0000000000..d64f5f9796 --- /dev/null +++ b/test/live/notifications_resource_subscription_live_test.go @@ -0,0 +1,103 @@ +//go:build live_test && (all || notifications) + +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package live + +import ( + "os" + "testing" +) + +func (s *CLILiveTestSuite) TestNotificationsResourceSubscriptionCRUDLive() { + t := s.T() + t.Parallel() + state := s.setupTestContext(t) + + // Variables + resource := "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector" + resourceType := "CONNECTOR" + integrations := "live-test-integrations" + updatedResource := "environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector-updated" + updatedResourceType := "CONNECTOR-updated" + updatedCurrentState := "ENABLED-updated" + updatedIntegrations := "updated-live-test-integrations" + notificationType := os.Getenv("CONFLUENT_LIVE_TEST_NOTIFICATION_TYPE_ID") + if notificationType == "" { + t.Skipf("%s must be set to run this live test (notification type ID)", "CONFLUENT_LIVE_TEST_NOTIFICATION_TYPE_ID") + } + + // Cleanup (LIFO — execution is reverse-registration order) + s.registerCleanup(t, "notifications resource-subscription delete {{.resource_subscription_id}} --force", state) + + steps := []CLILiveTest{ + { + Name: "Create notifications resource subscription", + Args: "notifications resource-subscription create --resource " + resource + " --resource-type " + resourceType + " --notification-type " + notificationType + " --integrations " + integrations + " -o json", + ExitCode: 0, + JSONFieldsExist: []string{"id", "resource", "resource_type", "integrations"}, + CaptureID: "resource_subscription_id", + }, + { + Name: "Describe notifications resource subscription", + Args: "notifications resource-subscription describe {{.resource_subscription_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFieldsExist: []string{"resource", "resource_type", "integrations"}, + }, + { + Name: "Update notifications resource subscription resource", + Args: "notifications resource-subscription update {{.resource_subscription_id}} --resource " + updatedResource, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications resource subscription resource-type", + Args: "notifications resource-subscription update {{.resource_subscription_id}} --resource-type " + updatedResourceType, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications resource subscription current-state", + Args: "notifications resource-subscription update {{.resource_subscription_id}} --current-state " + updatedCurrentState, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications resource subscription integrations", + Args: "notifications resource-subscription update {{.resource_subscription_id}} --integrations " + updatedIntegrations, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify notifications resource subscription update", + Args: "notifications resource-subscription describe {{.resource_subscription_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "resource": updatedResource, + "resource_type": updatedResourceType, + "current_state": updatedCurrentState, + "integrations": updatedIntegrations, + }, + }, + { + Name: "Delete notifications resource subscription", + Args: "notifications resource-subscription delete {{.resource_subscription_id}} --force", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify deletion", + Args: "notifications resource-subscription describe {{.resource_subscription_id}}", + UseStateVars: true, + ExitCode: 1, + }, + } + + for _, step := range steps { + t.Run(step.Name, func(t *testing.T) { + s.runLiveCommand(t, step, state) + }) + } +} diff --git a/test/live/notifications_subscription_live_test.go b/test/live/notifications_subscription_live_test.go new file mode 100644 index 0000000000..78d9286597 --- /dev/null +++ b/test/live/notifications_subscription_live_test.go @@ -0,0 +1,91 @@ +//go:build live_test && (all || notifications) + +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package live + +import ( + "os" + "testing" +) + +func (s *CLILiveTestSuite) TestNotificationsSubscriptionCRUDLive() { + t := s.T() + t.Parallel() + state := s.setupTestContext(t) + + // Variables + integrations := "live-test-integrations" + updatedCurrentState := "ENABLED-updated" + updatedIntegrations := "updated-live-test-integrations" + notificationType := os.Getenv("CONFLUENT_LIVE_TEST_NOTIFICATION_TYPE_ID") + if notificationType == "" { + t.Skipf("%s must be set to run this live test (notification type ID)", "CONFLUENT_LIVE_TEST_NOTIFICATION_TYPE_ID") + } + + // Cleanup (LIFO — execution is reverse-registration order) + s.registerCleanup(t, "notifications subscription delete {{.subscription_id}} --force", state) + + steps := []CLILiveTest{ + { + Name: "Create notifications subscription", + Args: "notifications subscription create --notification-type " + notificationType + " --integrations " + integrations + " -o json", + ExitCode: 0, + JSONFieldsExist: []string{"id", "integrations"}, + CaptureID: "subscription_id", + }, + { + Name: "Describe notifications subscription", + Args: "notifications subscription describe {{.subscription_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFieldsExist: []string{"integrations"}, + }, + { + Name: "List notifications subscriptions", + Args: "notifications subscription list -o json", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications subscription current-state", + Args: "notifications subscription update {{.subscription_id}} --current-state " + updatedCurrentState, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications subscription integrations", + Args: "notifications subscription update {{.subscription_id}} --integrations " + updatedIntegrations, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify notifications subscription update", + Args: "notifications subscription describe {{.subscription_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "current_state": updatedCurrentState, + "integrations": updatedIntegrations, + }, + }, + { + Name: "Delete notifications subscription", + Args: "notifications subscription delete {{.subscription_id}} --force", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify deletion", + Args: "notifications subscription describe {{.subscription_id}}", + UseStateVars: true, + ExitCode: 1, + }, + } + + for _, step := range steps { + t.Run(step.Name, func(t *testing.T) { + s.runLiveCommand(t, step, state) + }) + } +} diff --git a/test/live/notifications_user_notification_live_test.go b/test/live/notifications_user_notification_live_test.go new file mode 100644 index 0000000000..fb69ca5d97 --- /dev/null +++ b/test/live/notifications_user_notification_live_test.go @@ -0,0 +1,57 @@ +//go:build live_test && (all || notifications) + +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package live + +import ( + "testing" +) + +func (s *CLILiveTestSuite) TestNotificationsUserNotificationCRUDLive() { + t := s.T() + t.Parallel() + state := s.setupTestContext(t) + + // Variables + updatedRead := "true" + + // Cleanup (LIFO — execution is reverse-registration order) + + steps := []CLILiveTest{ + { + Name: "List notifications user notifications", + Args: "notifications user-notification list -o json", + UseStateVars: true, + ExitCode: 0, + CaptureID: "user_notification_id", + }, + { + Name: "Describe notifications user notification", + Args: "notifications user-notification describe {{.user_notification_id}} -o json", + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Update notifications user notification read", + Args: "notifications user-notification update {{.user_notification_id}} --read=" + updatedRead, + UseStateVars: true, + ExitCode: 0, + }, + { + Name: "Verify notifications user notification update", + Args: "notifications user-notification describe {{.user_notification_id}} -o json", + UseStateVars: true, + ExitCode: 0, + JSONFields: map[string]string{ + "read": updatedRead, + }, + }, + } + + for _, step := range steps { + t.Run(step.Name, func(t *testing.T) { + s.runLiveCommand(t, step, state) + }) + } +} diff --git a/test/notifications_integration_test.go b/test/notifications_integration_test.go new file mode 100644 index 0000000000..c982950cf4 --- /dev/null +++ b/test/notifications_integration_test.go @@ -0,0 +1,91 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package test + +func (s *CLITestSuite) TestNotificationsIntegrationCreate() { + tests := []CLITest{ + {args: "notifications integration create test-name --kind slack --webhook-url https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx --description \"A Slack channel integration\"", fixture: "notifications/integration/create/create-description.golden"}, + {args: "notifications integration create test-name --kind slack --webhook-url https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx", fixture: "notifications/integration/create/create-slack-target.golden"}, + {args: "notifications integration create test-name --kind webhook --url https://my.webhook.url/00000000-0000-0000-0000-000000000000", fixture: "notifications/integration/create/create-webhook-target.golden"}, + {args: "notifications integration create test-name --kind msteams --webhook-url https://admin.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000/IncomingWebhook/00000000000000000000000000000000/00000000-0000-0000-0000-000000000000", fixture: "notifications/integration/create/create-ms-teams-target.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsIntegrationDelete() { + tests := []CLITest{ + {args: "notifications integration delete integration-1 --force", fixture: "notifications/integration/delete/delete.golden"}, + {args: "notifications integration delete integration-1", input: "y\n", fixture: "notifications/integration/delete/delete-no-force.golden"}, + {args: "notifications integration delete integration-1 integration-2", input: "y\n", fixture: "notifications/integration/delete/delete-multiple.golden"}, + {args: "notifications integration delete invalid", fixture: "notifications/integration/delete/delete-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsIntegrationDescribe() { + tests := []CLITest{ + {args: "notifications integration describe integration-1", fixture: "notifications/integration/describe/describe-slack-target.golden"}, + {args: "notifications integration describe integration-2", fixture: "notifications/integration/describe/describe-role-email-target.golden"}, + {args: "notifications integration describe integration-3", fixture: "notifications/integration/describe/describe-user-email-target.golden"}, + {args: "notifications integration describe integration-4", fixture: "notifications/integration/describe/describe-webhook-target.golden"}, + {args: "notifications integration describe integration-5", fixture: "notifications/integration/describe/describe-ms-teams-target.golden"}, + {args: "notifications integration describe integration-6", fixture: "notifications/integration/describe/describe-in-app-target.golden"}, + {args: "notifications integration describe integration-1 -o json", fixture: "notifications/integration/describe/describe-json.golden"}, + {args: "notifications integration describe integration-1 -o yaml", fixture: "notifications/integration/describe/describe-yaml.golden"}, + {args: "notifications integration describe invalid", fixture: "notifications/integration/describe/describe-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsIntegrationList() { + tests := []CLITest{ + {args: "notifications integration list", fixture: "notifications/integration/list/list.golden"}, + {args: "notifications integration list -o json", fixture: "notifications/integration/list/list-json.golden"}, + {args: "notifications integration list -o yaml", fixture: "notifications/integration/list/list-yaml.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsIntegrationUpdate() { + tests := []CLITest{ + {args: "notifications integration update integration-1 --display-name \"Slack integration\"", fixture: "notifications/integration/update/update-display-name.golden"}, + {args: "notifications integration update integration-1 --description \"A Slack channel integration\"", fixture: "notifications/integration/update/update-description.golden"}, + {args: "notifications integration update integration-1 --kind slack --webhook-url https://hooks.slack.com/services/T000AAAA0/B000BBBB0/xxxxxxxxxxxxxxxxxxxxxxxx", fixture: "notifications/integration/update/update-slack-target.golden"}, + {args: "notifications integration update integration-1 --kind webhook --url https://my.webhook.url/00000000-0000-0000-0000-000000000000", fixture: "notifications/integration/update/update-webhook-target.golden"}, + {args: "notifications integration update integration-1 --kind msteams --webhook-url https://admin.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000/IncomingWebhook/00000000000000000000000000000000/00000000-0000-0000-0000-000000000000", fixture: "notifications/integration/update/update-ms-teams-target.golden"}, + {args: "notifications integration update invalid", fixture: "notifications/integration/update/update-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsIntegration_Autocomplete() { + tests := []CLITest{ + {args: "__complete notifications integration delete \"\"", fixture: "notifications/integration/delete/delete-autocomplete.golden"}, + {args: "__complete notifications integration describe \"\"", fixture: "notifications/integration/describe/describe-autocomplete.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} diff --git a/test/notifications_notification_type_test.go b/test/notifications_notification_type_test.go new file mode 100644 index 0000000000..8d88a60c97 --- /dev/null +++ b/test/notifications_notification_type_test.go @@ -0,0 +1,42 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package test + +func (s *CLITestSuite) TestNotificationsNotificationTypeDescribe() { + tests := []CLITest{ + {args: "notifications notification-type describe notification-type-1", fixture: "notifications/notification-type/describe/describe.golden"}, + {args: "notifications notification-type describe notification-type-1 -o json", fixture: "notifications/notification-type/describe/describe-json.golden"}, + {args: "notifications notification-type describe notification-type-1 -o yaml", fixture: "notifications/notification-type/describe/describe-yaml.golden"}, + {args: "notifications notification-type describe invalid", fixture: "notifications/notification-type/describe/describe-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsNotificationTypeList() { + tests := []CLITest{ + {args: "notifications notification-type list", fixture: "notifications/notification-type/list/list.golden"}, + {args: "notifications notification-type list --resource-type resource-type-value", fixture: "notifications/notification-type/list/list-resource-type.golden"}, + {args: "notifications notification-type list -o json", fixture: "notifications/notification-type/list/list-json.golden"}, + {args: "notifications notification-type list -o yaml", fixture: "notifications/notification-type/list/list-yaml.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsNotificationType_Autocomplete() { + tests := []CLITest{ + {args: "__complete notifications notification-type describe \"\"", fixture: "notifications/notification-type/describe/describe-autocomplete.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} diff --git a/test/notifications_resource_preference_test.go b/test/notifications_resource_preference_test.go new file mode 100644 index 0000000000..f32c21d757 --- /dev/null +++ b/test/notifications_resource_preference_test.go @@ -0,0 +1,57 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package test + +func (s *CLITestSuite) TestNotificationsResourcePreferenceCreate() { + tests := []CLITest{ + {args: "notifications resource-preference create --resource environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector --resource-type organization", fixture: "notifications/resource-preference/create/create.golden"}, + {args: "notifications resource-preference create --resource environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector --resource-type organization --current-state enabled", fixture: "notifications/resource-preference/create/create-current-state.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsResourcePreferenceDelete() { + tests := []CLITest{ + {args: "notifications resource-preference delete resource-preference-1 --force", fixture: "notifications/resource-preference/delete/delete.golden"}, + {args: "notifications resource-preference delete resource-preference-1", input: "y\n", fixture: "notifications/resource-preference/delete/delete-no-force.golden"}, + {args: "notifications resource-preference delete resource-preference-1 resource-preference-2", input: "y\n", fixture: "notifications/resource-preference/delete/delete-multiple.golden"}, + {args: "notifications resource-preference delete invalid", fixture: "notifications/resource-preference/delete/delete-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsResourcePreferenceDescribe() { + tests := []CLITest{ + {args: "notifications resource-preference describe resource-preference-1", fixture: "notifications/resource-preference/describe/describe.golden"}, + {args: "notifications resource-preference describe resource-preference-1 -o json", fixture: "notifications/resource-preference/describe/describe-json.golden"}, + {args: "notifications resource-preference describe resource-preference-1 -o yaml", fixture: "notifications/resource-preference/describe/describe-yaml.golden"}, + {args: "notifications resource-preference describe invalid", fixture: "notifications/resource-preference/describe/describe-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsResourcePreferenceUpdate() { + tests := []CLITest{ + {args: "notifications resource-preference update resource-preference-1 --resource environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector", fixture: "notifications/resource-preference/update/update-resource.golden"}, + {args: "notifications resource-preference update resource-preference-1 --resource-type organization", fixture: "notifications/resource-preference/update/update-resource-type.golden"}, + {args: "notifications resource-preference update resource-preference-1 --current-state enabled", fixture: "notifications/resource-preference/update/update-current-state.golden"}, + {args: "notifications resource-preference update invalid", fixture: "notifications/resource-preference/update/update-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} diff --git a/test/notifications_resource_subscription_test.go b/test/notifications_resource_subscription_test.go new file mode 100644 index 0000000000..d7b8f82a87 --- /dev/null +++ b/test/notifications_resource_subscription_test.go @@ -0,0 +1,58 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package test + +func (s *CLITestSuite) TestNotificationsResourceSubscriptionCreate() { + tests := []CLITest{ + {args: "notifications resource-subscription create --integrations val1,val2 --notification-type notification-type-value --resource environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector --resource-type environment", fixture: "notifications/resource-subscription/create/create.golden"}, + {args: "notifications resource-subscription create --integrations val1,val2 --notification-type notification-type-value --resource environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector --resource-type environment --current-state enabled", fixture: "notifications/resource-subscription/create/create-current-state.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsResourceSubscriptionDelete() { + tests := []CLITest{ + {args: "notifications resource-subscription delete resource-subscription-1 --force", fixture: "notifications/resource-subscription/delete/delete.golden"}, + {args: "notifications resource-subscription delete resource-subscription-1", input: "y\n", fixture: "notifications/resource-subscription/delete/delete-no-force.golden"}, + {args: "notifications resource-subscription delete resource-subscription-1 resource-subscription-2", input: "y\n", fixture: "notifications/resource-subscription/delete/delete-multiple.golden"}, + {args: "notifications resource-subscription delete invalid", fixture: "notifications/resource-subscription/delete/delete-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsResourceSubscriptionDescribe() { + tests := []CLITest{ + {args: "notifications resource-subscription describe resource-subscription-1", fixture: "notifications/resource-subscription/describe/describe.golden"}, + {args: "notifications resource-subscription describe resource-subscription-1 -o json", fixture: "notifications/resource-subscription/describe/describe-json.golden"}, + {args: "notifications resource-subscription describe resource-subscription-1 -o yaml", fixture: "notifications/resource-subscription/describe/describe-yaml.golden"}, + {args: "notifications resource-subscription describe invalid", fixture: "notifications/resource-subscription/describe/describe-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsResourceSubscriptionUpdate() { + tests := []CLITest{ + {args: "notifications resource-subscription update resource-subscription-1 --resource environment=env-456xy/cloud-cluster=lkc-df123/connector=my_datagen_connector", fixture: "notifications/resource-subscription/update/update-resource.golden"}, + {args: "notifications resource-subscription update resource-subscription-1 --resource-type environment", fixture: "notifications/resource-subscription/update/update-resource-type.golden"}, + {args: "notifications resource-subscription update resource-subscription-1 --current-state enabled", fixture: "notifications/resource-subscription/update/update-current-state.golden"}, + {args: "notifications resource-subscription update resource-subscription-1 --integrations val1,val2", fixture: "notifications/resource-subscription/update/update-integrations.golden"}, + {args: "notifications resource-subscription update invalid", fixture: "notifications/resource-subscription/update/update-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} diff --git a/test/notifications_subscription_test.go b/test/notifications_subscription_test.go new file mode 100644 index 0000000000..8857b1bebb --- /dev/null +++ b/test/notifications_subscription_test.go @@ -0,0 +1,81 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package test + +func (s *CLITestSuite) TestNotificationsSubscriptionCreate() { + tests := []CLITest{ + {args: "notifications subscription create --integrations val1,val2 --notification-type notification-type-value", fixture: "notifications/subscription/create/create.golden"}, + {args: "notifications subscription create --integrations val1,val2 --notification-type notification-type-value --current-state enabled", fixture: "notifications/subscription/create/create-current-state.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsSubscriptionDelete() { + tests := []CLITest{ + {args: "notifications subscription delete subscription-1 --force", fixture: "notifications/subscription/delete/delete.golden"}, + {args: "notifications subscription delete subscription-1", input: "y\n", fixture: "notifications/subscription/delete/delete-no-force.golden"}, + {args: "notifications subscription delete subscription-1 subscription-2", input: "y\n", fixture: "notifications/subscription/delete/delete-multiple.golden"}, + {args: "notifications subscription delete invalid", fixture: "notifications/subscription/delete/delete-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsSubscriptionDescribe() { + tests := []CLITest{ + {args: "notifications subscription describe subscription-1", fixture: "notifications/subscription/describe/describe.golden"}, + {args: "notifications subscription describe subscription-1 -o json", fixture: "notifications/subscription/describe/describe-json.golden"}, + {args: "notifications subscription describe subscription-1 -o yaml", fixture: "notifications/subscription/describe/describe-yaml.golden"}, + {args: "notifications subscription describe invalid", fixture: "notifications/subscription/describe/describe-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsSubscriptionList() { + tests := []CLITest{ + {args: "notifications subscription list", fixture: "notifications/subscription/list/list.golden"}, + {args: "notifications subscription list -o json", fixture: "notifications/subscription/list/list-json.golden"}, + {args: "notifications subscription list -o yaml", fixture: "notifications/subscription/list/list-yaml.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsSubscriptionUpdate() { + tests := []CLITest{ + {args: "notifications subscription update subscription-1 --current-state enabled", fixture: "notifications/subscription/update/update-current-state.golden"}, + {args: "notifications subscription update subscription-1 --integrations val1,val2", fixture: "notifications/subscription/update/update-integrations.golden"}, + {args: "notifications subscription update invalid", fixture: "notifications/subscription/update/update-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsSubscription_Autocomplete() { + tests := []CLITest{ + {args: "__complete notifications subscription delete \"\"", fixture: "notifications/subscription/delete/delete-autocomplete.golden"}, + {args: "__complete notifications subscription describe \"\"", fixture: "notifications/subscription/describe/describe-autocomplete.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} diff --git a/test/notifications_user_notification_test.go b/test/notifications_user_notification_test.go new file mode 100644 index 0000000000..199663c095 --- /dev/null +++ b/test/notifications_user_notification_test.go @@ -0,0 +1,61 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package test + +func (s *CLITestSuite) TestNotificationsUserNotificationDescribe() { + tests := []CLITest{ + {args: "notifications user-notification describe user-notification-1", fixture: "notifications/user-notification/describe/describe.golden"}, + {args: "notifications user-notification describe user-notification-1 -o json", fixture: "notifications/user-notification/describe/describe-json.golden"}, + {args: "notifications user-notification describe user-notification-1 -o yaml", fixture: "notifications/user-notification/describe/describe-yaml.golden"}, + {args: "notifications user-notification describe invalid", fixture: "notifications/user-notification/describe/describe-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsUserNotificationList() { + tests := []CLITest{ + {args: "notifications user-notification list", fixture: "notifications/user-notification/list/list.golden"}, + {args: "notifications user-notification list --read", fixture: "notifications/user-notification/list/list-read.golden"}, + {args: "notifications user-notification list --severity CRITICAL,WARN", fixture: "notifications/user-notification/list/list-severity.golden"}, + {args: "notifications user-notification list --include integrations,recommended_actions", fixture: "notifications/user-notification/list/list-include.golden"}, + {args: "notifications user-notification list --type CLUSTER,CONNECTOR", fixture: "notifications/user-notification/list/list-type.golden"}, + {args: "notifications user-notification list --crn crn://confluent.cloud/organization=org-abc/environment=env-xyz/cloud-cluster=lkc-ds23ad,crn://confluent.cloud/organization=org-abc/environment=env-mx05q", fixture: "notifications/user-notification/list/list-crn.golden"}, + {args: "notifications user-notification list --search \"cluster failure\"", fixture: "notifications/user-notification/list/list-search.golden"}, + {args: "notifications user-notification list --time-range PAST_24H", fixture: "notifications/user-notification/list/list-time-range.golden"}, + {args: "notifications user-notification list --sort val1,val2", fixture: "notifications/user-notification/list/list-sort.golden"}, + {args: "notifications user-notification list -o json", fixture: "notifications/user-notification/list/list-json.golden"}, + {args: "notifications user-notification list -o yaml", fixture: "notifications/user-notification/list/list-yaml.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsUserNotificationUpdate() { + tests := []CLITest{ + {args: "notifications user-notification update user-notification-1 --read", fixture: "notifications/user-notification/update/update-read.golden"}, + {args: "notifications user-notification update invalid", fixture: "notifications/user-notification/update/update-invalid.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + +func (s *CLITestSuite) TestNotificationsUserNotification_Autocomplete() { + tests := []CLITest{ + {args: "__complete notifications user-notification describe \"\"", fixture: "notifications/user-notification/describe/describe-autocomplete.golden"}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} diff --git a/test/test-server/ccloudv2_router.go b/test/test-server/ccloudv2_router.go index ea8fc344ad..6706425e40 100644 --- a/test/test-server/ccloudv2_router.go +++ b/test/test-server/ccloudv2_router.go @@ -112,6 +112,18 @@ var ccloudV2Routes = []route{ {"/networking/v1/private-link-attachment-connections/{id}", handleNetworkingPrivateLinkAttachmentConnection}, {"/networking/v1/transit-gateway-attachments", handleNetworkingTransitGatewayAttachments}, {"/networking/v1/transit-gateway-attachments/{id}", handleNetworkingTransitGatewayAttachment}, + {"/notifications/v1/integrations", handleNotificationsV1Integrations}, + {"/notifications/v1/integrations/{id}", handleNotificationsV1IntegrationsId}, + {"/notifications/v1/notification-types", handleNotificationsV1NotificationTypes}, + {"/notifications/v1/notification-types/{id}", handleNotificationsV1NotificationTypesId}, + {"/notifications/v1/resource-preferences", handleNotificationsV1ResourcePreferences}, + {"/notifications/v1/resource-preferences/{id}", handleNotificationsV1ResourcePreferencesId}, + {"/notifications/v1/resource-subscriptions", handleNotificationsV1ResourceSubscriptions}, + {"/notifications/v1/resource-subscriptions/{id}", handleNotificationsV1ResourceSubscriptionsId}, + {"/notifications/v1/subscriptions", handleNotificationsV1Subscriptions}, + {"/notifications/v1/subscriptions/{id}", handleNotificationsV1SubscriptionsId}, + {"/notifications/v1/user-notifications", handleNotificationsV1UserNotifications}, + {"/notifications/v1/user-notifications/{id}", handleNotificationsV1UserNotificationsId}, {"/org/v2/environments", handleOrgEnvironments}, {"/org/v2/environments/{id}", handleOrgEnvironment}, {"/org/v2/organizations", handleOrgOrganizations}, diff --git a/test/test-server/notifications_integration_handler.go b/test/test-server/notifications_integration_handler.go new file mode 100644 index 0000000000..00b5ac0ab7 --- /dev/null +++ b/test/test-server/notifications_integration_handler.go @@ -0,0 +1,94 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package testserver + +import ( + "encoding/json" + "net/http" + "os" + "path/filepath" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/require" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" +) + +// Handler for "/notifications/v1/integrations" +func handleNotificationsV1Integrations(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case http.MethodGet: + integration := readNotificationsV1IntegrationFile(t, "read_created_slack_target.json") + + integrationList := ¬ificationsv1.NotificationsV1IntegrationList{ + Data: []notificationsv1.NotificationsV1Integration{integration}, + } + + err := json.NewEncoder(w).Encode(integrationList) + require.NoError(t, err) + case http.MethodPost: + integration := readNotificationsV1IntegrationFile(t, "create_slack_target.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&integration) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(integration) + require.NoError(t, err) + } + } +} + +// Handler for "/notifications/v1/integrations/{id}" +func handleNotificationsV1IntegrationsId(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + id := mux.Vars(r)["id"] + switch r.Method { + case http.MethodGet: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + integration := readNotificationsV1IntegrationFile(t, "read_created_slack_target.json") + + err := json.NewEncoder(w).Encode(&integration) + require.NoError(t, err) + } + case http.MethodPatch: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + integration := readNotificationsV1IntegrationFile(t, "read_created_slack_target.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&integration) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(integration) + require.NoError(t, err) + } + case http.MethodDelete: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + w.WriteHeader(http.StatusNoContent) + } + } + } +} + +func readNotificationsV1IntegrationFile(t *testing.T, filename string) notificationsv1.NotificationsV1Integration { + jsonPath := filepath.Join("test", "fixtures", "input", "notifications", "integration", filename) + jsonData, err := os.ReadFile(jsonPath) + require.NoError(t, err) + + integration := notificationsv1.NotificationsV1Integration{} + err = json.Unmarshal(jsonData, &integration) + require.NoError(t, err) + + return integration +} diff --git a/test/test-server/notifications_notification_type_handler.go b/test/test-server/notifications_notification_type_handler.go new file mode 100644 index 0000000000..92a01633ee --- /dev/null +++ b/test/test-server/notifications_notification_type_handler.go @@ -0,0 +1,64 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package testserver + +import ( + "encoding/json" + "net/http" + "os" + "path/filepath" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/require" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" +) + +// Handler for "/notifications/v1/notification-types" +func handleNotificationsV1NotificationTypes(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case http.MethodGet: + notificationType := readNotificationsV1NotificationTypeFile(t, "read_created_notification_type.json") + + notificationTypeList := ¬ificationsv1.NotificationsV1NotificationTypeList{ + Data: []notificationsv1.NotificationsV1NotificationType{notificationType}, + } + + err := json.NewEncoder(w).Encode(notificationTypeList) + require.NoError(t, err) + } + } +} + +// Handler for "/notifications/v1/notification-types/{id}" +func handleNotificationsV1NotificationTypesId(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + id := mux.Vars(r)["id"] + switch r.Method { + case http.MethodGet: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + notificationType := readNotificationsV1NotificationTypeFile(t, "read_created_notification_type.json") + + err := json.NewEncoder(w).Encode(¬ificationType) + require.NoError(t, err) + } + } + } +} + +func readNotificationsV1NotificationTypeFile(t *testing.T, filename string) notificationsv1.NotificationsV1NotificationType { + jsonPath := filepath.Join("test", "fixtures", "input", "notifications", "notification-type", filename) + jsonData, err := os.ReadFile(jsonPath) + require.NoError(t, err) + + notificationType := notificationsv1.NotificationsV1NotificationType{} + err = json.Unmarshal(jsonData, ¬ificationType) + require.NoError(t, err) + + return notificationType +} diff --git a/test/test-server/notifications_resource_preference_handler.go b/test/test-server/notifications_resource_preference_handler.go new file mode 100644 index 0000000000..dfb8f780f8 --- /dev/null +++ b/test/test-server/notifications_resource_preference_handler.go @@ -0,0 +1,85 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package testserver + +import ( + "encoding/json" + "net/http" + "os" + "path/filepath" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/require" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" +) + +// Handler for "/notifications/v1/resource-preferences" +func handleNotificationsV1ResourcePreferences(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case http.MethodPost: + resourcePreference := readNotificationsV1ResourcePreferenceFile(t, "create_resource_preference.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&resourcePreference) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(resourcePreference) + require.NoError(t, err) + } + } +} + +// Handler for "/notifications/v1/resource-preferences/{id}" +func handleNotificationsV1ResourcePreferencesId(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + id := mux.Vars(r)["id"] + switch r.Method { + case http.MethodGet: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + resourcePreference := readNotificationsV1ResourcePreferenceFile(t, "read_created_resource_preference.json") + + err := json.NewEncoder(w).Encode(&resourcePreference) + require.NoError(t, err) + } + case http.MethodPatch: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + resourcePreference := readNotificationsV1ResourcePreferenceFile(t, "read_created_resource_preference.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&resourcePreference) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(resourcePreference) + require.NoError(t, err) + } + case http.MethodDelete: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + w.WriteHeader(http.StatusNoContent) + } + } + } +} + +func readNotificationsV1ResourcePreferenceFile(t *testing.T, filename string) notificationsv1.NotificationsV1ResourcePreference { + jsonPath := filepath.Join("test", "fixtures", "input", "notifications", "resource-preference", filename) + jsonData, err := os.ReadFile(jsonPath) + require.NoError(t, err) + + resourcePreference := notificationsv1.NotificationsV1ResourcePreference{} + err = json.Unmarshal(jsonData, &resourcePreference) + require.NoError(t, err) + + return resourcePreference +} diff --git a/test/test-server/notifications_resource_subscription_handler.go b/test/test-server/notifications_resource_subscription_handler.go new file mode 100644 index 0000000000..2d4e98a040 --- /dev/null +++ b/test/test-server/notifications_resource_subscription_handler.go @@ -0,0 +1,85 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package testserver + +import ( + "encoding/json" + "net/http" + "os" + "path/filepath" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/require" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" +) + +// Handler for "/notifications/v1/resource-subscriptions" +func handleNotificationsV1ResourceSubscriptions(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case http.MethodPost: + resourceSubscription := readNotificationsV1ResourceSubscriptionFile(t, "create_resource_subscription.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&resourceSubscription) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(resourceSubscription) + require.NoError(t, err) + } + } +} + +// Handler for "/notifications/v1/resource-subscriptions/{id}" +func handleNotificationsV1ResourceSubscriptionsId(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + id := mux.Vars(r)["id"] + switch r.Method { + case http.MethodGet: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + resourceSubscription := readNotificationsV1ResourceSubscriptionFile(t, "read_created_resource_subscription.json") + + err := json.NewEncoder(w).Encode(&resourceSubscription) + require.NoError(t, err) + } + case http.MethodPatch: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + resourceSubscription := readNotificationsV1ResourceSubscriptionFile(t, "read_created_resource_subscription.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&resourceSubscription) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(resourceSubscription) + require.NoError(t, err) + } + case http.MethodDelete: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + w.WriteHeader(http.StatusNoContent) + } + } + } +} + +func readNotificationsV1ResourceSubscriptionFile(t *testing.T, filename string) notificationsv1.NotificationsV1ResourceSubscription { + jsonPath := filepath.Join("test", "fixtures", "input", "notifications", "resource-subscription", filename) + jsonData, err := os.ReadFile(jsonPath) + require.NoError(t, err) + + resourceSubscription := notificationsv1.NotificationsV1ResourceSubscription{} + err = json.Unmarshal(jsonData, &resourceSubscription) + require.NoError(t, err) + + return resourceSubscription +} diff --git a/test/test-server/notifications_subscription_handler.go b/test/test-server/notifications_subscription_handler.go new file mode 100644 index 0000000000..d83c3011d0 --- /dev/null +++ b/test/test-server/notifications_subscription_handler.go @@ -0,0 +1,94 @@ +// Code generated by cli-terraform-generator v0.8.4; DO NOT EDIT. + +package testserver + +import ( + "encoding/json" + "net/http" + "os" + "path/filepath" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/require" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" +) + +// Handler for "/notifications/v1/subscriptions" +func handleNotificationsV1Subscriptions(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case http.MethodGet: + subscription := readNotificationsV1SubscriptionFile(t, "read_created_subscription.json") + + subscriptionList := ¬ificationsv1.NotificationsV1SubscriptionList{ + Data: []notificationsv1.NotificationsV1Subscription{subscription}, + } + + err := json.NewEncoder(w).Encode(subscriptionList) + require.NoError(t, err) + case http.MethodPost: + subscription := readNotificationsV1SubscriptionFile(t, "create_subscription.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&subscription) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(subscription) + require.NoError(t, err) + } + } +} + +// Handler for "/notifications/v1/subscriptions/{id}" +func handleNotificationsV1SubscriptionsId(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + id := mux.Vars(r)["id"] + switch r.Method { + case http.MethodGet: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + subscription := readNotificationsV1SubscriptionFile(t, "read_created_subscription.json") + + err := json.NewEncoder(w).Encode(&subscription) + require.NoError(t, err) + } + case http.MethodPatch: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + subscription := readNotificationsV1SubscriptionFile(t, "read_created_subscription.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&subscription) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(subscription) + require.NoError(t, err) + } + case http.MethodDelete: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + w.WriteHeader(http.StatusNoContent) + } + } + } +} + +func readNotificationsV1SubscriptionFile(t *testing.T, filename string) notificationsv1.NotificationsV1Subscription { + jsonPath := filepath.Join("test", "fixtures", "input", "notifications", "subscription", filename) + jsonData, err := os.ReadFile(jsonPath) + require.NoError(t, err) + + subscription := notificationsv1.NotificationsV1Subscription{} + err = json.Unmarshal(jsonData, &subscription) + require.NoError(t, err) + + return subscription +} diff --git a/test/test-server/notifications_user_notification_handler.go b/test/test-server/notifications_user_notification_handler.go new file mode 100644 index 0000000000..70df8fded0 --- /dev/null +++ b/test/test-server/notifications_user_notification_handler.go @@ -0,0 +1,78 @@ +// Code generated by cli-terraform-generator; DO NOT EDIT. + +package testserver + +import ( + "encoding/json" + "net/http" + "os" + "path/filepath" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/require" + + notificationsv1 "github.com/confluentinc/ccloud-sdk-go-v2/notifications/v1" +) + +// Handler for "/notifications/v1/user-notifications" +func handleNotificationsV1UserNotifications(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case http.MethodGet: + userNotification := readNotificationsV1UserNotificationFile(t, "read_created_user_notification.json") + + userNotificationList := ¬ificationsv1.NotificationsV1UserNotificationList{ + Data: []notificationsv1.NotificationsV1UserNotification{userNotification}, + } + + err := json.NewEncoder(w).Encode(userNotificationList) + require.NoError(t, err) + } + } +} + +// Handler for "/notifications/v1/user-notifications/{id}" +func handleNotificationsV1UserNotificationsId(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + id := mux.Vars(r)["id"] + switch r.Method { + case http.MethodGet: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + userNotification := readNotificationsV1UserNotificationFile(t, "read_created_user_notification.json") + + err := json.NewEncoder(w).Encode(&userNotification) + require.NoError(t, err) + } + case http.MethodPatch: + switch id { + case "invalid": + w.WriteHeader(http.StatusNotFound) + default: + userNotification := readNotificationsV1UserNotificationFile(t, "read_created_user_notification.json") + + // Overwrite updated fields using the request body + err := json.NewDecoder(r.Body).Decode(&userNotification) + require.NoError(t, err) + + err = json.NewEncoder(w).Encode(userNotification) + require.NoError(t, err) + } + } + } +} + +func readNotificationsV1UserNotificationFile(t *testing.T, filename string) notificationsv1.NotificationsV1UserNotification { + jsonPath := filepath.Join("test", "fixtures", "input", "notifications", "user-notification", filename) + jsonData, err := os.ReadFile(jsonPath) + require.NoError(t, err) + + userNotification := notificationsv1.NotificationsV1UserNotification{} + err = json.Unmarshal(jsonData, &userNotification) + require.NoError(t, err) + + return userNotification +}