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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions docs/stackit_beta_sqlserverflex_instance_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,26 @@ stackit beta sqlserverflex instance create [flags]
### Examples

```
Create a SQLServer Flex instance with name "my-instance" and specify flavor by CPU and RAM. Other parameters are set to default values
$ stackit beta sqlserverflex instance create --name my-instance --cpu 1 --ram 4

Create a SQLServer Flex instance with name "my-instance" and specify flavor by ID. Other parameters are set to default values.
The flavor ID can be retrieved by running "$ stackit beta sqlserverflex options --flavors"
$ stackit beta sqlserverflex instance create --name my-instance --flavor-id xxx
$ stackit beta sqlserverflex instance create --name my-instance --flavor-id xxx --backup-schedule "0 1-3 * * *" --retention-days 30 --storage-class premium-perf2-stackit --storage-size 10 --version 2022

Create a SQLServer Flex instance with name "my-instance", specify flavor by CPU and RAM, set storage size to 20 GB, and restrict access to a specific range of IP addresses. Other parameters are set to default values
$ stackit beta sqlserverflex instance create --name my-instance --cpu 1 --ram 4 --storage-size 20 --acl 1.2.3.0/24
$ stackit beta sqlserverflex instance create --name my-instance --cpu 1 --ram 4 --storage-size 20 --backup-schedule "0 1-3 * * *" --retention-days 30 --storage-class premium-perf2-stackit --storage-size 10 --version 2022 --acl 1.2.3.0/24
```

### Options

