diff --git a/docs/stackit_beta_sfs_export-policy.md b/docs/stackit_beta_sfs_export-policy.md index eaad44e74..c6f082ced 100644 --- a/docs/stackit_beta_sfs_export-policy.md +++ b/docs/stackit_beta_sfs_export-policy.md @@ -32,7 +32,7 @@ stackit beta sfs export-policy [flags] * [stackit beta sfs](./stackit_beta_sfs.md) - Provides functionality for SFS (stackit file storage) * [stackit beta sfs export-policy create](./stackit_beta_sfs_export-policy_create.md) - Creates a export policy * [stackit beta sfs export-policy delete](./stackit_beta_sfs_export-policy_delete.md) - Deletes a export policy -* [stackit beta sfs export-policy describe](./stackit_beta_sfs_export-policy_describe.md) - Shows details of a export policy +* [stackit beta sfs export-policy describe](./stackit_beta_sfs_export-policy_describe.md) - Shows details of an export policy * [stackit beta sfs export-policy list](./stackit_beta_sfs_export-policy_list.md) - Lists all export policies of a project -* [stackit beta sfs export-policy update](./stackit_beta_sfs_export-policy_update.md) - Updates a export policy +* [stackit beta sfs export-policy update](./stackit_beta_sfs_export-policy_update.md) - Updates an export policy diff --git a/docs/stackit_beta_sfs_export-policy_delete.md b/docs/stackit_beta_sfs_export-policy_delete.md index af95dfa5f..8b6e6b07a 100644 --- a/docs/stackit_beta_sfs_export-policy_delete.md +++ b/docs/stackit_beta_sfs_export-policy_delete.md @@ -13,7 +13,7 @@ stackit beta sfs export-policy delete EXPORT_POLICY_ID [flags] ### Examples ``` - Delete a export policy with ID "xxx" + Delete an export policy with ID "xxx" $ stackit beta sfs export-policy delete xxx ``` diff --git a/docs/stackit_beta_sfs_export-policy_describe.md b/docs/stackit_beta_sfs_export-policy_describe.md index 79b314f38..b6d327299 100644 --- a/docs/stackit_beta_sfs_export-policy_describe.md +++ b/docs/stackit_beta_sfs_export-policy_describe.md @@ -1,10 +1,10 @@ ## stackit beta sfs export-policy describe -Shows details of a export policy +Shows details of an export policy ### Synopsis -Shows details of a export policy. +Shows details of an export policy. ``` stackit beta sfs export-policy describe EXPORT_POLICY_ID [flags] @@ -13,7 +13,7 @@ stackit beta sfs export-policy describe EXPORT_POLICY_ID [flags] ### Examples ``` - Describe a export policy with ID "xxx" + Describe an export policy with ID "xxx" $ stackit beta sfs export-policy describe xxx ``` diff --git a/docs/stackit_beta_sfs_export-policy_update.md b/docs/stackit_beta_sfs_export-policy_update.md index 99bdec9d7..e610996f9 100644 --- a/docs/stackit_beta_sfs_export-policy_update.md +++ b/docs/stackit_beta_sfs_export-policy_update.md @@ -1,10 +1,10 @@ ## stackit beta sfs export-policy update -Updates a export policy +Updates an export policy ### Synopsis -Updates a export policy. +Updates an export policy. ``` stackit beta sfs export-policy update EXPORT_POLICY_ID [flags] @@ -13,10 +13,10 @@ stackit beta sfs export-policy update EXPORT_POLICY_ID [flags] ### Examples ``` - Update a export policy with ID "xxx" and with rules from file "./rules.json" + Update an export policy with ID "xxx" and with rules from file "./rules.json" $ stackit beta sfs export-policy update xxx --rules @./rules.json - Update a export policy with ID "xxx" and remove the rules + Update an export policy with ID "xxx" and remove the rules $ stackit beta sfs export-policy update XXX --remove-rules ``` diff --git a/docs/stackit_beta_sfs_resource-pool_create.md b/docs/stackit_beta_sfs_resource-pool_create.md index 334864945..5643e8671 100644 --- a/docs/stackit_beta_sfs_resource-pool_create.md +++ b/docs/stackit_beta_sfs_resource-pool_create.md @@ -37,7 +37,7 @@ stackit beta sfs resource-pool create [flags] --ip-acl strings List of network addresses in the form
, e.g. 192.168.10.0/24 that can mount the resource pool readonly (default []) --name string Name --performance-class string Performance class - --size int Size of the pool in Gigabytes + --size int32 Size of the pool in Gigabytes --snapshots-visible Set snapshots visible and accessible to users ``` diff --git a/docs/stackit_beta_sfs_resource-pool_update.md b/docs/stackit_beta_sfs_resource-pool_update.md index fbdc85e99..3929a5e14 100644 --- a/docs/stackit_beta_sfs_resource-pool_update.md +++ b/docs/stackit_beta_sfs_resource-pool_update.md @@ -35,7 +35,7 @@ stackit beta sfs resource-pool update [flags] -h, --help Help for "stackit beta sfs resource-pool update" --ip-acl strings List of network addresses in the form , e.g. 192.168.10.0/24 that can mount the resource pool readonly (default []) --performance-class string Performance class - --size int Size of the pool in Gigabytes + --size int32 Size of the pool in Gigabytes --snapshots-visible Set snapshots visible and accessible to users ``` diff --git a/docs/stackit_beta_sfs_share_create.md b/docs/stackit_beta_sfs_share_create.md index 15abc66d8..f59b25b1c 100644 --- a/docs/stackit_beta_sfs_share_create.md +++ b/docs/stackit_beta_sfs_share_create.md @@ -24,7 +24,7 @@ stackit beta sfs share create [flags] ``` --export-policy-name string The export policy the share is assigned to - --hard-limit int The space hard limit for the share + --hard-limit int32 The space hard limit for the share -h, --help Help for "stackit beta sfs share create" --name string Share name --resource-pool-id string The resource pool the share is assigned to diff --git a/docs/stackit_beta_sfs_share_describe.md b/docs/stackit_beta_sfs_share_describe.md index 7a881501f..a303e263a 100644 --- a/docs/stackit_beta_sfs_share_describe.md +++ b/docs/stackit_beta_sfs_share_describe.md @@ -14,7 +14,7 @@ stackit beta sfs share describe SHARE_ID [flags] ``` Describe a shares with ID "xxx" from resource pool with ID "yyy" - $ stackit beta sfs export-policy describe xxx --resource-pool-id yyy + $ stackit beta sfs share describe xxx --resource-pool-id yyy ``` ### Options diff --git a/docs/stackit_beta_sfs_share_list.md b/docs/stackit_beta_sfs_share_list.md index 2b3d73461..b100d94fc 100644 --- a/docs/stackit_beta_sfs_share_list.md +++ b/docs/stackit_beta_sfs_share_list.md @@ -14,10 +14,10 @@ stackit beta sfs share list [flags] ``` List all shares from resource pool with ID "xxx" - $ stackit beta sfs export-policy list --resource-pool-id xxx + $ stackit beta sfs share list --resource-pool-id xxx List up to 10 shares from resource pool with ID "xxx" - $ stackit beta sfs export-policy list --resource-pool-id xxx --limit 10 + $ stackit beta sfs share list --resource-pool-id xxx --limit 10 ``` ### Options diff --git a/docs/stackit_beta_sfs_share_update.md b/docs/stackit_beta_sfs_share_update.md index 0a0c1f8b8..8af76527d 100644 --- a/docs/stackit_beta_sfs_share_update.md +++ b/docs/stackit_beta_sfs_share_update.md @@ -24,7 +24,7 @@ stackit beta sfs share update SHARE_ID [flags] ``` --export-policy-name string The export policy the share is assigned to - --hard-limit int The space hard limit for the share + --hard-limit int32 The space hard limit for the share -h, --help Help for "stackit beta sfs share update" --resource-pool-id string The resource pool the share is assigned to ``` diff --git a/go.mod b/go.mod index b83cded9e..cf7759725 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 github.com/spf13/viper v1.21.0 - github.com/stackitcloud/stackit-sdk-go/core v0.23.0 + github.com/stackitcloud/stackit-sdk-go/core v0.26.0 github.com/stackitcloud/stackit-sdk-go/services/alb v0.10.0 github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0 github.com/stackitcloud/stackit-sdk-go/services/cdn v1.10.0 @@ -272,7 +272,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0 github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6 - github.com/stackitcloud/stackit-sdk-go/services/sfs v0.4.0 + github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 github.com/subosito/gotenv v1.6.0 // indirect golang.org/x/sys v0.43.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index af0e10bab..bf1428b79 100644 --- a/go.sum +++ b/go.sum @@ -594,8 +594,8 @@ github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU= github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY= github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0= github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= -github.com/stackitcloud/stackit-sdk-go/core v0.23.0 h1:zPrOhf3Xe47rKRs1fg/AqKYUiJJRYjdcv+3qsS50mEs= -github.com/stackitcloud/stackit-sdk-go/core v0.23.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI= +github.com/stackitcloud/stackit-sdk-go/core v0.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA= +github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA= github.com/stackitcloud/stackit-sdk-go/services/alb v0.10.0 h1:V9+885qkSv621rZZatg1YE5ENM1ElALxQDJsh+hDIUg= github.com/stackitcloud/stackit-sdk-go/services/alb v0.10.0/go.mod h1:V6+MolxM/M2FWyWZA+FRFKEzzUe10MU9eEVfMvxHGi8= github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0 h1:HxPgBu04j5tj6nfZ2r0l6v4VXC0/tYOGe4sA5Addra8= @@ -650,8 +650,8 @@ github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 h1:l1EDIl github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0/go.mod h1:EXq8/J7t9p8zPmdIq+atuxyAbnQwxrQT18fI+Qpv98k= github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7 h1:M2PYLF8k3zmAwYWSKfUiCTNTXr7ROGuJganVVEQA3YI= github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7/go.mod h1:jitkQuP2K/SH63Qor0C4pcqz1GDCy/lK2H4t8/VDse4= -github.com/stackitcloud/stackit-sdk-go/services/sfs v0.4.0 h1:ofdGO2dGH6ywKbIVxaxRVal3jWX9WlcHSm5BTud5bC4= -github.com/stackitcloud/stackit-sdk-go/services/sfs v0.4.0/go.mod h1:r5lBwzJpJe2xBIYctkVIIpaZ41Y6vUEpkmsWR2VoQJs= +github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 h1:JWAFnskRbNKT8x62pZcAMCC+p5hyTEkAyxqFwy39jFA= +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.4.3 h1:AQrcr+qeIuZob+3TT2q1L4WOPtpsu5SEpkTnOUHDqfE= diff --git a/internal/cmd/beta/sfs/export-policy/create/create.go b/internal/cmd/beta/sfs/export-policy/create/create.go index e640862df..4012dfd47 100644 --- a/internal/cmd/beta/sfs/export-policy/create/create.go +++ b/internal/cmd/beta/sfs/export-policy/create/create.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -28,7 +28,7 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel Name string - Rules *[]sfs.CreateShareExportPolicyRequestRule + Rules []sfs.CreateShareExportPolicyRequestRule } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -102,15 +102,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return nil, &errors.ProjectIdError{} } - rulesString := flags.FlagToStringPointer(p, cmd, rulesFlag) - var rules *[]sfs.CreateShareExportPolicyRequestRule - if rulesString != nil && *rulesString != "" { + rulesString := flags.FlagToStringValue(p, cmd, rulesFlag) + var rules []sfs.CreateShareExportPolicyRequestRule + if rulesString != "" { var r []sfs.CreateShareExportPolicyRequestRule - err := json.Unmarshal([]byte(*rulesString), &r) + err := json.Unmarshal([]byte(rulesString), &r) if err != nil { return nil, fmt.Errorf("could not parse rules: %w", err) } - rules = &r + rules = r } model := inputModel{ @@ -124,10 +124,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiCreateShareExportPolicyRequest { - req := apiClient.CreateShareExportPolicy(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.CreateShareExportPolicy(ctx, model.ProjectId, model.Region) req = req.CreateShareExportPolicyPayload( sfs.CreateShareExportPolicyPayload{ - Name: utils.Ptr(model.Name), + Name: model.Name, Rules: model.Rules, }, ) diff --git a/internal/cmd/beta/sfs/export-policy/create/create_test.go b/internal/cmd/beta/sfs/export-policy/create/create_test.go index a31ce8ec4..0715ca337 100644 --- a/internal/cmd/beta/sfs/export-policy/create/create_test.go +++ b/internal/cmd/beta/sfs/export-policy/create/create_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -21,13 +21,13 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" var testName = "test-name" var testRulesString = "[]" -var testRules = &[]sfs.CreateShareExportPolicyRequestRule{} +var testRules = []sfs.CreateShareExportPolicyRequestRule{} func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ @@ -59,18 +59,18 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { return model } -func fixtureRequest(mods ...func(request *sfs.ApiCreateShareExportPolicyRequest)) sfs.ApiCreateShareExportPolicyRequest { - request := testClient.CreateShareExportPolicy(testCtx, testProjectId, testRegion) +func fixtureRequest(mods ...func(request sfs.ApiCreateShareExportPolicyRequest)) sfs.ApiCreateShareExportPolicyRequest { + request := testClient.DefaultAPI.CreateShareExportPolicy(testCtx, testProjectId, testRegion) request = request.CreateShareExportPolicyPayload(fixturePayload()) for _, mod := range mods { - mod(&request) + mod(request) } return request } func fixturePayload(mods ...func(payload *sfs.CreateShareExportPolicyPayload)) sfs.CreateShareExportPolicyPayload { payload := sfs.CreateShareExportPolicyPayload{ - Name: utils.Ptr(testName), + Name: testName, Rules: testRules, } for _, mod := range mods { @@ -110,20 +110,20 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Rules = &[]sfs.CreateShareExportPolicyRequestRule{ + model.Rules = []sfs.CreateShareExportPolicyRequestRule{ { - Description: sfs.NewNullableString( - utils.Ptr("first rule"), - ), - IpAcl: utils.Ptr([]string{"192.168.2.0/24"}), - Order: utils.Ptr(int64(1)), - SetUuid: utils.Ptr(true), - SuperUser: utils.Ptr(false), + Description: *sfs.NewNullableString(utils.Ptr("first rule")), + IpAcl: []string{"192.168.2.0/24"}, + Order: utils.Ptr(int32(1)), + SetUuid: utils.Ptr(true), + SuperUser: utils.Ptr(false), + AdditionalProperties: map[string]any{}, }, { - IpAcl: utils.Ptr([]string{"192.168.2.0/24", "127.0.0.1/32"}), - Order: utils.Ptr(int64(2)), - ReadOnly: utils.Ptr(true), + IpAcl: []string{"192.168.2.0/24", "127.0.0.1/32"}, + Order: utils.Ptr(int32(2)), + ReadOnly: utils.Ptr(true), + AdditionalProperties: map[string]any{"readonly": true}, }, } }), @@ -157,7 +157,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -194,7 +194,7 @@ func TestOutputResult(t *testing.T) { name: "set empty export policy", args: args{ exportPolicy: &sfs.CreateShareExportPolicyResponse{ - ShareExportPolicy: &sfs.CreateShareExportPolicyResponseShareExportPolicy{}, + ShareExportPolicy: &sfs.ShareExportPolicy{}, }, }, wantErr: false, diff --git a/internal/cmd/beta/sfs/export-policy/delete/delete.go b/internal/cmd/beta/sfs/export-policy/delete/delete.go index a02a994fc..a57e4ffc8 100644 --- a/internal/cmd/beta/sfs/export-policy/delete/delete.go +++ b/internal/cmd/beta/sfs/export-policy/delete/delete.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -33,7 +33,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { Args: args.SingleArg(exportPolicyIdArg, utils.ValidateUUID), Example: examples.Build( examples.NewExample( - `Delete a export policy with ID "xxx"`, + `Delete an export policy with ID "xxx"`, "$ stackit beta sfs export-policy delete xxx", ), ), @@ -49,7 +49,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - exportPolicyLabel, err := sfsUtils.GetExportPolicyName(ctx, apiClient, model.ProjectId, model.Region, model.ExportPolicyId) + exportPolicyLabel, err := sfsUtils.GetExportPolicyName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ExportPolicyId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get export policy name: %v", err) exportPolicyLabel = model.ExportPolicyId @@ -78,7 +78,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiDeleteShareExportPolicyRequest { - return apiClient.DeleteShareExportPolicy(ctx, model.ProjectId, model.Region, model.ExportPolicyId) + return apiClient.DefaultAPI.DeleteShareExportPolicy(ctx, model.ProjectId, model.Region, model.ExportPolicyId) } func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { diff --git a/internal/cmd/beta/sfs/export-policy/delete/delete_test.go b/internal/cmd/beta/sfs/export-policy/delete/delete_test.go index 77ea7870a..418df1aa2 100644 --- a/internal/cmd/beta/sfs/export-policy/delete/delete_test.go +++ b/internal/cmd/beta/sfs/export-policy/delete/delete_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -19,7 +19,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiDeleteShareExportPolicyRequest)) sfs.ApiDeleteShareExportPolicyRequest { - request := testClient.DeleteShareExportPolicy(testCtx, testProjectId, testRegion, testExportPolicyId) + request := testClient.DefaultAPI.DeleteShareExportPolicy(testCtx, testProjectId, testRegion, testExportPolicyId) for _, mod := range mods { mod(&request) } @@ -164,7 +164,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/beta/sfs/export-policy/describe/describe.go b/internal/cmd/beta/sfs/export-policy/describe/describe.go index 4cbed0c22..6f29161cf 100644 --- a/internal/cmd/beta/sfs/export-policy/describe/describe.go +++ b/internal/cmd/beta/sfs/export-policy/describe/describe.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -29,12 +29,12 @@ type inputModel struct { func NewCmd(params *types.CmdParams) *cobra.Command { cmd := &cobra.Command{ Use: fmt.Sprintf("describe %s", exportPolicyIdArg), - Short: "Shows details of a export policy", - Long: "Shows details of a export policy.", + Short: "Shows details of an export policy", + Long: "Shows details of an export policy.", Args: args.SingleArg(exportPolicyIdArg, utils.ValidateUUID), Example: examples.Build( examples.NewExample( - `Describe a export policy with ID "xxx"`, + `Describe an export policy with ID "xxx"`, "$ stackit beta sfs export-policy describe xxx", ), ), @@ -91,7 +91,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiGetShareExportPolicyRequest { - return apiClient.GetShareExportPolicy(ctx, model.ProjectId, model.Region, model.ExportPolicyId) + return apiClient.DefaultAPI.GetShareExportPolicy(ctx, model.ProjectId, model.Region, model.ExportPolicyId) } func outputResult(p *print.Printer, outputFormat, exportPolicyId, projectLabel string, exportPolicy *sfs.GetShareExportPolicyResponse) error { @@ -117,25 +117,25 @@ func outputResult(p *print.Printer, outputFormat, exportPolicyId, projectLabel s content = append(content, table) - if policy.Rules != nil && len(*policy.Rules) > 0 { + if len(policy.Rules) > 0 { rulesTable := tables.NewTable() rulesTable.SetTitle("Rules") rulesTable.SetHeader("ID", "ORDER", "DESCRIPTION", "IP ACL", "READ ONLY", "SET UUID", "SUPER USER", "CREATED AT") - for _, rule := range *policy.Rules { + for _, rule := range policy.Rules { var description string - if rule.Description != nil { - description = utils.PtrString(rule.Description.Get()) + if rule.Description.IsSet() && *rule.Description.Get() != "" { + description = *rule.Description.Get() } rulesTable.AddRow( - utils.PtrString(rule.Id), - utils.PtrString(rule.Order), + rule.Id, + rule.Order, description, - utils.JoinStringPtr(rule.IpAcl, ", "), - utils.PtrString(rule.ReadOnly), - utils.PtrString(rule.SetUuid), - utils.PtrString(rule.SuperUser), + utils.JoinStringPtr(&rule.IpAcl, ", "), + rule.ReadOnly, + rule.SetUuid, + rule.SuperUser, utils.ConvertTimePToDateTimeString(rule.CreatedAt), ) rulesTable.AddSeparator() diff --git a/internal/cmd/beta/sfs/export-policy/describe/describe_test.go b/internal/cmd/beta/sfs/export-policy/describe/describe_test.go index 531b57a7b..ee9bb0188 100644 --- a/internal/cmd/beta/sfs/export-policy/describe/describe_test.go +++ b/internal/cmd/beta/sfs/export-policy/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -63,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiGetShareExportPolicyRequest)) sfs.ApiGetShareExportPolicyRequest { - request := testClient.GetShareExportPolicy(testCtx, testProjectId, testRegion, testExportPolicyId) + request := testClient.DefaultAPI.GetShareExportPolicy(testCtx, testProjectId, testRegion, testExportPolicyId) for _, mod := range mods { mod(&request) } @@ -165,7 +165,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -203,7 +203,7 @@ func TestOutputResult(t *testing.T) { name: "set empty export policy", args: args{ exportPolicy: &sfs.GetShareExportPolicyResponse{ - ShareExportPolicy: &sfs.GetShareExportPolicyResponseShareExportPolicy{}, + ShareExportPolicy: &sfs.ShareExportPolicy{}, }, }, wantErr: false, diff --git a/internal/cmd/beta/sfs/export-policy/list/list.go b/internal/cmd/beta/sfs/export-policy/list/list.go index 186f07106..d3fd00883 100644 --- a/internal/cmd/beta/sfs/export-policy/list/list.go +++ b/internal/cmd/beta/sfs/export-policy/list/list.go @@ -6,7 +6,7 @@ import ( "strconv" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Truncate output - items := utils.GetSliceFromPointer(resp.ShareExportPolicies) + items := utils.GetSliceFromPointer(&resp.ShareExportPolicies) if model.Limit != nil && len(items) > int(*model.Limit) { items = items[:*model.Limit] } @@ -116,7 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiListShareExportPoliciesRequest { - return apiClient.ListShareExportPolicies(ctx, model.ProjectId, model.Region) + return apiClient.DefaultAPI.ListShareExportPolicies(ctx, model.ProjectId, model.Region) } func outputResult(p *print.Printer, outputFormat, projectLabel string, exportPolicies []sfs.ShareExportPolicy) error { @@ -132,7 +132,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, exportPol for _, exportPolicy := range exportPolicies { amountRules := "-" if exportPolicy.Rules != nil { - amountRules = strconv.Itoa(len(*exportPolicy.Rules)) + amountRules = strconv.Itoa(len(exportPolicy.Rules)) } table.AddRow( utils.PtrString(exportPolicy.Id), diff --git a/internal/cmd/beta/sfs/export-policy/list/list_test.go b/internal/cmd/beta/sfs/export-policy/list/list_test.go index 0adda28b3..b2ce7389a 100644 --- a/internal/cmd/beta/sfs/export-policy/list/list_test.go +++ b/internal/cmd/beta/sfs/export-policy/list/list_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -22,7 +22,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -55,7 +55,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiListShareExportPoliciesRequest)) sfs.ApiListShareExportPoliciesRequest { - request := testClient.ListShareExportPolicies(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListShareExportPolicies(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -128,7 +128,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/beta/sfs/export-policy/update/update.go b/internal/cmd/beta/sfs/export-policy/update/update.go index 5b0e1457a..55c22a5b8 100644 --- a/internal/cmd/beta/sfs/export-policy/update/update.go +++ b/internal/cmd/beta/sfs/export-policy/update/update.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -37,16 +37,16 @@ type inputModel struct { func NewCmd(params *types.CmdParams) *cobra.Command { cmd := &cobra.Command{ Use: fmt.Sprintf("update %s", exportPolicyArg), - Short: "Updates a export policy", - Long: "Updates a export policy.", + Short: "Updates an export policy", + Long: "Updates an export policy.", Args: args.SingleArg(exportPolicyArg, utils.ValidateUUID), Example: examples.Build( examples.NewExample( - `Update a export policy with ID "xxx" and with rules from file "./rules.json"`, + `Update an export policy with ID "xxx" and with rules from file "./rules.json"`, "$ stackit beta sfs export-policy update xxx --rules @./rules.json", ), examples.NewExample( - `Update a export policy with ID "xxx" and remove the rules`, + `Update an export policy with ID "xxx" and remove the rules`, "$ stackit beta sfs export-policy update XXX --remove-rules", ), ), @@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - exportPolicyLabel, err := sfsUtils.GetExportPolicyName(ctx, apiClient, model.ProjectId, model.Region, model.ExportPolicyId) + exportPolicyLabel, err := sfsUtils.GetExportPolicyName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ExportPolicyId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get export policy name: %v", err) exportPolicyLabel = model.ExportPolicyId @@ -109,10 +109,10 @@ func configureFlags(cmd *cobra.Command) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiUpdateShareExportPolicyRequest { - req := apiClient.UpdateShareExportPolicy(ctx, model.ProjectId, model.Region, model.ExportPolicyId) + req := apiClient.DefaultAPI.UpdateShareExportPolicy(ctx, model.ProjectId, model.Region, model.ExportPolicyId) payload := sfs.UpdateShareExportPolicyPayload{ - Rules: model.Rules, + Rules: *model.Rules, } return req.UpdateShareExportPolicyPayload(payload) } diff --git a/internal/cmd/beta/sfs/export-policy/update/update_test.go b/internal/cmd/beta/sfs/export-policy/update/update_test.go index 10441c24a..a707cc54e 100644 --- a/internal/cmd/beta/sfs/export-policy/update/update_test.go +++ b/internal/cmd/beta/sfs/export-policy/update/update_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -21,7 +21,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() @@ -38,9 +38,10 @@ const ( var testRules = &[]sfs.UpdateShareExportPolicyBodyRule{ { - IpAcl: utils.Ptr([]string{"172.16.0.0/24"}), - ReadOnly: utils.Ptr(true), - Order: utils.Ptr(int64(1)), + IpAcl: []string{"172.16.0.0/24"}, + ReadOnly: utils.Ptr(true), + Order: utils.Ptr(int32(1)), + AdditionalProperties: map[string]any{}, }, } var testExportPolicyId = uuid.NewString() @@ -84,7 +85,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiUpdateShareExportPolicyRequest)) sfs.ApiUpdateShareExportPolicyRequest { - request := testClient.UpdateShareExportPolicy(testCtx, testProjectId, testRegion, testExportPolicyId) + request := testClient.DefaultAPI.UpdateShareExportPolicy(testCtx, testProjectId, testRegion, testExportPolicyId) request = request.UpdateShareExportPolicyPayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -94,7 +95,7 @@ func fixtureRequest(mods ...func(request *sfs.ApiUpdateShareExportPolicyRequest) func fixturePayload(mods ...func(payload *sfs.UpdateShareExportPolicyPayload)) sfs.UpdateShareExportPolicyPayload { payload := sfs.UpdateShareExportPolicyPayload{ - Rules: testRules, + Rules: *testRules, } for _, mod := range mods { mod(&payload) @@ -159,18 +160,20 @@ func TestParseInput(t *testing.T) { expectedModel: fixtureInputModel(func(model *inputModel) { model.Rules = &[]sfs.UpdateShareExportPolicyBodyRule{ { - Description: sfs.NewNullableString( + Description: *sfs.NewNullableString( utils.Ptr("first rule"), ), - IpAcl: utils.Ptr([]string{"192.168.2.0/24"}), - Order: utils.Ptr(int64(1)), - SetUuid: utils.Ptr(true), - SuperUser: utils.Ptr(false), + IpAcl: []string{"192.168.2.0/24"}, + Order: utils.Ptr(int32(1)), + SetUuid: utils.Ptr(true), + SuperUser: utils.Ptr(false), + AdditionalProperties: map[string]any{}, }, { - IpAcl: utils.Ptr([]string{"192.168.2.0/24", "127.0.0.1/32"}), - Order: utils.Ptr(int64(2)), - ReadOnly: utils.Ptr(true), + IpAcl: []string{"192.168.2.0/24", "127.0.0.1/32"}, + Order: utils.Ptr(int32(2)), + ReadOnly: utils.Ptr(true), + AdditionalProperties: map[string]any{"readonly": true}, }, } }), @@ -204,8 +207,9 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), + cmp.AllowUnexported(sfs.NullableString{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/sfs/performance-class/list/list.go b/internal/cmd/beta/sfs/performance-class/list/list.go index c16ed52e9..2352c7411 100644 --- a/internal/cmd/beta/sfs/performance-class/list/list.go +++ b/internal/cmd/beta/sfs/performance-class/list/list.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { projectLabel = model.ProjectId } - performanceClasses := utils.GetSliceFromPointer(resp.PerformanceClasses) + performanceClasses := utils.GetSliceFromPointer(&resp.PerformanceClasses) return outputResult(params.Printer, model.OutputFormat, projectLabel, performanceClasses) }, @@ -86,7 +86,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, apiClient *sfs.APIClient) sfs.ApiListPerformanceClassesRequest { - return apiClient.ListPerformanceClasses(ctx) + return apiClient.DefaultAPI.ListPerformanceClasses(ctx) } func outputResult(p *print.Printer, outputFormat, projectLabel string, performanceClasses []sfs.PerformanceClass) error { diff --git a/internal/cmd/beta/sfs/performance-class/list/list_test.go b/internal/cmd/beta/sfs/performance-class/list/list_test.go index dd1a7ecc1..1c05d3ec8 100644 --- a/internal/cmd/beta/sfs/performance-class/list/list_test.go +++ b/internal/cmd/beta/sfs/performance-class/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -51,7 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiListPerformanceClassesRequest)) sfs.ApiListPerformanceClassesRequest { - request := testClient.ListPerformanceClasses(testCtx) + request := testClient.DefaultAPI.ListPerformanceClasses(testCtx) for _, mod := range mods { mod(&request) } @@ -122,8 +122,9 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), + cmp.AllowUnexported(sfs.NullableString{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/sfs/resource-pool/create/create.go b/internal/cmd/beta/sfs/resource-pool/create/create.go index 38df9acf1..47420cbc3 100644 --- a/internal/cmd/beta/sfs/resource-pool/create/create.go +++ b/internal/cmd/beta/sfs/resource-pool/create/create.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" - "github.com/stackitcloud/stackit-sdk-go/services/sfs/wait" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -32,7 +32,7 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel - SizeInGB int64 + SizeInGB *int32 PerformanceClass string IpAcl []string Name string @@ -102,7 +102,7 @@ The available performance class values can be obtained by running: // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Create resource pool", func() error { - _, err = wait.CreateResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resourcePoolId).WaitWithContext(ctx) + _, err = wait.CreateResourcePoolWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, resourcePoolId).WaitWithContext(ctx) return err }) if err != nil { @@ -118,7 +118,7 @@ The available performance class values can be obtained by running: } func configureFlags(cmd *cobra.Command) { - cmd.Flags().Int64(sizeFlag, 0, "Size of the pool in Gigabytes") + cmd.Flags().Int32(sizeFlag, 0, "Size of the pool in Gigabytes") cmd.Flags().String(performanceClassFlag, "", "Performance class") cmd.Flags().Var(flags.CIDRSliceFlag(), ipAclFlag, "List of network addresses in the form , e.g. 192.168.10.0/24 that can mount the resource pool readonly") cmd.Flags().String(availabilityZoneFlag, "", "Availability zone") @@ -132,13 +132,13 @@ func configureFlags(cmd *cobra.Command) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiCreateResourcePoolRequest { - req := apiClient.CreateResourcePool(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.CreateResourcePool(ctx, model.ProjectId, model.Region) req = req.CreateResourcePoolPayload(sfs.CreateResourcePoolPayload{ - AvailabilityZone: &model.AvailabilityZone, - IpAcl: &model.IpAcl, - Name: &model.Name, - PerformanceClass: &model.PerformanceClass, - SizeGigabytes: &model.SizeInGB, + AvailabilityZone: model.AvailabilityZone, + IpAcl: model.IpAcl, + Name: model.Name, + PerformanceClass: model.PerformanceClass, + SizeGigabytes: *model.SizeInGB, SnapshotsAreVisible: &model.SnapshotsVisible, }) return req @@ -151,16 +151,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } performanceClass := flags.FlagToStringValue(p, cmd, performanceClassFlag) - size := flags.FlagWithDefaultToInt64Value(p, cmd, sizeFlag) + size := flags.FlagToInt32Pointer(p, cmd, sizeFlag) availabilityZone := flags.FlagToStringValue(p, cmd, availabilityZoneFlag) - ipAcls := flags.FlagToStringSlicePointer(p, cmd, ipAclFlag) + ipAcls := flags.FlagToStringSliceValue(p, cmd, ipAclFlag) name := flags.FlagToStringValue(p, cmd, nameFlag) snapshotsVisible := flags.FlagToBoolValue(p, cmd, snapshotsVisibleFlag) model := inputModel{ GlobalFlagModel: globalFlags, SizeInGB: size, - IpAcl: *ipAcls, + IpAcl: ipAcls, PerformanceClass: performanceClass, AvailabilityZone: availabilityZone, Name: name, diff --git a/internal/cmd/beta/sfs/resource-pool/create/create_test.go b/internal/cmd/beta/sfs/resource-pool/create/create_test.go index 9cdaf3c9a..8dbb653e9 100644 --- a/internal/cmd/beta/sfs/resource-pool/create/create_test.go +++ b/internal/cmd/beta/sfs/resource-pool/create/create_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,13 +20,13 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var ( testProjectId = uuid.NewString() testRegion = "eu02" testResourcePoolPerformanceClass = "Standard" - testResourcePoolSizeInGB int64 = 50 + testResourcePoolSizeInGB int32 = 50 testResourcePoolAvailabilityZone = "eu02-m" testResourcePoolName = "sfs-resource-pool-01" testResourcePoolIpAcl = []string{"10.88.135.144/28", "250.81.87.224/32"} @@ -38,7 +38,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.ProjectIdFlag: testProjectId, globalflags.RegionFlag: testRegion, performanceClassFlag: testResourcePoolPerformanceClass, - sizeFlag: strconv.FormatInt(testResourcePoolSizeInGB, 10), + sizeFlag: strconv.FormatInt(int64(testResourcePoolSizeInGB), 10), ipAclFlag: strings.Join(testResourcePoolIpAcl, ","), availabilityZoneFlag: testResourcePoolAvailabilityZone, nameFlag: testResourcePoolName, @@ -60,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { PerformanceClass: testResourcePoolPerformanceClass, AvailabilityZone: testResourcePoolAvailabilityZone, Name: testResourcePoolName, - SizeInGB: testResourcePoolSizeInGB, + SizeInGB: &testResourcePoolSizeInGB, IpAcl: testResourcePoolIpAcl, SnapshotsVisible: testSnapshotsVisible, } @@ -71,13 +71,13 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiCreateResourcePoolRequest)) sfs.ApiCreateResourcePoolRequest { - request := testClient.CreateResourcePool(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateResourcePool(testCtx, testProjectId, testRegion) request = request.CreateResourcePoolPayload(sfs.CreateResourcePoolPayload{ - Name: &testResourcePoolName, - PerformanceClass: &testResourcePoolPerformanceClass, - AvailabilityZone: &testResourcePoolAvailabilityZone, - IpAcl: &testResourcePoolIpAcl, - SizeGigabytes: &testResourcePoolSizeInGB, + Name: testResourcePoolName, + PerformanceClass: testResourcePoolPerformanceClass, + AvailabilityZone: testResourcePoolAvailabilityZone, + IpAcl: testResourcePoolIpAcl, + SizeGigabytes: testResourcePoolSizeInGB, SnapshotsAreVisible: &testSnapshotsVisible, }) for _, mod := range mods { @@ -240,7 +240,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -278,7 +278,7 @@ func TestOutputResult(t *testing.T) { name: "set response", args: args{ resp: &sfs.CreateResourcePoolResponse{ - ResourcePool: &sfs.CreateResourcePoolResponseResourcePool{}, + ResourcePool: &sfs.ResourcePool{}, }, }, wantErr: false, diff --git a/internal/cmd/beta/sfs/resource-pool/delete/delete.go b/internal/cmd/beta/sfs/resource-pool/delete/delete.go index f67d92976..d5cd7e1cd 100644 --- a/internal/cmd/beta/sfs/resource-pool/delete/delete.go +++ b/internal/cmd/beta/sfs/resource-pool/delete/delete.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" - "github.com/stackitcloud/stackit-sdk-go/services/sfs/wait" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - resourcePoolName, err := sfsUtils.GetResourcePoolName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId) + resourcePoolName, err := sfsUtils.GetResourcePoolName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get resource pool name: %v", err) resourcePoolName = model.ResourcePoolId @@ -75,7 +75,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Delete resource pool", func() error { - _, err = wait.DeleteResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId).WaitWithContext(ctx) + _, err = wait.DeleteResourcePoolWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId).WaitWithContext(ctx) return err }) if err != nil { @@ -90,7 +90,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiDeleteResourcePoolRequest { - req := apiClient.DeleteResourcePool(ctx, model.ProjectId, model.Region, model.ResourcePoolId) + req := apiClient.DefaultAPI.DeleteResourcePool(ctx, model.ProjectId, model.Region, model.ResourcePoolId) return req } diff --git a/internal/cmd/beta/sfs/resource-pool/delete/delete_test.go b/internal/cmd/beta/sfs/resource-pool/delete/delete_test.go index 9d7cda89f..1224548c0 100644 --- a/internal/cmd/beta/sfs/resource-pool/delete/delete_test.go +++ b/internal/cmd/beta/sfs/resource-pool/delete/delete_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testResourcePoolId = uuid.NewString() var testRegion = "eu02" @@ -60,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiDeleteResourcePoolRequest)) sfs.ApiDeleteResourcePoolRequest { - request := testClient.DeleteResourcePool(testCtx, testProjectId, testRegion, testResourcePoolId) + request := testClient.DefaultAPI.DeleteResourcePool(testCtx, testProjectId, testRegion, testResourcePoolId) for _, mod := range mods { mod(&request) } @@ -163,7 +163,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/beta/sfs/resource-pool/describe/describe.go b/internal/cmd/beta/sfs/resource-pool/describe/describe.go index c428b53e1..c3a451fae 100644 --- a/internal/cmd/beta/sfs/resource-pool/describe/describe.go +++ b/internal/cmd/beta/sfs/resource-pool/describe/describe.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiGetResourcePoolRequest { - req := apiClient.GetResourcePool(ctx, model.ProjectId, model.Region, model.ResourcePoolId) + req := apiClient.DefaultAPI.GetResourcePool(ctx, model.ProjectId, model.Region, model.ResourcePoolId) return req } @@ -97,7 +97,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func outputResult(p *print.Printer, outputFormat, resourcePoolId, projectLabel string, resourcePool *sfs.GetResourcePoolResponseResourcePool) error { +func outputResult(p *print.Printer, outputFormat, resourcePoolId, projectLabel string, resourcePool *sfs.ResourcePool) error { return p.OutputResult(outputFormat, resourcePool, func() error { if resourcePool == nil { p.Outputf("Resource pool %q not found in project %q\n", resourcePoolId, projectLabel) @@ -108,7 +108,7 @@ func outputResult(p *print.Printer, outputFormat, resourcePoolId, projectLabel s // convert the string slice to a comma separated list var ipAclStr string if resourcePool.IpAcl != nil { - ipAclStr = strings.Join(*resourcePool.IpAcl, ", ") + ipAclStr = strings.Join(resourcePool.IpAcl, ", ") } table.AddRow("ID", utils.PtrString(resourcePool.Id)) @@ -129,16 +129,16 @@ func outputResult(p *print.Printer, outputFormat, resourcePoolId, projectLabel s } table.AddRow("SNAPSHOTS ARE VISIBLE", utils.PtrString(resourcePool.SnapshotsAreVisible)) table.AddSeparator() - table.AddRow("NEXT PERFORMANCE CLASS DOWNGRADE TIME", utils.PtrString(resourcePool.PerformanceClassDowngradableAt)) + table.AddRow("NEXT PERFORMANCE CLASS DOWNGRADE TIME", resourcePool.PerformanceClassDowngradableAt) table.AddSeparator() - table.AddRow("NEXT SIZE REDUCTION TIME", utils.PtrString(resourcePool.SizeReducibleAt)) + table.AddRow("NEXT SIZE REDUCTION TIME", resourcePool.SizeReducibleAt) table.AddSeparator() if resourcePool.HasSpace() { table.AddRow("TOTAL SIZE (GB)", utils.PtrString(resourcePool.Space.SizeGigabytes)) table.AddSeparator() - table.AddRow("AVAILABLE SIZE (GB)", utils.PtrString(resourcePool.Space.AvailableGigabytes)) + table.AddRow("AVAILABLE SIZE (GB)", utils.PtrString(resourcePool.Space.AvailableGigabytes.Get())) table.AddSeparator() - table.AddRow("USED SIZE (GB)", utils.PtrString(resourcePool.Space.UsedGigabytes)) + table.AddRow("USED SIZE (GB)", utils.PtrString(resourcePool.Space.UsedGigabytes.Get())) table.AddSeparator() } table.AddRow("STATE", utils.PtrString(resourcePool.State)) diff --git a/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go b/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go index a7da91158..6a125f802 100644 --- a/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go +++ b/internal/cmd/beta/sfs/resource-pool/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,7 +17,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testResourcePoolId = uuid.NewString() @@ -60,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiGetResourcePoolRequest)) sfs.ApiGetResourcePoolRequest { - request := testClient.GetResourcePool(testCtx, testProjectId, testRegion, testResourcePoolId) + request := testClient.DefaultAPI.GetResourcePool(testCtx, testProjectId, testRegion, testResourcePoolId) for _, mod := range mods { mod(&request) } @@ -163,7 +163,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -178,7 +178,7 @@ func TestOutputResult(t *testing.T) { outputFormat string resourcePoolId string projectLabel string - resp *sfs.GetResourcePoolResponseResourcePool + resp *sfs.ResourcePool } tests := []struct { name string @@ -193,7 +193,7 @@ func TestOutputResult(t *testing.T) { { name: "set empty response", args: args{ - resp: &sfs.GetResourcePoolResponseResourcePool{}, + resp: &sfs.ResourcePool{}, }, wantErr: false, }, diff --git a/internal/cmd/beta/sfs/resource-pool/list/list.go b/internal/cmd/beta/sfs/resource-pool/list/list.go index d70ebf5a8..be46ce2ec 100644 --- a/internal/cmd/beta/sfs/resource-pool/list/list.go +++ b/internal/cmd/beta/sfs/resource-pool/list/list.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -66,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("list SFS resource pools: %w", err) } - resourcePools := utils.GetSliceFromPointer(resp.ResourcePools) + resourcePools := utils.GetSliceFromPointer(&resp.ResourcePools) // Truncate output if model.Limit != nil && len(resourcePools) > int(*model.Limit) { @@ -94,7 +94,7 @@ func configureFlags(cmd *cobra.Command) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiListResourcePoolsRequest { - req := apiClient.ListResourcePools(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.ListResourcePools(ctx, model.ProjectId, model.Region) return req } @@ -133,7 +133,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, resourceP totalSizeGigabytes, usedSizeGigabytes := "", "" if resourcePool.HasSpace() { totalSizeGigabytes = utils.PtrString(resourcePool.Space.SizeGigabytes) - usedSizeGigabytes = utils.PtrString(resourcePool.Space.UsedGigabytes) + usedSizeGigabytes = utils.PtrString(resourcePool.Space.UsedGigabytes.Get()) } table.AddRow( utils.PtrString(resourcePool.Id), diff --git a/internal/cmd/beta/sfs/resource-pool/list/list_test.go b/internal/cmd/beta/sfs/resource-pool/list/list_test.go index ce2e6b717..675b7092b 100644 --- a/internal/cmd/beta/sfs/resource-pool/list/list_test.go +++ b/internal/cmd/beta/sfs/resource-pool/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu02" @@ -50,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiListResourcePoolsRequest)) sfs.ApiListResourcePoolsRequest { - request := testClient.ListResourcePools(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListResourcePools(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -145,7 +145,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/beta/sfs/resource-pool/update/update.go b/internal/cmd/beta/sfs/resource-pool/update/update.go index f70b6d7da..0203c80d8 100644 --- a/internal/cmd/beta/sfs/resource-pool/update/update.go +++ b/internal/cmd/beta/sfs/resource-pool/update/update.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" - "github.com/stackitcloud/stackit-sdk-go/services/sfs/wait" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -32,9 +32,9 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel - SizeGigabytes *int64 + SizeGigabytes *int32 PerformanceClass *string - IpAcl *[]string + IpAcl []string ResourcePoolId string SnapshotsVisible *bool } @@ -82,7 +82,7 @@ The available performance class values can be obtained by running: projectLabel = model.ProjectId } - resourcePoolName, err := sfsUtils.GetResourcePoolName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId) + resourcePoolName, err := sfsUtils.GetResourcePoolName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get resource pool name: %v", err) resourcePoolName = model.ResourcePoolId @@ -103,7 +103,7 @@ The available performance class values can be obtained by running: // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Update resource pool", func() error { - _, err = wait.UpdateResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId).WaitWithContext(ctx) + _, err = wait.UpdateResourcePoolWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId).WaitWithContext(ctx) return err }) if err != nil { @@ -119,18 +119,18 @@ The available performance class values can be obtained by running: } func configureFlags(cmd *cobra.Command) { - cmd.Flags().Int64(sizeFlag, 0, "Size of the pool in Gigabytes") + cmd.Flags().Int32(sizeFlag, 0, "Size of the pool in Gigabytes") cmd.Flags().String(performanceClassFlag, "", "Performance class") cmd.Flags().Var(flags.CIDRSliceFlag(), ipAclFlag, "List of network addresses in the form , e.g. 192.168.10.0/24 that can mount the resource pool readonly") cmd.Flags().Bool(snapshotsVisibleFlag, false, "Set snapshots visible and accessible to users") } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiUpdateResourcePoolRequest { - req := apiClient.UpdateResourcePool(ctx, model.ProjectId, model.Region, model.ResourcePoolId) + req := apiClient.DefaultAPI.UpdateResourcePool(ctx, model.ProjectId, model.Region, model.ResourcePoolId) req = req.UpdateResourcePoolPayload(sfs.UpdateResourcePoolPayload{ IpAcl: model.IpAcl, PerformanceClass: model.PerformanceClass, - SizeGigabytes: model.SizeGigabytes, + SizeGigabytes: *sfs.NewNullableInt32(model.SizeGigabytes), SnapshotsAreVisible: model.SnapshotsVisible, }) return req @@ -145,8 +145,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } performanceClass := flags.FlagToStringPointer(p, cmd, performanceClassFlag) - size := flags.FlagToInt64Pointer(p, cmd, sizeFlag) - ipAcls := flags.FlagToStringSlicePointer(p, cmd, ipAclFlag) + size := flags.FlagToInt32Pointer(p, cmd, sizeFlag) + ipAcls := flags.FlagToStringSliceValue(p, cmd, ipAclFlag) snapshotsVisible := flags.FlagToBoolPointer(p, cmd, snapshotsVisibleFlag) if performanceClass == nil && size == nil && ipAcls == nil && snapshotsVisible == nil { diff --git a/internal/cmd/beta/sfs/resource-pool/update/update_test.go b/internal/cmd/beta/sfs/resource-pool/update/update_test.go index 0acc1f6a9..58d2d4c0e 100644 --- a/internal/cmd/beta/sfs/resource-pool/update/update_test.go +++ b/internal/cmd/beta/sfs/resource-pool/update/update_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -26,13 +26,13 @@ const ( var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &sfs.APIClient{} + testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} testProjectId = uuid.NewString() testResourcePoolId = uuid.NewString() testResourcePoolIpAcl = []string{"10.88.135.144/28", "250.81.87.224/32"} testResourcePoolPerformanceClass = "Standard" - testResourcePoolSizeInGB int64 = 50 + testResourcePoolSizeInGB int32 = 50 testSnapshotsVisible = true ) @@ -51,7 +51,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.ProjectIdFlag: testProjectId, globalflags.RegionFlag: testRegion, performanceClassFlag: testResourcePoolPerformanceClass, - sizeFlag: strconv.FormatInt(testResourcePoolSizeInGB, 10), + sizeFlag: strconv.FormatInt(int64(testResourcePoolSizeInGB), 10), ipAclFlag: strings.Join(testResourcePoolIpAcl, ","), snapshotsVisibleFlag: strconv.FormatBool(testSnapshotsVisible), } @@ -73,7 +73,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { ResourcePoolId: testResourcePoolId, SizeGigabytes: &testResourcePoolSizeInGB, PerformanceClass: &testResourcePoolPerformanceClass, - IpAcl: &ipAclClone, + IpAcl: ipAclClone, SnapshotsVisible: &testSnapshotsVisible, } for _, mod := range mods { @@ -83,11 +83,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiUpdateResourcePoolRequest)) sfs.ApiUpdateResourcePoolRequest { - request := testClient.UpdateResourcePool(testCtx, testProjectId, testRegion, testResourcePoolId) + request := testClient.DefaultAPI.UpdateResourcePool(testCtx, testProjectId, testRegion, testResourcePoolId) request = request.UpdateResourcePoolPayload(sfs.UpdateResourcePoolPayload{ - IpAcl: &testResourcePoolIpAcl, + IpAcl: testResourcePoolIpAcl, PerformanceClass: &testResourcePoolPerformanceClass, - SizeGigabytes: &testResourcePoolSizeInGB, + SizeGigabytes: *sfs.NewNullableInt32(&testResourcePoolSizeInGB), SnapshotsAreVisible: &testSnapshotsVisible, }) for _, mod := range mods { @@ -248,9 +248,9 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { if model.IpAcl == nil { - model.IpAcl = &[]string{} + model.IpAcl = []string{} } - *model.IpAcl = append(*model.IpAcl, "198.51.100.14/24", "198.51.100.14/32") + model.IpAcl = append(model.IpAcl, "198.51.100.14/24", "198.51.100.14/32") }), }, { @@ -261,9 +261,9 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { if model.IpAcl == nil { - model.IpAcl = &[]string{} + model.IpAcl = []string{} } - *model.IpAcl = append(*model.IpAcl, "198.51.100.14/24", "198.51.100.14/32") + model.IpAcl = append(model.IpAcl, "198.51.100.14/24", "198.51.100.14/32") }), }, } @@ -295,8 +295,9 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), + cmp.AllowUnexported(sfs.NullableInt32{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -332,7 +333,7 @@ func TestOutputResult(t *testing.T) { name: "valid response with empty resource pool", args: args{ resp: &sfs.UpdateResourcePoolResponse{ - ResourcePool: &sfs.UpdateResourcePoolResponseResourcePool{}, + ResourcePool: &sfs.ResourcePool{}, }, }, wantErr: false, @@ -341,7 +342,7 @@ func TestOutputResult(t *testing.T) { name: "valid response with name", args: args{ resp: &sfs.UpdateResourcePoolResponse{ - ResourcePool: &sfs.UpdateResourcePoolResponseResourcePool{ + ResourcePool: &sfs.ResourcePool{ Name: utils.Ptr("example name"), }, }, diff --git a/internal/cmd/beta/sfs/share/create/create.go b/internal/cmd/beta/sfs/share/create/create.go index 3a565f197..5d57a5d7d 100644 --- a/internal/cmd/beta/sfs/share/create/create.go +++ b/internal/cmd/beta/sfs/share/create/create.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" - "github.com/stackitcloud/stackit-sdk-go/services/sfs/wait" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -33,7 +33,7 @@ type inputModel struct { Name string ExportPolicyName *string ResourcePoolId string - HardLimit *int64 + HardLimit *int32 } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -65,7 +65,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId) + resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get resource pool name: %v", err) resourcePoolLabel = model.ResourcePoolId @@ -93,7 +93,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating share", func() error { - _, err = wait.CreateShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, shareId).WaitWithContext(ctx) + _, err = wait.CreateShareWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId, shareId).WaitWithContext(ctx) return err }) if err != nil { @@ -112,7 +112,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(nameFlag, "", "Share name") cmd.Flags().Var(flags.UUIDFlag(), resourcePoolIdFlag, "The resource pool the share is assigned to") cmd.Flags().String(exportPolicyNameFlag, "", "The export policy the share is assigned to") - cmd.Flags().Int64(hardLimitFlag, 0, "The space hard limit for the share") + cmd.Flags().Int32(hardLimitFlag, 0, "The space hard limit for the share") err := flags.MarkFlagsRequired(cmd, nameFlag, resourcePoolIdFlag, hardLimitFlag) cobra.CheckErr(err) @@ -124,7 +124,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return nil, &errors.ProjectIdError{} } - hardLimit := flags.FlagToInt64Pointer(p, cmd, hardLimitFlag) + hardLimit := flags.FlagToInt32Pointer(p, cmd, hardLimitFlag) if hardLimit != nil { if *hardLimit < 0 { return nil, &errors.FlagValidationError{ @@ -147,12 +147,12 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiCreateShareRequest { - req := apiClient.CreateShare(ctx, model.ProjectId, model.Region, model.ResourcePoolId) + req := apiClient.DefaultAPI.CreateShare(ctx, model.ProjectId, model.Region, model.ResourcePoolId) req = req.CreateSharePayload( sfs.CreateSharePayload{ - Name: utils.Ptr(model.Name), - ExportPolicyName: sfs.NewNullableString(model.ExportPolicyName), - SpaceHardLimitGigabytes: model.HardLimit, + Name: model.Name, + ExportPolicyName: *sfs.NewNullableString(model.ExportPolicyName), + SpaceHardLimitGigabytes: *model.HardLimit, }, ) return req diff --git a/internal/cmd/beta/sfs/share/create/create_test.go b/internal/cmd/beta/sfs/share/create/create_test.go index 87869da54..9727c0d0a 100644 --- a/internal/cmd/beta/sfs/share/create/create_test.go +++ b/internal/cmd/beta/sfs/share/create/create_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -22,7 +22,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -30,7 +30,7 @@ var testRegion = "eu01" var testName = "test-name" var testResourcePoolId = uuid.NewString() var testExportPolicyName = "test-export-policy" -var testHardLimit int64 = 10 +var testHardLimit int32 = 10 func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ @@ -67,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiCreateShareRequest)) sfs.ApiCreateShareRequest { - request := testClient.CreateShare(testCtx, testProjectId, testRegion, testResourcePoolId) + request := testClient.DefaultAPI.CreateShare(testCtx, testProjectId, testRegion, testResourcePoolId) request = request.CreateSharePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -77,9 +77,9 @@ func fixtureRequest(mods ...func(request *sfs.ApiCreateShareRequest)) sfs.ApiCre func fixturePayload(mods ...func(request *sfs.CreateSharePayload)) sfs.CreateSharePayload { payload := sfs.CreateSharePayload{ - Name: utils.Ptr(testName), - ExportPolicyName: sfs.NewNullableString(utils.Ptr(testExportPolicyName)), - SpaceHardLimitGigabytes: utils.Ptr(testHardLimit), + Name: testName, + ExportPolicyName: *sfs.NewNullableString(utils.Ptr(testExportPolicyName)), + SpaceHardLimitGigabytes: testHardLimit, } for _, mod := range mods { mod(&payload) @@ -150,7 +150,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), cmp.AllowUnexported(sfs.NullableString{}), ) @@ -189,7 +189,7 @@ func TestOutputResult(t *testing.T) { name: "set empty response share", args: args{ item: &sfs.CreateShareResponse{ - Share: &sfs.CreateShareResponseShare{}, + Share: &sfs.Share{}, }, }, wantErr: false, diff --git a/internal/cmd/beta/sfs/share/delete/delete.go b/internal/cmd/beta/sfs/share/delete/delete.go index c9086fe77..ed4cf417b 100644 --- a/internal/cmd/beta/sfs/share/delete/delete.go +++ b/internal/cmd/beta/sfs/share/delete/delete.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" - "github.com/stackitcloud/stackit-sdk-go/services/sfs/wait" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - shareLabel, err := sfsUtils.GetShareName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) + shareLabel, err := sfsUtils.GetShareName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get share name: %v", err) shareLabel = model.ShareId @@ -82,7 +82,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting share", func() error { - _, err = wait.DeleteShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId).WaitWithContext(ctx) + _, err = wait.DeleteShareWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId).WaitWithContext(ctx) return err }) if err != nil { @@ -129,5 +129,5 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiDeleteShareRequest { - return apiClient.DeleteShare(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) + return apiClient.DefaultAPI.DeleteShare(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) } diff --git a/internal/cmd/beta/sfs/share/delete/delete_test.go b/internal/cmd/beta/sfs/share/delete/delete_test.go index a6526653b..e8c63f367 100644 --- a/internal/cmd/beta/sfs/share/delete/delete_test.go +++ b/internal/cmd/beta/sfs/share/delete/delete_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -19,7 +19,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -67,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiDeleteShareRequest)) sfs.ApiDeleteShareRequest { - request := testClient.DeleteShare(testCtx, testProjectId, testRegion, testResourcePoolId, testShareId) + request := testClient.DefaultAPI.DeleteShare(testCtx, testProjectId, testRegion, testResourcePoolId, testShareId) for _, mod := range mods { mod(&request) } @@ -176,7 +176,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/beta/sfs/share/describe/describe.go b/internal/cmd/beta/sfs/share/describe/describe.go index 9fb2b1f06..e2756f757 100644 --- a/internal/cmd/beta/sfs/share/describe/describe.go +++ b/internal/cmd/beta/sfs/share/describe/describe.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -41,7 +41,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { Example: examples.Build( examples.NewExample( `Describe a shares with ID "xxx" from resource pool with ID "yyy"`, - "$ stackit beta sfs export-policy describe xxx --resource-pool-id yyy", + "$ stackit beta sfs share describe xxx --resource-pool-id yyy", ), ), RunE: func(cmd *cobra.Command, inputArgs []string) error { @@ -64,7 +64,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("describe SFS share: %w", err) } - resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId) + resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get resource pool name: %v", err) resourcePoolLabel = model.ResourcePoolId @@ -104,7 +104,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiGetShareRequest { - return apiClient.GetShare(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) + return apiClient.DefaultAPI.GetShare(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) } func outputResult(p *print.Printer, outputFormat, resourcePoolLabel, shareId string, share *sfs.GetShareResponse) error { @@ -156,22 +156,22 @@ func outputResult(p *print.Printer, outputFormat, resourcePoolLabel, shareId str content = append(content, policyTable) - if policy.Rules != nil && len(*policy.Rules) > 0 { + if len(policy.Rules) > 0 { ruleTable := tables.NewTable() ruleTable.SetTitle("Export Policy - Rules") ruleTable.SetHeader("ID", "ORDER", "DESCRIPTION", "IP ACL", "READ ONLY", "SET UUID", "SUPER USER", "CREATED AT") - for _, rule := range *policy.Rules { + for _, rule := range policy.Rules { var description string - if rule.Description != nil { + if rule.Description.IsSet() && *rule.Description.Get() != "" { description = utils.PtrString(rule.Description.Get()) } ruleTable.AddRow( utils.PtrString(rule.Id), utils.PtrString(rule.Order), description, - utils.JoinStringPtr(rule.IpAcl, ", "), + utils.JoinStringPtr(&rule.IpAcl, ", "), utils.PtrString(rule.ReadOnly), utils.PtrString(rule.SetUuid), utils.PtrString(rule.SuperUser), diff --git a/internal/cmd/beta/sfs/share/describe/describe_test.go b/internal/cmd/beta/sfs/share/describe/describe_test.go index acfa9a3f2..6848ae685 100644 --- a/internal/cmd/beta/sfs/share/describe/describe_test.go +++ b/internal/cmd/beta/sfs/share/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -68,7 +68,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiGetShareRequest)) sfs.ApiGetShareRequest { - request := testClient.GetShare(testCtx, testProjectId, testRegion, testResourcePoolId, testShareId) + request := testClient.DefaultAPI.GetShare(testCtx, testProjectId, testRegion, testResourcePoolId, testShareId) for _, mod := range mods { mod(&request) } @@ -177,7 +177,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -215,7 +215,7 @@ func TestOutputResult(t *testing.T) { name: "set empty share", args: args{ share: &sfs.GetShareResponse{ - Share: &sfs.GetShareResponseShare{}, + Share: &sfs.Share{}, }, }, wantErr: false, diff --git a/internal/cmd/beta/sfs/share/list/list.go b/internal/cmd/beta/sfs/share/list/list.go index 9f0aa1386..5816a9185 100644 --- a/internal/cmd/beta/sfs/share/list/list.go +++ b/internal/cmd/beta/sfs/share/list/list.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -40,11 +40,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command { Example: examples.Build( examples.NewExample( `List all shares from resource pool with ID "xxx"`, - "$ stackit beta sfs export-policy list --resource-pool-id xxx", + "$ stackit beta sfs share list --resource-pool-id xxx", ), examples.NewExample( `List up to 10 shares from resource pool with ID "xxx"`, - "$ stackit beta sfs export-policy list --resource-pool-id xxx --limit 10", + "$ stackit beta sfs share list --resource-pool-id xxx --limit 10", ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -67,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("list SFS share: %w", err) } - resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId) + resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get resource pool name: %v", err) resourcePoolLabel = model.ResourcePoolId @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Truncate output - items := utils.GetSliceFromPointer(resp.Shares) + items := utils.GetSliceFromPointer(&resp.Shares) if model.Limit != nil && len(items) > int(*model.Limit) { items = items[:*model.Limit] } @@ -121,7 +121,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiListSharesRequest { - return apiClient.ListShares(ctx, model.ProjectId, model.Region, model.ResourcePoolId) + return apiClient.DefaultAPI.ListShares(ctx, model.ProjectId, model.Region, model.ResourcePoolId) } func outputResult(p *print.Printer, outputFormat, resourcePoolLabel string, shares []sfs.Share) error { @@ -136,11 +136,11 @@ func outputResult(p *print.Printer, outputFormat, resourcePoolLabel string, shar for _, share := range shares { var policy string - if share.ExportPolicy != nil { + if share.ExportPolicy.IsSet() && (share.ExportPolicy.Get().GetId() != "" || share.ExportPolicy.Get().GetName() != "") { if name, ok := share.ExportPolicy.Get().GetNameOk(); ok { - policy = name + policy = *name } else if id, ok := share.ExportPolicy.Get().GetIdOk(); ok { - policy = id + policy = *id } } table.AddRow( diff --git a/internal/cmd/beta/sfs/share/list/list_test.go b/internal/cmd/beta/sfs/share/list/list_test.go index 839fc2e6f..acf1d8b04 100644 --- a/internal/cmd/beta/sfs/share/list/list_test.go +++ b/internal/cmd/beta/sfs/share/list/list_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -22,7 +22,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiListSharesRequest)) sfs.ApiListSharesRequest { - request := testClient.ListShares(testCtx, testProjectId, testRegion, testResourcePoolId) + request := testClient.DefaultAPI.ListShares(testCtx, testProjectId, testRegion, testResourcePoolId) for _, mod := range mods { mod(&request) } @@ -154,7 +154,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/beta/sfs/share/update/update.go b/internal/cmd/beta/sfs/share/update/update.go index a13257c81..5e6112f4f 100644 --- a/internal/cmd/beta/sfs/share/update/update.go +++ b/internal/cmd/beta/sfs/share/update/update.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" - "github.com/stackitcloud/stackit-sdk-go/services/sfs/wait" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -34,7 +34,7 @@ type inputModel struct { ShareId string ResourcePoolId string ExportPolicyName *string - HardLimit *int64 + HardLimit *int32 } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -66,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - shareLabel, err := sfsUtils.GetShareName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) + shareLabel, err := sfsUtils.GetShareName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get share name: %v", err) shareLabel = model.ShareId @@ -74,7 +74,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { shareLabel = model.ShareId } - resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId) + resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get resource pool name: %v", err) resourcePoolLabel = model.ResourcePoolId @@ -98,7 +98,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating share", func() error { - _, err = wait.UpdateShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId).WaitWithContext(ctx) + _, err = wait.UpdateShareWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId).WaitWithContext(ctx) return err }) if err != nil { @@ -116,7 +116,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().Var(flags.UUIDFlag(), resourcePoolIdFlag, "The resource pool the share is assigned to") cmd.Flags().String(exportPolicyNameFlag, "", "The export policy the share is assigned to") - cmd.Flags().Int64(hardLimitFlag, 0, "The space hard limit for the share") + cmd.Flags().Int32(hardLimitFlag, 0, "The space hard limit for the share") err := flags.MarkFlagsRequired(cmd, resourcePoolIdFlag) cobra.CheckErr(err) @@ -129,7 +129,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return nil, &errors.ProjectIdError{} } - hardLimit := flags.FlagToInt64Pointer(p, cmd, hardLimitFlag) + hardLimit := flags.FlagToInt32Pointer(p, cmd, hardLimitFlag) if hardLimit != nil && *hardLimit < 0 { return nil, &errors.FlagValidationError{ Flag: hardLimitFlag, @@ -150,10 +150,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiUpdateShareRequest { - req := apiClient.UpdateShare(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) + req := apiClient.DefaultAPI.UpdateShare(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId) req = req.UpdateSharePayload(sfs.UpdateSharePayload{ - ExportPolicyName: sfs.NewNullableString(model.ExportPolicyName), - SpaceHardLimitGigabytes: model.HardLimit, + ExportPolicyName: *sfs.NewNullableString(model.ExportPolicyName), + SpaceHardLimitGigabytes: *sfs.NewNullableInt32(model.HardLimit), }) return req } diff --git a/internal/cmd/beta/sfs/share/update/update_test.go b/internal/cmd/beta/sfs/share/update/update_test.go index f130909c6..1184bdbd8 100644 --- a/internal/cmd/beta/sfs/share/update/update_test.go +++ b/internal/cmd/beta/sfs/share/update/update_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -22,14 +22,14 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" var testResourcePoolId = uuid.NewString() var testShareId = uuid.NewString() -var testHardLimit int64 = 10 +var testHardLimit int32 = 10 var testExportPolicy = "test-export-policy" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -38,7 +38,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st regionFlag: testRegion, resourcePoolIdFlag: testResourcePoolId, - hardLimitFlag: strconv.FormatInt(testHardLimit, 10), + hardLimitFlag: strconv.FormatInt(int64(testHardLimit), 10), exportPolicyNameFlag: testExportPolicy, } for _, mod := range mods { @@ -76,7 +76,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiUpdateShareRequest)) sfs.ApiUpdateShareRequest { - request := testClient.UpdateShare(testCtx, testProjectId, testRegion, testResourcePoolId, testShareId) + request := testClient.DefaultAPI.UpdateShare(testCtx, testProjectId, testRegion, testResourcePoolId, testShareId) request = request.UpdateSharePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -86,8 +86,8 @@ func fixtureRequest(mods ...func(request *sfs.ApiUpdateShareRequest)) sfs.ApiUpd func fixturePayload(mods ...func(payload *sfs.UpdateSharePayload)) sfs.UpdateSharePayload { payload := sfs.UpdateSharePayload{ - ExportPolicyName: sfs.NewNullableString(utils.Ptr(testExportPolicy)), - SpaceHardLimitGigabytes: utils.Ptr(testHardLimit), + ExportPolicyName: *sfs.NewNullableString(utils.Ptr(testExportPolicy)), + SpaceHardLimitGigabytes: *sfs.NewNullableInt32(utils.Ptr(testHardLimit)), } for _, mod := range mods { mod(&payload) @@ -210,7 +210,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest, sfs.NullableString{}), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}, sfs.NullableString{}, sfs.NullableInt32{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -248,7 +248,7 @@ func TestOutputResult(t *testing.T) { name: "set empty share", args: args{ item: &sfs.UpdateShareResponse{ - Share: &sfs.UpdateShareResponseShare{}, + Share: &sfs.Share{}, }, }, wantErr: false, diff --git a/internal/cmd/beta/sfs/snapshot/create/create.go b/internal/cmd/beta/sfs/snapshot/create/create.go index 5344ec33a..90efa3dd3 100644 --- a/internal/cmd/beta/sfs/snapshot/create/create.go +++ b/internal/cmd/beta/sfs/snapshot/create/create.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -61,7 +61,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId) + resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get resource pool name: %v", err) resourcePoolLabel = model.ResourcePoolId @@ -99,10 +99,10 @@ func configureFlags(cmd *cobra.Command) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiCreateResourcePoolSnapshotRequest { - req := apiClient.CreateResourcePoolSnapshot(ctx, model.ProjectId, model.Region, model.ResourcePoolId) + req := apiClient.DefaultAPI.CreateResourcePoolSnapshot(ctx, model.ProjectId, model.Region, model.ResourcePoolId) req = req.CreateResourcePoolSnapshotPayload(sfs.CreateResourcePoolSnapshotPayload{ Name: utils.Ptr(model.Name), - Comment: sfs.NewNullableString(model.Comment), + Comment: *sfs.NewNullableString(model.Comment), }) return req } diff --git a/internal/cmd/beta/sfs/snapshot/create/create_test.go b/internal/cmd/beta/sfs/snapshot/create/create_test.go index fae381a88..94abf5712 100644 --- a/internal/cmd/beta/sfs/snapshot/create/create_test.go +++ b/internal/cmd/beta/sfs/snapshot/create/create_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -21,7 +21,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -63,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiCreateResourcePoolSnapshotRequest)) sfs.ApiCreateResourcePoolSnapshotRequest { - request := testClient.CreateResourcePoolSnapshot(testCtx, testProjectId, testRegion, testResourcePoolId) + request := testClient.DefaultAPI.CreateResourcePoolSnapshot(testCtx, testProjectId, testRegion, testResourcePoolId) request = request.CreateResourcePoolSnapshotPayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -74,7 +74,7 @@ func fixtureRequest(mods ...func(request *sfs.ApiCreateResourcePoolSnapshotReque func fixturePayload(mods ...func(request *sfs.CreateResourcePoolSnapshotPayload)) sfs.CreateResourcePoolSnapshotPayload { payload := sfs.CreateResourcePoolSnapshotPayload{ Name: utils.Ptr(testName), - Comment: sfs.NewNullableString( + Comment: *sfs.NewNullableString( utils.Ptr(testComment), ), } @@ -161,9 +161,9 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), - cmp.AllowUnexported(sfs.NullableString{}), + cmp.AllowUnexported(sfs.NullableString{}, sfs.NullableInt32{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -200,7 +200,7 @@ func TestOutputResult(t *testing.T) { name: "set empty snapshot", args: args{ resp: &sfs.CreateResourcePoolSnapshotResponse{ - ResourcePoolSnapshot: &sfs.CreateResourcePoolSnapshotResponseResourcePoolSnapshot{}, + ResourcePoolSnapshot: &sfs.ResourcePoolSnapshot{}, }, }, wantErr: false, diff --git a/internal/cmd/beta/sfs/snapshot/delete/delete.go b/internal/cmd/beta/sfs/snapshot/delete/delete.go index fcc74be46..7fd570bd6 100644 --- a/internal/cmd/beta/sfs/snapshot/delete/delete.go +++ b/internal/cmd/beta/sfs/snapshot/delete/delete.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId) + resourcePoolLabel, err := sfsUtils.GetResourcePoolName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ResourcePoolId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get resource pool name: %v", err) resourcePoolLabel = model.ResourcePoolId @@ -91,7 +91,7 @@ func configureFlags(cmd *cobra.Command) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiDeleteResourcePoolSnapshotRequest { - return apiClient.DeleteResourcePoolSnapshot(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.SnapshotName) + return apiClient.DefaultAPI.DeleteResourcePoolSnapshot(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.SnapshotName) } func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { diff --git a/internal/cmd/beta/sfs/snapshot/delete/delete_test.go b/internal/cmd/beta/sfs/snapshot/delete/delete_test.go index db010e22a..ebc37fc03 100644 --- a/internal/cmd/beta/sfs/snapshot/delete/delete_test.go +++ b/internal/cmd/beta/sfs/snapshot/delete/delete_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -19,7 +19,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -67,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiDeleteResourcePoolSnapshotRequest)) sfs.ApiDeleteResourcePoolSnapshotRequest { - request := testClient.DeleteResourcePoolSnapshot(testCtx, testProjectId, testRegion, testResourcePoolId, testSnapshotName) + request := testClient.DefaultAPI.DeleteResourcePoolSnapshot(testCtx, testProjectId, testRegion, testResourcePoolId, testSnapshotName) for _, mod := range mods { mod(&request) } @@ -178,7 +178,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/beta/sfs/snapshot/describe/describe.go b/internal/cmd/beta/sfs/snapshot/describe/describe.go index 123e60172..1d5b01a1c 100644 --- a/internal/cmd/beta/sfs/snapshot/describe/describe.go +++ b/internal/cmd/beta/sfs/snapshot/describe/describe.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -78,7 +78,7 @@ func configureFlags(cmd *cobra.Command) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiGetResourcePoolSnapshotRequest { - return apiClient.GetResourcePoolSnapshot(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.SnapshotName) + return apiClient.DefaultAPI.GetResourcePoolSnapshot(ctx, model.ProjectId, model.Region, model.ResourcePoolId, model.SnapshotName) } func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { @@ -111,7 +111,7 @@ func outputResult(p *print.Printer, outputFormat string, resp *sfs.GetResourcePo snap := *resp.ResourcePoolSnapshot table.AddRow("NAME", utils.PtrString(snap.SnapshotName)) table.AddSeparator() - if snap.Comment != nil { + if snap.Comment.IsSet() && snap.Comment.Get() != nil { table.AddRow("COMMENT", utils.PtrString(snap.Comment.Get())) table.AddSeparator() } diff --git a/internal/cmd/beta/sfs/snapshot/describe/describe_test.go b/internal/cmd/beta/sfs/snapshot/describe/describe_test.go index e077aa0d2..91a4ee5a4 100644 --- a/internal/cmd/beta/sfs/snapshot/describe/describe_test.go +++ b/internal/cmd/beta/sfs/snapshot/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -68,7 +68,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiGetResourcePoolSnapshotRequest)) sfs.ApiGetResourcePoolSnapshotRequest { - request := testClient.GetResourcePoolSnapshot(testCtx, testProjectId, testRegion, testResourcePoolId, testSnapshotName) + request := testClient.DefaultAPI.GetResourcePoolSnapshot(testCtx, testProjectId, testRegion, testResourcePoolId, testSnapshotName) for _, mod := range mods { mod(&request) } @@ -179,7 +179,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -215,7 +215,7 @@ func TestOutputResult(t *testing.T) { name: " set empty snapshot", args: args{ resp: &sfs.GetResourcePoolSnapshotResponse{ - ResourcePoolSnapshot: &sfs.GetResourcePoolSnapshotResponseResourcePoolSnapshot{}, + ResourcePoolSnapshot: &sfs.ResourcePoolSnapshot{}, }, }, wantErr: false, diff --git a/internal/cmd/beta/sfs/snapshot/list/list.go b/internal/cmd/beta/sfs/snapshot/list/list.go index cfc0347b8..5f0b55364 100644 --- a/internal/cmd/beta/sfs/snapshot/list/list.go +++ b/internal/cmd/beta/sfs/snapshot/list/list.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Truncate output - items := utils.GetSliceFromPointer(resp.ResourcePoolSnapshots) + items := utils.GetSliceFromPointer(&resp.ResourcePoolSnapshots) if model.Limit != nil && len(items) > int(*model.Limit) { items = items[:*model.Limit] } @@ -84,7 +84,7 @@ func configureFlags(cmd *cobra.Command) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *sfs.APIClient) sfs.ApiListResourcePoolSnapshotsRequest { - req := apiClient.ListResourcePoolSnapshots(ctx, model.ProjectId, model.Region, model.ResourcePoolId) + req := apiClient.DefaultAPI.ListResourcePoolSnapshots(ctx, model.ProjectId, model.Region, model.ResourcePoolId) return req } @@ -130,7 +130,7 @@ func outputResult(p *print.Printer, outputFormat string, resp []sfs.ResourcePool for _, snap := range resp { var comment string - if snap.Comment != nil { + if snap.Comment.IsSet() && snap.Comment.Get() != nil { comment = utils.PtrString(snap.Comment.Get()) } table.AddRow( diff --git a/internal/cmd/beta/sfs/snapshot/list/list_test.go b/internal/cmd/beta/sfs/snapshot/list/list_test.go index 86312ac23..98d3abbf8 100644 --- a/internal/cmd/beta/sfs/snapshot/list/list_test.go +++ b/internal/cmd/beta/sfs/snapshot/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ var regionFlag = globalflags.RegionFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &sfs.APIClient{} +var testClient = &sfs.APIClient{DefaultAPI: &sfs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *sfs.ApiListResourcePoolSnapshotsRequest)) sfs.ApiListResourcePoolSnapshotsRequest { - request := testClient.ListResourcePoolSnapshots(testCtx, testProjectId, testRegion, testResourcePoolId) + request := testClient.DefaultAPI.ListResourcePoolSnapshots(testCtx, testProjectId, testRegion, testResourcePoolId) for _, mod := range mods { mod(&request) } @@ -121,7 +121,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, sfs.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/pkg/services/sfs/client/client.go b/internal/pkg/services/sfs/client/client.go index 0e9057501..0a5448d54 100644 --- a/internal/pkg/services/sfs/client/client.go +++ b/internal/pkg/services/sfs/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/config" genericclient "github.com/stackitcloud/stackit-cli/internal/pkg/generic-client" diff --git a/internal/pkg/services/sfs/utils/utils.go b/internal/pkg/services/sfs/utils/utils.go index 2507a512e..c78e0d7e3 100644 --- a/internal/pkg/services/sfs/utils/utils.go +++ b/internal/pkg/services/sfs/utils/utils.go @@ -4,17 +4,11 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" ) -type SfsClient interface { - GetShareExportPolicyExecute(ctx context.Context, projectId string, region string, policyId string) (*sfs.GetShareExportPolicyResponse, error) - GetShareExecute(ctx context.Context, projectId, region, resourcePoolId, shareId string) (*sfs.GetShareResponse, error) - GetResourcePoolExecute(ctx context.Context, projectId, region, resourcePoolId string) (*sfs.GetResourcePoolResponse, error) -} - -func GetShareName(ctx context.Context, client SfsClient, projectId, region, resourcePoolId, shareId string) (string, error) { - resp, err := client.GetShareExecute(ctx, projectId, region, resourcePoolId, shareId) +func GetShareName(ctx context.Context, client sfs.DefaultAPI, projectId, region, resourcePoolId, shareId string) (string, error) { + resp, err := client.GetShare(ctx, projectId, region, resourcePoolId, shareId).Execute() if err != nil { return "", fmt.Errorf("get share: %w", err) } @@ -24,8 +18,8 @@ func GetShareName(ctx context.Context, client SfsClient, projectId, region, reso return "", nil } -func GetExportPolicyName(ctx context.Context, apiClient SfsClient, projectId, region, policyId string) (string, error) { - resp, err := apiClient.GetShareExportPolicyExecute(ctx, projectId, region, policyId) +func GetExportPolicyName(ctx context.Context, apiClient sfs.DefaultAPI, projectId, region, policyId string) (string, error) { + resp, err := apiClient.GetShareExportPolicy(ctx, projectId, region, policyId).Execute() if err != nil { return "", fmt.Errorf("get share export policy: %w", err) } @@ -35,8 +29,8 @@ func GetExportPolicyName(ctx context.Context, apiClient SfsClient, projectId, re return "", nil } -func GetResourcePoolName(ctx context.Context, client SfsClient, projectId, region, resourcePoolId string) (string, error) { - resp, err := client.GetResourcePoolExecute(ctx, projectId, region, resourcePoolId) +func GetResourcePoolName(ctx context.Context, client sfs.DefaultAPI, projectId, region, resourcePoolId string) (string, error) { + resp, err := client.GetResourcePool(ctx, projectId, region, resourcePoolId).Execute() if err != nil { return "", fmt.Errorf("get resource pool: %w", err) } diff --git a/internal/pkg/services/sfs/utils/utils_test.go b/internal/pkg/services/sfs/utils/utils_test.go index 0f7ef08bb..5c4b6d1f4 100644 --- a/internal/pkg/services/sfs/utils/utils_test.go +++ b/internal/pkg/services/sfs/utils/utils_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/sfs" + sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) @@ -15,7 +15,6 @@ const ( testShareName = "share-name" testResourcePoolName = "resource-pool-name" testExportPolicyName = "export-policy-name" - testSnapshotName = "snapshot-name" testRegion = "eu01" ) @@ -24,34 +23,41 @@ var ( testProjectId = uuid.NewString() ) -type sfsClientMocked struct { - getShareFails bool - getShareResp *sfs.GetShareResponse +type mockSettings struct { + getShareFails bool + getShareResp *sfs.GetShareResponse + getResourcePoolFails bool getResourcePoolResp *sfs.GetResourcePoolResponse + getExportPolicyFails bool getExportPolicyResp *sfs.GetShareExportPolicyResponse } -func (s *sfsClientMocked) GetShareExecute(_ context.Context, _, _, _, _ string) (*sfs.GetShareResponse, error) { - if s.getShareFails { - return nil, fmt.Errorf("could not get share") - } - return s.getShareResp, nil -} +func newAPIMock(settings *mockSettings) sfs.DefaultAPI { + return &sfs.DefaultAPIServiceMock{ + GetShareExecuteMock: utils.Ptr(func(_ sfs.ApiGetShareRequest) (*sfs.GetShareResponse, error) { + if settings.getShareFails { + return nil, fmt.Errorf("could not get share details") + } -func (s *sfsClientMocked) GetResourcePoolExecute(_ context.Context, _, _, _ string) (*sfs.GetResourcePoolResponse, error) { - if s.getResourcePoolFails { - return nil, fmt.Errorf("could not get resource pool") - } - return s.getResourcePoolResp, nil -} + return settings.getShareResp, nil + }), + GetShareExportPolicyExecuteMock: utils.Ptr(func(_ sfs.ApiGetShareExportPolicyRequest) (*sfs.GetShareExportPolicyResponse, error) { + if settings.getExportPolicyFails { + return nil, fmt.Errorf("could not get export policy details") + } + + return settings.getExportPolicyResp, nil + }), + GetResourcePoolExecuteMock: utils.Ptr(func(_ sfs.ApiGetResourcePoolRequest) (*sfs.GetResourcePoolResponse, error) { + if settings.getResourcePoolFails { + return nil, fmt.Errorf("could not get resource pool details") + } -func (s *sfsClientMocked) GetShareExportPolicyExecute(_ context.Context, _, _, _ string) (*sfs.GetShareExportPolicyResponse, error) { - if s.getExportPolicyFails { - return nil, fmt.Errorf("could not get export policy") + return settings.getResourcePoolResp, nil + }), } - return s.getExportPolicyResp, nil } func TestGetExportPolicyName(t *testing.T) { @@ -65,7 +71,7 @@ func TestGetExportPolicyName(t *testing.T) { { description: "base", getExportPolicyResp: &sfs.GetShareExportPolicyResponse{ - ShareExportPolicy: &sfs.GetShareExportPolicyResponseShareExportPolicy{ + ShareExportPolicy: &sfs.ShareExportPolicy{ Name: utils.Ptr(testExportPolicyName), }, }, @@ -81,10 +87,10 @@ func TestGetExportPolicyName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &sfsClientMocked{ + client := newAPIMock(&mockSettings{ getExportPolicyFails: tt.getExportPolicyFails, getExportPolicyResp: tt.getExportPolicyResp, - } + }) output, err := GetExportPolicyName(context.Background(), client, testProjectId, testRegion, testPolicyId) @@ -115,7 +121,7 @@ func TestGetShareName(t *testing.T) { { description: "base", getShareResp: &sfs.GetShareResponse{ - Share: &sfs.GetShareResponseShare{ + Share: &sfs.Share{ Name: utils.Ptr(testShareName), }, }, @@ -132,10 +138,10 @@ func TestGetShareName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &sfsClientMocked{ + client := newAPIMock(&mockSettings{ getShareFails: tt.getShareFails, getShareResp: tt.getShareResp, - } + }) output, err := GetShareName(context.Background(), client, testProjectId, testRegion, "", "") @@ -166,7 +172,7 @@ func TestGetResourcePoolName(t *testing.T) { { description: "base", getResourcePoolResp: &sfs.GetResourcePoolResponse{ - ResourcePool: &sfs.GetResourcePoolResponseResourcePool{ + ResourcePool: &sfs.ResourcePool{ Name: utils.Ptr(testResourcePoolName), }, }, @@ -183,10 +189,10 @@ func TestGetResourcePoolName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &sfsClientMocked{ + client := newAPIMock(&mockSettings{ getResourcePoolResp: tt.getResourcePoolResp, getResourcePoolFails: tt.getResourcePoolFails, - } + }) output, err := GetResourcePoolName(context.Background(), client, testProjectId, testRegion, "")