Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix enum type #96

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var restoreBackupCmd = &cobra.Command{
msg := fmt.Sprintf("Backup %v is being restored onto the cluster %v", formatter.Colorize(backupID, formatter.GREEN_COLOR), formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "RESTORE_BACKUP", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_RESTORE_BACKUP, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down Expand Up @@ -168,7 +168,7 @@ var createBackupCmd = &cobra.Command{
msg := fmt.Sprintf("The backup for cluster %s is being created", formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(*backupID, "BACKUP", "CREATE_BACKUP", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(*backupID, ybmclient.ENTITYTYPEENUM_BACKUP, ybmclient.TASKTYPEENUM_CREATE_BACKUP, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/cdc/cdc_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var createCdcStreamCmd = &cobra.Command{
msg := fmt.Sprintf("The CDC stream %s is being created", formatter.Colorize(cdcStreamName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "CREATE_CDC_SERVICE", []string{"FAILED", "SUCCEEDED"}, msg, 1200)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_CREATE_CDC_SERVICE, []string{"FAILED", "SUCCEEDED"}, msg, 1200)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down Expand Up @@ -186,7 +186,7 @@ var editCdcStreamCmd = &cobra.Command{
if viper.GetBool("wait") {

if cmd.Flags().Changed("tables") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "RECONFIGURE_CDC_SERVICE", []string{"FAILED", "SUCCEEDED"}, msg, 1200)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_RECONFIGURE_CDC_SERVICE, []string{"FAILED", "SUCCEEDED"}, msg, 1200)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down Expand Up @@ -238,7 +238,7 @@ var deleteCdcStreamCmd = &cobra.Command{
msg := fmt.Sprintf("The CDC stream %s is being deleted", formatter.Colorize(cdcStreamName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "DELETE_CDC_SERVICE", []string{"FAILED", "SUCCEEDED"}, msg, 1200)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_DELETE_CDC_SERVICE, []string{"FAILED", "SUCCEEDED"}, msg, 1200)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/cluster/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ var createClusterCmd = &cobra.Command{
logrus.Fatalf(ybmAuthClient.GetApiErrorDetails(err))
}

dbCredentials := ybmclient.NewCreateClusterRequestDbCredentials()
dbCredentials.Ycql = ybmclient.NewDBCredentials(username, password)
dbCredentials.Ysql = ybmclient.NewDBCredentials(username, password)
dbCredentials := ybmclient.NewCreateClusterRequestDbCredentialsWithDefaults()
dbCredentials.Ycql = *ybmclient.NewDBCredentials(username, password)
dbCredentials.Ysql = *ybmclient.NewDBCredentials(username, password)

createClusterRequest := ybmclient.NewCreateClusterRequest(*clusterSpec, *dbCredentials)

Expand All @@ -114,7 +114,7 @@ var createClusterCmd = &cobra.Command{
msg := fmt.Sprintf("The cluster %s is being created", formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "CREATE_CLUSTER", []string{"FAILED", "SUCCEEDED"}, msg, 1800)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_CREATE_CLUSTER, []string{"FAILED", "SUCCEEDED"}, msg, 1800)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/cluster/delete_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/spf13/viper"
ybmAuthClient "github.com/yugabyte/ybm-cli/internal/client"
"github.com/yugabyte/ybm-cli/internal/formatter"
ybmclient "github.com/yugabyte/yugabytedb-managed-go-client-internal"
)

// deleteClusterCmd represents the cluster command
Expand Down Expand Up @@ -51,7 +52,7 @@ var deleteClusterCmd = &cobra.Command{
msg := fmt.Sprintf("The cluster %s is being deleted", formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "DELETE_CLUSTER", []string{"FAILED", "SUCCEEDED"}, msg, 1800)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_DELETE_CLUSTER, []string{"FAILED", "SUCCEEDED"}, msg, 1800)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/cluster/network/nal/assign_nal_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/spf13/viper"
ybmAuthClient "github.com/yugabyte/ybm-cli/internal/client"
"github.com/yugabyte/ybm-cli/internal/formatter"
ybmclient "github.com/yugabyte/yugabytedb-managed-go-client-internal"
)

// assignClusterCmd represents the cluster command
Expand Down Expand Up @@ -68,7 +69,7 @@ var assignClusterCmd = &cobra.Command{
msg := fmt.Sprintf("The network allow list %s is being assigned to the cluster %s", formatter.Colorize(newNetworkAllowListName, formatter.GREEN_COLOR), formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterId, "CLUSTER", "EDIT_ALLOW_LIST", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(clusterId, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_EDIT_ALLOW_LIST, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/cluster/network/nal/unassign_nal_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/spf13/viper"
ybmAuthClient "github.com/yugabyte/ybm-cli/internal/client"
"github.com/yugabyte/ybm-cli/internal/formatter"
ybmclient "github.com/yugabyte/yugabytedb-managed-go-client-internal"
)

// unassignClusterCmd represents the cluster command
Expand Down Expand Up @@ -76,7 +77,7 @@ var unassignClusterCmd = &cobra.Command{
msg := fmt.Sprintf("The network allow list %s is being unassigned from the cluster %s", formatter.Colorize(newNetworkAllowListName, formatter.GREEN_COLOR), formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterId, "CLUSTER", "EDIT_ALLOW_LIST", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(clusterId, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_EDIT_ALLOW_LIST, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cluster/pause_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var pauseClusterCmd = &cobra.Command{
msg := fmt.Sprintf("The cluster %s is being paused", formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "PAUSE_CLUSTER", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_PAUSE_CLUSTER, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/cluster/read-replica/read_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ var createReadReplicaCmd = &cobra.Command{
msg := fmt.Sprintf("Read Replica is being created for cluster %s", formatter.Colorize(ClusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "CREATE_READ_REPLICA", []string{"FAILED", "SUCCEEDED"}, msg, 1800)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_CREATE_READ_REPLICA, []string{"FAILED", "SUCCEEDED"}, msg, 1800)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down Expand Up @@ -313,7 +313,7 @@ var updateReadReplicaCmd = &cobra.Command{
msg := fmt.Sprintf("Read Replica is being updated for cluster %s", formatter.Colorize(ClusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "EDIT_READ_REPLICA", []string{"FAILED", "SUCCEEDED"}, msg, 1800)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_EDIT_READ_REPLICA, []string{"FAILED", "SUCCEEDED"}, msg, 1800)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down Expand Up @@ -356,7 +356,7 @@ var deleteReadReplicaCmd = &cobra.Command{
msg := fmt.Sprintf("Read Replica is being deleted for cluster %s", formatter.Colorize(ClusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "DELETE_READ_REPLICA", []string{"FAILED", "SUCCEEDED"}, msg, 1800)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_DELETE_READ_REPLICA, []string{"FAILED", "SUCCEEDED"}, msg, 1800)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cluster/resume_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var resumeClusterCmd = &cobra.Command{
msg := fmt.Sprintf("The cluster %s is being resumed", formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "RESUME_CLUSTER", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_RESUME_CLUSTER, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cluster/update_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var updateClusterCmd = &cobra.Command{
msg := fmt.Sprintf("The cluster %s is being updated", formatter.Colorize(clusterName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, "CLUSTER", "EDIT_CLUSTER", []string{"FAILED", "SUCCEEDED"}, msg, 1800)
returnStatus, err := authApi.WaitForTaskCompletion(clusterID, ybmclient.ENTITYTYPEENUM_CLUSTER, ybmclient.TASKTYPEENUM_EDIT_CLUSTER, []string{"FAILED", "SUCCEEDED"}, msg, 1800)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/vpc/peering/vpc_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ var createVpcPeeringCmd = &cobra.Command{
msg := fmt.Sprintf("The VPC Peering %s is being created", formatter.Colorize(vpcPeeringName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(ybVpcId, "", "CREATE_VPC_PEERING", []string{"FAILED", "SUCCEEDED"}, msg, 1800)
returnStatus, err := authApi.WaitForTaskCompletion(ybVpcId, "", ybmclient.TASKTYPEENUM_CREATE_VPC_PEERING, []string{"FAILED", "SUCCEEDED"}, msg, 1800)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down Expand Up @@ -258,7 +258,7 @@ var deleteVpcPeeringCmd = &cobra.Command{
msg := fmt.Sprintf("VPC peering %s is being terminated", formatter.Colorize(vpcPeeringName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(ybvpcID, "", "DELETE_VPC_PEERING", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(ybvpcID, "", ybmclient.TASKTYPEENUM_DELETE_VPC_PEERING, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/vpc/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var createVpcCmd = &cobra.Command{
msg := fmt.Sprintf("The VPC %s is being created", formatter.Colorize(vpcName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(vpcID, "", "CREATE_VPC", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(vpcID, "", ybmclient.TASKTYPEENUM_CREATE_VPC, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down Expand Up @@ -206,7 +206,7 @@ var deleteVpcCmd = &cobra.Command{
msg := fmt.Sprintf("The VPC %s is being deleted", formatter.Colorize(vpcName, formatter.GREEN_COLOR))

if viper.GetBool("wait") {
returnStatus, err := authApi.WaitForTaskCompletion(vpcId, "", "DELETE_VPC", []string{"FAILED", "SUCCEEDED"}, msg, 600)
returnStatus, err := authApi.WaitForTaskCompletion(vpcId, "", ybmclient.TASKTYPEENUM_DELETE_VPC, []string{"FAILED", "SUCCEEDED"}, msg, 600)
if err != nil {
logrus.Fatalf("error when getting task status: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.15.0
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20230128004341-7bd09f253ed8
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20230316062908-5b0566196202
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2
golang.org/x/term v0.6.0
gotest.tools/v3 v3.4.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20230128004341-7bd09f253ed8 h1:mq9vH0tGfDNa0BQWiuQM0TJsA6wdxB8kHdkAROD8cYk=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20230128004341-7bd09f253ed8/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20230316062908-5b0566196202 h1:wTAdnBa5Ksz60zoTuKEIuxGzc90CRjj25MeMNWA2NSg=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20230316062908-5b0566196202/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
6 changes: 3 additions & 3 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func (a *AuthApiClient) ListTasks() ybmclient.ApiListTasksRequest {
return a.ApiClient.TaskApi.ListTasks(a.ctx, a.AccountID)
}

func (a *AuthApiClient) WaitForTaskCompletion(entityId string, entityType string, taskType string, completionStatus []string, message string, timeOutInSec int) (string, error) {
func (a *AuthApiClient) WaitForTaskCompletion(entityId string, entityType ybmclient.EntityTypeEnum, taskType ybmclient.TaskTypeEnum, completionStatus []string, message string, timeOutInSec int) (string, error) {

if strings.ToLower(os.Getenv("YBM_CI")) == "true" {
return a.WaitForTaskCompletionCI(entityId, entityType, taskType, completionStatus, message, timeOutInSec)
Expand All @@ -670,7 +670,7 @@ func (a *AuthApiClient) WaitForTaskCompletion(entityId string, entityType string

}

func (a *AuthApiClient) WaitForTaskCompletionCI(entityId string, entityType string, taskType string, completionStatus []string, message string, timeOutInSec int) (string, error) {
func (a *AuthApiClient) WaitForTaskCompletionCI(entityId string, entityType ybmclient.EntityTypeEnum, taskType ybmclient.TaskTypeEnum, completionStatus []string, message string, timeOutInSec int) (string, error) {
var taskList ybmclient.TaskListResponse
var resp *http.Response
var err error
Expand Down Expand Up @@ -725,7 +725,7 @@ func (a *AuthApiClient) WaitForTaskCompletionCI(entityId string, entityType stri

}

func (a *AuthApiClient) WaitForTaskCompletionFull(entityId string, entityType string, taskType string, completionStatus []string, message string, timeOutInSec int) (string, error) {
func (a *AuthApiClient) WaitForTaskCompletionFull(entityId string, entityType ybmclient.EntityTypeEnum, taskType ybmclient.TaskTypeEnum, completionStatus []string, message string, timeOutInSec int) (string, error) {
var taskList ybmclient.TaskListResponse
var resp *http.Response
var err error
Expand Down