```
--acl strings The access control list (ACL). Must contain at least one valid subnet, for instance '0.0.0.0/0' for open access (discouraged), '1.2.3.0/24 for a public IP range of an organization, '1.2.3.4/32' for a single IP range, etc. (default [])
--backup-schedule string Backup schedule
--cpu int32 Number of CPUs
--cpu int Number of CPUs
--edition string Edition of the SQLServer instance
--flavor-id string ID of the flavor
-h, --help Help for "stackit beta sqlserverflex instance create"
-n, --name string Instance name
--ram int32 Amount of RAM (in GB)
--retention-days int The days for how long the backup files should be stored before being cleaned up
--ram int Amount of RAM (in GB)
--retention-days int32 The days for how long the backup files should be stored before being cleaned up
--storage-class string Storage class
--storage-size int Storage size (in GB)
--version string SQLServer version
Expand Down
4 changes: 2 additions & 2 deletions docs/stackit_beta_sqlserverflex_instance_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ stackit beta sqlserverflex instance update INSTANCE_ID [flags]
```
--acl strings Lists of IP networks in CIDR notation which are allowed to access this instance (default [])
--backup-schedule string Backup schedule
--cpu int32 Number of CPUs
--cpu int Number of CPUs
--flavor-id string ID of the flavor
-h, --help Help for "stackit beta sqlserverflex instance update"
-n, --name string Instance name
--ram int32 Amount of RAM (in GB)
--ram int Amount of RAM (in GB)
--version string Version
```

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7
github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.16.0
github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0
github.com/zalando/go-keyring v0.2.8
golang.org/x/mod v0.34.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,8 @@ github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 h1:JWAFnskRbNKT8x62pZ
github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0/go.mod h1:jMlBoXqrPNX5nXbo6oT7exalqilw1jiLPoIp4Cn0CdI=
github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 h1:QoKyQPe8FqDqJLNgE5uRlZ/y1c1GUxjV1DDLu5QEBD8=
github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0/go.mod h1:KhVYCR58wETqdI7Quwhe3OR3BhB2T/b7DzaMsfDnr8g=
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0 h1:PwjQeupEnXxhu+uWCUzO/hUfL4yqNblOcZbP2jvaQtU=
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0/go.mod h1:AiUoMAqQcOlMgDtkVJlqI7P/VGD5xjN3dYjERGnwN/M=
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.16.0 h1:A6zN5JUz5DOTigTxAyAC+4p5VpJzaYDftx2yIH0mgn8=
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.16.0/go.mod h1:AiUoMAqQcOlMgDtkVJlqI7P/VGD5xjN3dYjERGnwN/M=
github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 h1:LMgbzhPunuelsIsfyEj/5O/aYfNcg/eGHsnZ7AZOhYg=
github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0/go.mod h1:toIjQk1dhxdUFVyCWJJja0w/0nFpDid8MWX0ukQfvfo=
github.com/stbenjam/no-sprintf-host-port v0.3.1 h1:AyX7+dxI4IdLBPtDbsGAyqiTSLpCP9hWRrXQDU4Cm/g=
Expand Down
10 changes: 4 additions & 6 deletions internal/cmd/beta/sqlserverflex/database/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/stackitcloud/stackit-cli/internal/pkg/types"

sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v2api"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
Expand Down Expand Up @@ -108,12 +108,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *sqlserverflex.APIClient) sqlserverflex.ApiCreateDatabaseRequest {
req := apiClient.DefaultAPI.CreateDatabase(ctx, model.ProjectId, model.InstanceId, model.Region)
req := apiClient.DefaultAPI.CreateDatabase(ctx, model.ProjectId, model.Region, model.InstanceId)
payload := sqlserverflex.CreateDatabasePayload{
Name: model.DatabaseName,
Options: sqlserverflex.DatabaseDocumentationCreateDatabaseRequestOptions{
Owner: model.Owner,
},
Name: model.DatabaseName,
Owner: model.Owner,
}
req = req.CreateDatabasePayload(payload)
return req
Expand Down
10 changes: 4 additions & 6 deletions internal/cmd/beta/sqlserverflex/database/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v2api"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3api"

"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"

Expand Down Expand Up @@ -67,12 +67,10 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *sqlserverflex.ApiCreateDatabaseRequest)) sqlserverflex.ApiCreateDatabaseRequest {
request := testClient.DefaultAPI.CreateDatabase(testCtx, testProjectId, testInstanceId, testRegion)
request := testClient.DefaultAPI.CreateDatabase(testCtx, testProjectId, testRegion, testInstanceId)
payload := sqlserverflex.CreateDatabasePayload{
Name: testDatabaseName,
Options: sqlserverflex.DatabaseDocumentationCreateDatabaseRequestOptions{
Owner: testOwner,
},
Name: testDatabaseName,
Owner: testOwner,
}
request = request.CreateDatabasePayload(payload)
for _, mod := range mods {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/beta/sqlserverflex/database/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"

"github.com/spf13/cobra"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v2api"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3api"
)

const (
Expand Down Expand Up @@ -107,6 +107,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *sqlserverflex.APIClient) sqlserverflex.ApiDeleteDatabaseRequest {
req := apiClient.DefaultAPI.DeleteDatabase(ctx, model.ProjectId, model.InstanceId, model.DatabaseName, model.Region)
req := apiClient.DefaultAPI.DeleteDatabase(ctx, model.ProjectId, model.Region, model.InstanceId, model.DatabaseName)
return req
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"testing"

sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v2api"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3api"

"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
Expand Down Expand Up @@ -63,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *sqlserverflex.ApiDeleteDatabaseRequest)) sqlserverflex.ApiDeleteDatabaseRequest {
request := testClient.DefaultAPI.DeleteDatabase(testCtx, testProjectId, testInstanceId, testDatabaseName, testRegion)
request := testClient.DefaultAPI.DeleteDatabase(testCtx, testProjectId, testRegion, testInstanceId, testDatabaseName)
for _, mod := range mods {
mod(&request)
}
Expand Down
30 changes: 10 additions & 20 deletions internal/cmd/beta/sqlserverflex/database/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/types"

"github.com/spf13/cobra"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v2api"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
Expand All @@ -17,7 +17,6 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/sqlserverflex/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
)

const (
Expand Down Expand Up @@ -98,35 +97,26 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *sqlserverflex.APIClient) sqlserverflex.ApiGetDatabaseRequest {
req := apiClient.DefaultAPI.GetDatabase(ctx, model.ProjectId, model.InstanceId, model.DatabaseName, model.Region)
req := apiClient.DefaultAPI.GetDatabase(ctx, model.ProjectId, model.Region, model.InstanceId, model.DatabaseName)
return req
}

func outputResult(p *print.Printer, outputFormat string, resp *sqlserverflex.GetDatabaseResponse) error {
if resp == nil || resp.Database == nil {
if resp == nil {
return fmt.Errorf("database response is empty")
}

return p.OutputResult(outputFormat, resp, func() error {
database := resp.Database
table := tables.NewTable()
table.AddRow("ID", utils.PtrString(database.Id))
table.AddRow("ID", resp.Id)
table.AddSeparator()
table.AddRow("NAME", utils.PtrString(database.Name))
table.AddRow("NAME", resp.Name)
table.AddSeparator()
if database.Options != nil {
if database.Options.CompatibilityLevel != nil {
table.AddRow("COMPATIBILITY LEVEL", *database.Options.CompatibilityLevel)
table.AddSeparator()
}
if database.Options.Owner != nil {
table.AddRow("OWNER", *database.Options.Owner)
table.AddSeparator()
}
if database.Options.CollationName != nil {
table.AddRow("COLLATION", *database.Options.CollationName)
}
}
table.AddRow("COMPATIBILITY LEVEL", resp.CompatibilityLevel)
table.AddSeparator()
table.AddRow("OWNER", resp.Owner)
table.AddSeparator()
table.AddRow("COLLATION", resp.CollationName)
err := table.Display(p)
if err != nil {
return fmt.Errorf("render table: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v2api"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3api"

"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"

Expand Down Expand Up @@ -64,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *sqlserverflex.ApiGetDatabaseRequest)) sqlserverflex.ApiGetDatabaseRequest {
request := testClient.DefaultAPI.GetDatabase(testCtx, testProjectId, testInstanceId, testDatabaseName, testRegion)
request := testClient.DefaultAPI.GetDatabase(testCtx, testProjectId, testRegion, testInstanceId, testDatabaseName)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -210,20 +210,6 @@ func TestOutputResult(t *testing.T) {
args: args{},
wantErr: true,
},
{
name: "empty response",
args: args{
resp: &sqlserverflex.GetDatabaseResponse{},
},
wantErr: true,
},
{
name: "only database as argument",
args: args{
resp: &sqlserverflex.GetDatabaseResponse{Database: &sqlserverflex.SingleDatabase{}},
},
wantErr: false,
},
}
params := testparams.NewTestParams()

Expand Down
9 changes: 4 additions & 5 deletions internal/cmd/beta/sqlserverflex/database/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/types"

"github.com/spf13/cobra"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v2api"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
Expand All @@ -18,7 +18,6 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/sqlserverflex/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
)

const (
Expand Down Expand Up @@ -122,11 +121,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *sqlserverflex.APIClient) sqlserverflex.ApiListDatabasesRequest {
req := apiClient.DefaultAPI.ListDatabases(ctx, model.ProjectId, model.InstanceId, model.Region)
req := apiClient.DefaultAPI.ListDatabases(ctx, model.ProjectId, model.Region, model.InstanceId)
return req
}

func outputResult(p *print.Printer, outputFormat, instanceId, projectLabel string, databases []sqlserverflex.Database) error {
func outputResult(p *print.Printer, outputFormat, instanceId, projectLabel string, databases []sqlserverflex.ListDatabase) error {
return p.OutputResult(outputFormat, databases, func() error {
if len(databases) == 0 {
p.Outputf("No databases found for instance %s on project %s\n", instanceId, projectLabel)
Expand All @@ -137,7 +136,7 @@ func outputResult(p *print.Printer, outputFormat, instanceId, projectLabel strin
table.SetHeader("ID", "NAME")
for i := range databases {
database := databases[i]
table.AddRow(utils.PtrString(database.Id), utils.PtrString(database.Name))
table.AddRow(database.Id, database.Name)
}
err := table.Display(p)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sqlserverflex/database/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v2api"
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3api"

"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"

Expand Down Expand Up @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *sqlserverflex.ApiListDatabasesRequest)) sqlserverflex.ApiListDatabasesRequest {
request := testClient.DefaultAPI.ListDatabases(testCtx, testProjectId, testInstanceId, testRegion)
request := testClient.DefaultAPI.ListDatabases(testCtx, testProjectId, testRegion, testInstanceId)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestOutputResult(t *testing.T) {
outputFormat string
instanceId string
projectLabel string
databases []sqlserverflex.Database
databases []sqlserverflex.ListDatabase
}
tests := []struct {
name string
Expand All @@ -195,7 +195,7 @@ func TestOutputResult(t *testing.T) {
{
name: "empty database in databases slice",
args: args{
databases: []sqlserverflex.Database{{}},
databases: []sqlserverflex.ListDatabase{{}},
},
wantErr: false,
},
Expand Down
Loading
Loading