diff --git a/docs/stackit_beta_intake_runner_create.md b/docs/stackit_beta_intake_runner_create.md index 8903cef9d..c38cce74c 100644 --- a/docs/stackit_beta_intake_runner_create.md +++ b/docs/stackit_beta_intake_runner_create.md @@ -23,12 +23,12 @@ stackit beta intake runner create [flags] ### Options ``` - --description string Description - --display-name string Display name - -h, --help Help for "stackit beta intake runner create" - --labels stringToString Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2" (default []) - --max-message-size-kib int Maximum message size in KiB - --max-messages-per-hour int Maximum number of messages per hour + --description string Description + --display-name string Display name + -h, --help Help for "stackit beta intake runner create" + --labels stringToString Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2" (default []) + --max-message-size-kib int32 Maximum message size in KiB + --max-messages-per-hour int32 Maximum number of messages per hour ``` ### Options inherited from parent commands diff --git a/docs/stackit_beta_intake_runner_update.md b/docs/stackit_beta_intake_runner_update.md index d02cb7c84..007a1aaf8 100644 --- a/docs/stackit_beta_intake_runner_update.md +++ b/docs/stackit_beta_intake_runner_update.md @@ -23,12 +23,12 @@ stackit beta intake runner update RUNNER_ID [flags] ### Options ``` - --description string Description - --display-name string Display name - -h, --help Help for "stackit beta intake runner update" - --labels stringToString Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2". (default []) - --max-message-size-kib int Maximum message size in KiB. Note: Overall message capacity cannot be decreased. - --max-messages-per-hour int Maximum number of messages per hour. Note: Overall message capacity cannot be decreased. + --description string Description + --display-name string Display name + -h, --help Help for "stackit beta intake runner update" + --labels stringToString Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2". (default []) + --max-message-size-kib int32 Maximum message size in KiB. Note: Overall message capacity cannot be decreased. + --max-messages-per-hour int32 Maximum number of messages per hour. Note: Overall message capacity cannot be decreased. ``` ### Options inherited from parent commands diff --git a/go.mod b/go.mod index 3c1c07cf6..e951c3dca 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3 github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3 github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5 - github.com/stackitcloud/stackit-sdk-go/services/intake v0.4.4 + github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8 github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 diff --git a/go.sum b/go.sum index 23665a67e..8f141a92a 100644 --- a/go.sum +++ b/go.sum @@ -612,8 +612,8 @@ github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3 h1:VIjkSofZz9utOOkBd github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3/go.mod h1:EJk1Ss9GTel2NPIu/w3+x9XcQcEd2k3ibea5aQDzVhQ= github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5 h1:W57+XRa8wTLsi5CV9Tqa7mGgt/PvlRM//RurXSmvII8= github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5/go.mod h1:lTWjW57eAq1bwfM6nsNinhoBr3MHFW/GaFasdAsYfDM= -github.com/stackitcloud/stackit-sdk-go/services/intake v0.4.4 h1:cbXM7jUBCL7A5zxJKFWolRIDl45sdJMMMAzeumeIEOA= -github.com/stackitcloud/stackit-sdk-go/services/intake v0.4.4/go.mod h1:z+7KKZf0uHXU/Kb4CRs/oaBrXRJ01LpiD0OH11MXLOk= +github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 h1:7ZSrwps/zI41rl+xYkG4osld8cyAwssyl/UZ/Iu/F2g= +github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1/go.mod h1:ZIvwBZwEMFO+YfJLCNXqabslI0Fp9zxV7ZBwlZjk7uE= github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2 h1:2ulSL2IkIAKND59eAjbEhVkOoBMyvm48ojwz1a3t0U0= github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2/go.mod h1:cuIaMMiHeHQsbvy7BOFMutoV3QtN+ZBx7Tg3GmYUw7s= github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0 h1:DxrN85V738CRLynu6MULQHO+OXyYnkhVPgoZKULfFIs= diff --git a/internal/cmd/beta/intake/create/create.go b/internal/cmd/beta/intake/create/create.go index 00d54349e..9cb6c1fb7 100644 --- a/internal/cmd/beta/intake/create/create.go +++ b/internal/cmd/beta/intake/create/create.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -113,7 +113,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Creating STACKIT Intake instance", func() error { - _, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx) + _, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx) return err }) if err != nil { @@ -185,19 +185,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiCreateIntakeRequest { - req := apiClient.CreateIntake(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.CreateIntake(ctx, model.ProjectId, model.Region) // Build catalog authentication var catalogAuth *intake.CatalogAuth if model.CatalogAuthType != nil { authType := intake.CatalogAuthType(*model.CatalogAuthType) catalogAuth = &intake.CatalogAuth{ - Type: &authType, + Type: authType, } if *model.CatalogAuthType == "dremio" { catalogAuth.Dremio = &intake.DremioAuth{ - TokenEndpoint: model.DremioTokenEndpoint, - PersonalAccessToken: model.DremioToken, + TokenEndpoint: utils.PtrString(model.DremioTokenEndpoint), + PersonalAccessToken: utils.PtrString(model.DremioToken), } } } @@ -209,22 +209,22 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIC // Build catalog catalogPayload := intake.IntakeCatalog{ - Uri: model.CatalogURI, - Warehouse: model.CatalogWarehouse, + Uri: utils.PtrString(model.CatalogURI), + Warehouse: utils.PtrString(model.CatalogWarehouse), Namespace: model.CatalogNamespace, TableName: model.CatalogTableName, Partitioning: partitioning, - PartitionBy: model.CatalogPartitionBy, + PartitionBy: utils.PtrValue(model.CatalogPartitionBy), Auth: catalogAuth, } // Build main payload payload := intake.CreateIntakePayload{ - DisplayName: model.DisplayName, - IntakeRunnerId: model.RunnerId, + DisplayName: utils.PtrString(model.DisplayName), + IntakeRunnerId: utils.PtrString(model.RunnerId), Description: model.Description, - Labels: model.Labels, - Catalog: &catalogPayload, + Labels: utils.PtrValue(model.Labels), + Catalog: catalogPayload, } req = req.CreateIntakePayload(payload) @@ -242,7 +242,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s Intake for project %q. Intake ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id)) + p.Outputf("%s Intake for project %q. Intake ID: %s\n", operationState, projectLabel, resp.Id) return nil }) } diff --git a/internal/cmd/beta/intake/create/create_test.go b/internal/cmd/beta/intake/create/create_test.go index 9c6c37213..6822649cd 100644 --- a/internal/cmd/beta/intake/create/create_test.go +++ b/internal/cmd/beta/intake/create/create_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -41,7 +41,9 @@ var ( // testCtx dummy context for testing purposes testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") // testClient mock API client - testClient = &intake.APIClient{} + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testRunnerId = uuid.NewString() @@ -107,22 +109,22 @@ func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakePayload)) int authType := intake.CatalogAuthType(testCatalogAuthType) testPartitioningType := intake.PartitioningType(testCatalogPartitioning) payload := intake.CreateIntakePayload{ - DisplayName: utils.Ptr(testDisplayName), - IntakeRunnerId: utils.Ptr(testRunnerId), + DisplayName: testDisplayName, + IntakeRunnerId: testRunnerId, Description: utils.Ptr(testDescription), - Labels: utils.Ptr(testLabels), - Catalog: &intake.IntakeCatalog{ - Uri: utils.Ptr(testCatalogURI), - Warehouse: utils.Ptr(testCatalogWarehouse), + Labels: testLabels, + Catalog: intake.IntakeCatalog{ + Uri: testCatalogURI, + Warehouse: testCatalogWarehouse, Namespace: utils.Ptr(testCatalogNamespace), TableName: utils.Ptr(testCatalogTableName), Partitioning: &testPartitioningType, - PartitionBy: utils.Ptr(testCatalogPartitionBy), + PartitionBy: testCatalogPartitionBy, Auth: &intake.CatalogAuth{ - Type: &authType, + Type: authType, Dremio: &intake.DremioAuth{ - TokenEndpoint: utils.Ptr(testDremioTokenEndpoint), - PersonalAccessToken: utils.Ptr(testDremioToken), + TokenEndpoint: testDremioTokenEndpoint, + PersonalAccessToken: testDremioToken, }, }, }, @@ -135,7 +137,7 @@ func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakePayload)) int // fixtureRequest generates an API request for tests func fixtureRequest(mods ...func(request *intake.ApiCreateIntakeRequest)) intake.ApiCreateIntakeRequest { - request := testClient.CreateIntake(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateIntake(testCtx, testProjectId, testRegion) request = request.CreateIntakePayload(fixtureCreatePayload()) for _, mod := range mods { mod(&request) @@ -248,7 +250,7 @@ func TestBuildRequest(t *testing.T) { model.DremioToken = nil }), expectedRequest: fixtureRequest(func(request *intake.ApiCreateIntakeRequest) { - *request = (*request).CreateIntakePayload(fixtureCreatePayload(func(payload *intake.CreateIntakePayload) { + *request = request.CreateIntakePayload(fixtureCreatePayload(func(payload *intake.CreateIntakePayload) { payload.Description = nil payload.Labels = nil payload.Catalog.Namespace = nil @@ -267,9 +269,9 @@ func TestBuildRequest(t *testing.T) { model.DremioToken = nil }), expectedRequest: fixtureRequest(func(request *intake.ApiCreateIntakeRequest) { - *request = (*request).CreateIntakePayload(fixtureCreatePayload(func(payload *intake.CreateIntakePayload) { + *request = request.CreateIntakePayload(fixtureCreatePayload(func(payload *intake.CreateIntakePayload) { authType := intake.CatalogAuthType("none") - payload.Catalog.Auth.Type = &authType + payload.Catalog.Auth.Type = authType payload.Catalog.Auth.Dremio = nil })) }), @@ -282,6 +284,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -306,7 +309,7 @@ func TestOutputResult(t *testing.T) { args: args{ model: fixtureInputModel(), projectLabel: "my-project", - resp: &intake.IntakeResponse{Id: utils.Ptr("intake-id-123")}, + resp: &intake.IntakeResponse{Id: "intake-id-123"}, }, wantErr: false, }, @@ -317,7 +320,7 @@ func TestOutputResult(t *testing.T) { model.Async = true }), projectLabel: "my-project", - resp: &intake.IntakeResponse{Id: utils.Ptr("intake-id-123")}, + resp: &intake.IntakeResponse{Id: "intake-id-123"}, }, wantErr: false, }, @@ -327,7 +330,7 @@ func TestOutputResult(t *testing.T) { model: fixtureInputModel(func(model *inputModel) { model.OutputFormat = print.JSONOutputFormat }), - resp: &intake.IntakeResponse{Id: utils.Ptr("intake-id-123")}, + resp: &intake.IntakeResponse{Id: "intake-id-123"}, }, wantErr: false, }, diff --git a/internal/cmd/beta/intake/delete/delete.go b/internal/cmd/beta/intake/delete/delete.go index f49118dfe..e831e2493 100644 --- a/internal/cmd/beta/intake/delete/delete.go +++ b/internal/cmd/beta/intake/delete/delete.go @@ -5,9 +5,9 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -70,7 +70,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Deleting STACKIT Intake instance", func() error { - _, err = wait.DeleteIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx) + _, err = wait.DeleteIntakeWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx) return err }) if err != nil { @@ -110,6 +110,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu // buildRequest creates the API request to delete an Intake func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiDeleteIntakeRequest { - req := apiClient.DeleteIntake(ctx, model.ProjectId, model.Region, model.IntakeId) + req := apiClient.DefaultAPI.DeleteIntake(ctx, model.ProjectId, model.Region, model.IntakeId) return req } diff --git a/internal/cmd/beta/intake/delete/delete_test.go b/internal/cmd/beta/intake/delete/delete_test.go index ce673fabc..31e631fd3 100644 --- a/internal/cmd/beta/intake/delete/delete_test.go +++ b/internal/cmd/beta/intake/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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -24,7 +24,9 @@ var ( // testCtx is a dummy context for testing purposes testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") // testClient is a mock API client - testClient = &intake.APIClient{} + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testIntakeId = uuid.NewString() ) @@ -70,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // fixtureRequest generates an API request for tests func fixtureRequest(mods ...func(request *intake.ApiDeleteIntakeRequest)) intake.ApiDeleteIntakeRequest { - request := testClient.DeleteIntake(testCtx, testProjectId, testRegion, testIntakeId) + request := testClient.DefaultAPI.DeleteIntake(testCtx, testProjectId, testRegion, testIntakeId) for _, mod := range mods { mod(&request) } @@ -147,6 +149,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/intake/describe/describe.go b/internal/cmd/beta/intake/describe/describe.go index 7c0926591..91dbc0771 100644 --- a/internal/cmd/beta/intake/describe/describe.go +++ b/internal/cmd/beta/intake/describe/describe.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -86,7 +86,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiGetIntakeRequest { - req := apiClient.GetIntake(ctx, model.ProjectId, model.Region, model.IntakeId) + req := apiClient.DefaultAPI.GetIntake(ctx, model.ProjectId, model.Region, model.IntakeId) return req } @@ -131,8 +131,8 @@ func outputResult(p *print.Printer, outputFormat string, intk *intake.IntakeResp table.AddRow("Catalog Table Name", tableName) } table.AddRow("Catalog Partitioning", catalog.GetPartitioning()) - if partitionBy := catalog.GetPartitionBy(); partitionBy != nil && len(*partitionBy) > 0 { - table.AddRow("Catalog Partition By", strings.Join(*partitionBy, ", ")) + if partitionBy := catalog.GetPartitionBy(); len(partitionBy) > 0 { + table.AddRow("Catalog Partition By", strings.Join(partitionBy, ", ")) } err := table.Display(p) diff --git a/internal/cmd/beta/intake/describe/describe_test.go b/internal/cmd/beta/intake/describe/describe_test.go index c2961c5b4..d7032acd2 100644 --- a/internal/cmd/beta/intake/describe/describe_test.go +++ b/internal/cmd/beta/intake/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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -22,8 +22,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testIntakeId = uuid.NewString() ) @@ -65,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *intake.ApiGetIntakeRequest)) intake.ApiGetIntakeRequest { - request := testClient.GetIntake(testCtx, testProjectId, testRegion, testIntakeId) + request := testClient.DefaultAPI.GetIntake(testCtx, testProjectId, testRegion, testIntakeId) for _, mod := range mods { mod(&request) } @@ -142,6 +144,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -162,17 +165,17 @@ func TestOutputResult(t *testing.T) { }{ { name: "default output", - args: args{outputFormat: "default", intakeResp: &intake.IntakeResponse{Catalog: &intake.IntakeCatalog{}}}, + args: args{outputFormat: "default", intakeResp: &intake.IntakeResponse{Catalog: intake.IntakeCatalog{}}}, wantErr: false, }, { name: "json output", - args: args{outputFormat: print.JSONOutputFormat, intakeResp: &intake.IntakeResponse{Catalog: &intake.IntakeCatalog{}}}, + args: args{outputFormat: print.JSONOutputFormat, intakeResp: &intake.IntakeResponse{Catalog: intake.IntakeCatalog{}}}, wantErr: false, }, { name: "yaml output", - args: args{outputFormat: print.YAMLOutputFormat, intakeResp: &intake.IntakeResponse{Catalog: &intake.IntakeCatalog{}}}, + args: args{outputFormat: print.YAMLOutputFormat, intakeResp: &intake.IntakeResponse{Catalog: intake.IntakeCatalog{}}}, wantErr: false, }, { diff --git a/internal/cmd/beta/intake/list/list.go b/internal/cmd/beta/intake/list/list.go index 2f19c91f7..7fa509260 100644 --- a/internal/cmd/beta/intake/list/list.go +++ b/internal/cmd/beta/intake/list/list.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -119,7 +119,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { // buildRequest creates the API request to list Intakes func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiListIntakesRequest { - req := apiClient.ListIntakes(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.ListIntakes(ctx, model.ProjectId, model.Region) return req } diff --git a/internal/cmd/beta/intake/list/list_test.go b/internal/cmd/beta/intake/list/list_test.go index 15b5e714a..caec7db89 100644 --- a/internal/cmd/beta/intake/list/list_test.go +++ b/internal/cmd/beta/intake/list/list_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -25,8 +25,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testLimit = int64(5) ) @@ -57,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *intake.ApiListIntakesRequest)) intake.ApiListIntakesRequest { - request := testClient.ListIntakes(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListIntakes(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -139,6 +141,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/intake/runner/create/create.go b/internal/cmd/beta/intake/runner/create/create.go index b64a116f9..c811ec896 100644 --- a/internal/cmd/beta/intake/runner/create/create.go +++ b/internal/cmd/beta/intake/runner/create/create.go @@ -7,8 +7,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -34,8 +34,8 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel DisplayName *string - MaxMessageSizeKiB *int64 - MaxMessagesPerHour *int64 + MaxMessageSizeKiB *int32 + MaxMessagesPerHour *int32 Description *string Labels *map[string]string } @@ -89,7 +89,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Creating STACKIT Intake Runner", func() error { - _, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx) + _, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx) return err }) if err != nil { @@ -106,8 +106,8 @@ func NewCmd(p *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().String(displayNameFlag, "", "Display name") - cmd.Flags().Int64(maxMessageSizeKiBFlag, 0, "Maximum message size in KiB") - cmd.Flags().Int64(maxMessagesPerHourFlag, 0, "Maximum number of messages per hour") + cmd.Flags().Int32(maxMessageSizeKiBFlag, 0, "Maximum message size in KiB") + cmd.Flags().Int32(maxMessagesPerHourFlag, 0, "Maximum number of messages per hour") cmd.Flags().String(descriptionFlag, "", "Description") cmd.Flags().StringToString(labelFlag, nil, "Labels in key=value format, separated by commas. Example: --labels \"key1=value1,key2=value2\"") @@ -124,8 +124,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { model := inputModel{ GlobalFlagModel: globalFlags, DisplayName: flags.FlagToStringPointer(p, cmd, displayNameFlag), - MaxMessageSizeKiB: flags.FlagToInt64Pointer(p, cmd, maxMessageSizeKiBFlag), - MaxMessagesPerHour: flags.FlagToInt64Pointer(p, cmd, maxMessagesPerHourFlag), + MaxMessageSizeKiB: flags.FlagToInt32Pointer(p, cmd, maxMessageSizeKiBFlag), + MaxMessagesPerHour: flags.FlagToInt32Pointer(p, cmd, maxMessagesPerHourFlag), Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), Labels: flags.FlagToStringToStringPointer(p, cmd, labelFlag), } @@ -136,15 +136,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiCreateIntakeRunnerRequest { // Start building the request by calling the base method with path parameters - req := apiClient.CreateIntakeRunner(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.CreateIntakeRunner(ctx, model.ProjectId, model.Region) // Create the payload struct with data from the input model payload := intake.CreateIntakeRunnerPayload{ - DisplayName: model.DisplayName, - MaxMessageSizeKiB: model.MaxMessageSizeKiB, - MaxMessagesPerHour: model.MaxMessagesPerHour, + DisplayName: utils.PtrString(model.DisplayName), + MaxMessageSizeKiB: utils.PtrValue(model.MaxMessageSizeKiB), + MaxMessagesPerHour: utils.PtrValue(model.MaxMessagesPerHour), Description: model.Description, - Labels: model.Labels, + Labels: utils.PtrValue(model.Labels), } // Attach the payload to the request builder req = req.CreateIntakeRunnerPayload(payload) @@ -163,7 +163,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s Intake Runner for project %q. Runner ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id)) + p.Outputf("%s Intake Runner for project %q. Runner ID: %s\n", operationState, projectLabel, resp.Id) return nil }) } diff --git a/internal/cmd/beta/intake/runner/create/create_test.go b/internal/cmd/beta/intake/runner/create/create_test.go index 852e7339b..2ab2a6dda 100644 --- a/internal/cmd/beta/intake/runner/create/create_test.go +++ b/internal/cmd/beta/intake/runner/create/create_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -24,8 +24,8 @@ type testCtxKey struct{} const ( testRegion = "eu01" testDisplayName = "testrunner" - testMaxMessageSizeKiB = int64(1024) - testMaxMessagesPerHour = int64(10000) + testMaxMessageSizeKiB = int32(1024) + testMaxMessagesPerHour = int32(10000) testDescription = "This is a test runner" testLabelsString = "env=test,team=dev" ) @@ -34,7 +34,9 @@ var ( // testCtx dummy context for testing purposes testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") // testClient mock API client - testClient = &intake.APIClient{} + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testLabels = map[string]string{"env": "test", "team": "dev"} @@ -80,11 +82,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // fixtureCreatePayload generates a CreateIntakeRunnerPayload for tests func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakeRunnerPayload)) intake.CreateIntakeRunnerPayload { payload := intake.CreateIntakeRunnerPayload{ - DisplayName: utils.Ptr(testDisplayName), - MaxMessageSizeKiB: utils.Ptr(testMaxMessageSizeKiB), - MaxMessagesPerHour: utils.Ptr(testMaxMessagesPerHour), + DisplayName: testDisplayName, + MaxMessageSizeKiB: testMaxMessageSizeKiB, + MaxMessagesPerHour: testMaxMessagesPerHour, Description: utils.Ptr(testDescription), - Labels: utils.Ptr(testLabels), + Labels: testLabels, } for _, mod := range mods { mod(&payload) @@ -94,7 +96,7 @@ func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakeRunnerPayload // fixtureRequest generates an API request for tests func fixtureRequest(mods ...func(request *intake.ApiCreateIntakeRunnerRequest)) intake.ApiCreateIntakeRunnerRequest { - request := testClient.CreateIntakeRunner(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateIntakeRunner(testCtx, testProjectId, testRegion) request = request.CreateIntakeRunnerPayload(fixtureCreatePayload()) for _, mod := range mods { mod(&request) @@ -201,7 +203,7 @@ func TestBuildRequest(t *testing.T) { model.Labels = nil }), expectedRequest: fixtureRequest(func(request *intake.ApiCreateIntakeRunnerRequest) { - *request = (*request).CreateIntakeRunnerPayload(fixtureCreatePayload(func(payload *intake.CreateIntakeRunnerPayload) { + *request = request.CreateIntakeRunnerPayload(fixtureCreatePayload(func(payload *intake.CreateIntakeRunnerPayload) { payload.Description = nil payload.Labels = nil })) @@ -215,6 +217,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -239,7 +242,7 @@ func TestOutputResult(t *testing.T) { args: args{ model: fixtureInputModel(), projectLabel: "my-project", - resp: &intake.IntakeRunnerResponse{Id: utils.Ptr("runner-id-123")}, + resp: &intake.IntakeRunnerResponse{Id: "runner-id-123"}, }, wantErr: false, }, @@ -250,7 +253,7 @@ func TestOutputResult(t *testing.T) { model.Async = true }), projectLabel: "my-project", - resp: &intake.IntakeRunnerResponse{Id: utils.Ptr("runner-id-123")}, + resp: &intake.IntakeRunnerResponse{Id: "runner-id-123"}, }, wantErr: false, }, @@ -260,7 +263,7 @@ func TestOutputResult(t *testing.T) { model: fixtureInputModel(func(model *inputModel) { model.OutputFormat = print.JSONOutputFormat }), - resp: &intake.IntakeRunnerResponse{Id: utils.Ptr("runner-id-123")}, + resp: &intake.IntakeRunnerResponse{Id: "runner-id-123"}, }, wantErr: false, }, diff --git a/internal/cmd/beta/intake/runner/delete/delete.go b/internal/cmd/beta/intake/runner/delete/delete.go index 5c7277bff..794122083 100644 --- a/internal/cmd/beta/intake/runner/delete/delete.go +++ b/internal/cmd/beta/intake/runner/delete/delete.go @@ -7,8 +7,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -70,7 +70,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Deleting STACKIT Intake Runner", func() error { - _, err = wait.DeleteIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.RunnerId).WaitWithContext(ctx) + _, err = wait.DeleteIntakeRunnerWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.RunnerId).WaitWithContext(ctx) return err }) if err != nil { @@ -110,6 +110,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu // buildRequest creates the API request to delete an Intake Runner func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiDeleteIntakeRunnerRequest { - req := apiClient.DeleteIntakeRunner(ctx, model.ProjectId, model.Region, model.RunnerId) + req := apiClient.DefaultAPI.DeleteIntakeRunner(ctx, model.ProjectId, model.Region, model.RunnerId) return req } diff --git a/internal/cmd/beta/intake/runner/delete/delete_test.go b/internal/cmd/beta/intake/runner/delete/delete_test.go index ec5dc76f9..a4d5048fd 100644 --- a/internal/cmd/beta/intake/runner/delete/delete_test.go +++ b/internal/cmd/beta/intake/runner/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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -24,7 +24,9 @@ var ( // testCtx is a dummy context for testing purposes testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") // testClient is a mock API client - testClient = &intake.APIClient{} + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testRunnerId = uuid.NewString() ) @@ -70,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // fixtureRequest generates an API request for tests func fixtureRequest(mods ...func(request *intake.ApiDeleteIntakeRunnerRequest)) intake.ApiDeleteIntakeRunnerRequest { - request := testClient.DeleteIntakeRunner(testCtx, testProjectId, testRegion, testRunnerId) + request := testClient.DefaultAPI.DeleteIntakeRunner(testCtx, testProjectId, testRegion, testRunnerId) for _, mod := range mods { mod(&request) } @@ -147,6 +149,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/intake/runner/describe/describe.go b/internal/cmd/beta/intake/runner/describe/describe.go index 47eedc386..6eafda0fd 100644 --- a/internal/cmd/beta/intake/runner/describe/describe.go +++ b/internal/cmd/beta/intake/runner/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -87,7 +87,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu // buildRequest creates the API request to get a single Intake Runner func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiGetIntakeRunnerRequest { - req := apiClient.GetIntakeRunner(ctx, model.ProjectId, model.Region, model.RunnerId) + req := apiClient.DefaultAPI.GetIntakeRunner(ctx, model.ProjectId, model.Region, model.RunnerId) return req } diff --git a/internal/cmd/beta/intake/runner/describe/describe_test.go b/internal/cmd/beta/intake/runner/describe/describe_test.go index a9f6ff778..f65175bfb 100644 --- a/internal/cmd/beta/intake/runner/describe/describe_test.go +++ b/internal/cmd/beta/intake/runner/describe/describe_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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -23,8 +23,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testRunnerId = uuid.NewString() ) @@ -66,7 +68,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *intake.ApiGetIntakeRunnerRequest)) intake.ApiGetIntakeRunnerRequest { - request := testClient.GetIntakeRunner(testCtx, testProjectId, testRegion, testRunnerId) + request := testClient.DefaultAPI.GetIntakeRunner(testCtx, testProjectId, testRegion, testRunnerId) for _, mod := range mods { mod(&request) } @@ -143,6 +145,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/intake/runner/list/list.go b/internal/cmd/beta/intake/runner/list/list.go index 81d1afa2d..63d278516 100644 --- a/internal/cmd/beta/intake/runner/list/list.go +++ b/internal/cmd/beta/intake/runner/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -120,7 +120,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { // buildRequest creates the API request to list Intake Runners func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiListIntakeRunnersRequest { - req := apiClient.ListIntakeRunners(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.ListIntakeRunners(ctx, model.ProjectId, model.Region) // Note: we do support API pagination, but for consistency with other services, we fetch all items and apply // client-side limit. // A more advanced implementation could use the --limit flag to set the API's PageSize. diff --git a/internal/cmd/beta/intake/runner/list/list_test.go b/internal/cmd/beta/intake/runner/list/list_test.go index eed227010..ae88bff6f 100644 --- a/internal/cmd/beta/intake/runner/list/list_test.go +++ b/internal/cmd/beta/intake/runner/list/list_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -27,8 +27,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() ) @@ -58,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *intake.ApiListIntakeRunnersRequest)) intake.ApiListIntakeRunnersRequest { - request := testClient.ListIntakeRunners(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListIntakeRunners(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -141,6 +143,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/intake/runner/update/update.go b/internal/cmd/beta/intake/runner/update/update.go index f59020818..36b5b088e 100644 --- a/internal/cmd/beta/intake/runner/update/update.go +++ b/internal/cmd/beta/intake/runner/update/update.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -39,8 +39,8 @@ type inputModel struct { *globalflags.GlobalFlagModel RunnerId string DisplayName *string - MaxMessageSizeKiB *int64 - MaxMessagesPerHour *int64 + MaxMessageSizeKiB *int32 + MaxMessagesPerHour *int32 Description *string Labels *map[string]string } @@ -88,7 +88,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Updating STACKIT Intake Runner", func() error { - _, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.RunnerId).WaitWithContext(ctx) + _, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.RunnerId).WaitWithContext(ctx) return err }) if err != nil { @@ -105,8 +105,8 @@ func NewCmd(p *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().String(displayNameFlag, "", "Display name") - cmd.Flags().Int64(maxMessageSizeKiBFlag, 0, "Maximum message size in KiB. Note: Overall message capacity cannot be decreased.") - cmd.Flags().Int64(maxMessagesPerHourFlag, 0, "Maximum number of messages per hour. Note: Overall message capacity cannot be decreased.") + cmd.Flags().Int32(maxMessageSizeKiBFlag, 0, "Maximum message size in KiB. Note: Overall message capacity cannot be decreased.") + cmd.Flags().Int32(maxMessagesPerHourFlag, 0, "Maximum number of messages per hour. Note: Overall message capacity cannot be decreased.") cmd.Flags().String(descriptionFlag, "", "Description") cmd.Flags().StringToString(labelFlag, nil, `Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2".`) } @@ -123,8 +123,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu GlobalFlagModel: globalFlags, RunnerId: runnerId, DisplayName: flags.FlagToStringPointer(p, cmd, displayNameFlag), - MaxMessageSizeKiB: flags.FlagToInt64Pointer(p, cmd, maxMessageSizeKiBFlag), - MaxMessagesPerHour: flags.FlagToInt64Pointer(p, cmd, maxMessagesPerHourFlag), + MaxMessageSizeKiB: flags.FlagToInt32Pointer(p, cmd, maxMessageSizeKiBFlag), + MaxMessagesPerHour: flags.FlagToInt32Pointer(p, cmd, maxMessagesPerHourFlag), Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), Labels: flags.FlagToStringToStringPointer(p, cmd, labelFlag), } @@ -138,7 +138,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiUpdateIntakeRunnerRequest { - req := apiClient.UpdateIntakeRunner(ctx, model.ProjectId, model.Region, model.RunnerId) + req := apiClient.DefaultAPI.UpdateIntakeRunner(ctx, model.ProjectId, model.Region, model.RunnerId) payload := intake.UpdateIntakeRunnerPayload{} if model.DisplayName != nil { @@ -154,7 +154,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIC payload.Description = model.Description } if model.Labels != nil { - payload.Labels = model.Labels + payload.Labels = utils.PtrValue(model.Labels) } req = req.UpdateIntakeRunnerPayload(payload) @@ -172,7 +172,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp if model.Async { operationState = "Triggered update of" } - p.Outputf("%s Intake Runner for project %q. Runner ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id)) + p.Outputf("%s Intake Runner for project %q. Runner ID: %s\n", operationState, projectLabel, resp.Id) return nil }) } diff --git a/internal/cmd/beta/intake/runner/update/update_test.go b/internal/cmd/beta/intake/runner/update/update_test.go index 3b1161ee1..586a7cd46 100644 --- a/internal/cmd/beta/intake/runner/update/update_test.go +++ b/internal/cmd/beta/intake/runner/update/update_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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -24,8 +24,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testRunnerId = uuid.NewString() ) @@ -69,7 +71,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *intake.ApiUpdateIntakeRunnerRequest)) intake.ApiUpdateIntakeRunnerRequest { - request := testClient.UpdateIntakeRunner(testCtx, testProjectId, testRegion, testRunnerId) + request := testClient.DefaultAPI.UpdateIntakeRunner(testCtx, testProjectId, testRegion, testRunnerId) payload := intake.UpdateIntakeRunnerPayload{ DisplayName: utils.Ptr("new-runner-name"), } @@ -115,8 +117,8 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.MaxMessageSizeKiB = utils.Ptr(int64(2048)) - model.MaxMessagesPerHour = utils.Ptr(int64(10000)) + model.MaxMessageSizeKiB = utils.Ptr(int32(2048)) + model.MaxMessagesPerHour = utils.Ptr(int32(10000)) model.Description = utils.Ptr("new description") model.Labels = utils.Ptr(map[string]string{"env": "prod", "team": "sre"}) }), @@ -165,29 +167,29 @@ func TestBuildRequest(t *testing.T) { expectedRequest: fixtureRequest(func(request *intake.ApiUpdateIntakeRunnerRequest) { payload := intake.UpdateIntakeRunnerPayload{ Description: utils.Ptr("new-desc"), - Labels: utils.Ptr(map[string]string{"key": "value"}), + Labels: map[string]string{"key": "value"}, } - *request = (*request).UpdateIntakeRunnerPayload(payload) + *request = request.UpdateIntakeRunnerPayload(payload) }), }, { description: "update all fields", model: fixtureInputModel(func(model *inputModel) { model.DisplayName = utils.Ptr("another-name") - model.MaxMessageSizeKiB = utils.Ptr(int64(4096)) - model.MaxMessagesPerHour = utils.Ptr(int64(20000)) + model.MaxMessageSizeKiB = utils.Ptr(int32(4096)) + model.MaxMessagesPerHour = utils.Ptr(int32(20000)) model.Description = utils.Ptr("final-desc") model.Labels = utils.Ptr(map[string]string{"a": "b"}) }), expectedRequest: fixtureRequest(func(request *intake.ApiUpdateIntakeRunnerRequest) { payload := intake.UpdateIntakeRunnerPayload{ DisplayName: utils.Ptr("another-name"), - MaxMessageSizeKiB: utils.Ptr(int64(4096)), - MaxMessagesPerHour: utils.Ptr(int64(20000)), + MaxMessageSizeKiB: utils.Ptr(int32(4096)), + MaxMessagesPerHour: utils.Ptr(int32(20000)), Description: utils.Ptr("final-desc"), - Labels: utils.Ptr(map[string]string{"a": "b"}), + Labels: map[string]string{"a": "b"}, } - *request = (*request).UpdateIntakeRunnerPayload(payload) + *request = request.UpdateIntakeRunnerPayload(payload) }), }, } @@ -199,6 +201,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -223,7 +226,7 @@ func TestOutputResult(t *testing.T) { args: args{ model: fixtureInputModel(), projectLabel: "my-project", - resp: &intake.IntakeRunnerResponse{Id: utils.Ptr("runner-id-123")}, + resp: &intake.IntakeRunnerResponse{Id: "runner-id-123"}, }, wantErr: false, }, @@ -234,7 +237,7 @@ func TestOutputResult(t *testing.T) { model.Async = true }), projectLabel: "my-project", - resp: &intake.IntakeRunnerResponse{Id: utils.Ptr("runner-id-123")}, + resp: &intake.IntakeRunnerResponse{Id: "runner-id-123"}, }, wantErr: false, }, @@ -244,7 +247,7 @@ func TestOutputResult(t *testing.T) { model: fixtureInputModel(func(model *inputModel) { model.OutputFormat = print.JSONOutputFormat }), - resp: &intake.IntakeRunnerResponse{Id: utils.Ptr("runner-id-123")}, + resp: &intake.IntakeRunnerResponse{Id: "runner-id-123"}, }, wantErr: false, }, diff --git a/internal/cmd/beta/intake/update/update.go b/internal/cmd/beta/intake/update/update.go index c21640e5d..fb6522c7d 100644 --- a/internal/cmd/beta/intake/update/update.go +++ b/internal/cmd/beta/intake/update/update.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -107,7 +107,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Updating STACKIT Intake Runner instance", func() error { - _, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx) + _, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx) return err }) if err != nil { @@ -181,13 +181,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiUpdateIntakeRequest { - req := apiClient.UpdateIntake(ctx, model.ProjectId, model.Region, model.IntakeId) + req := apiClient.DefaultAPI.UpdateIntake(ctx, model.ProjectId, model.Region, model.IntakeId) payload := intake.UpdateIntakePayload{ - IntakeRunnerId: model.RunnerId, // This is required by the API + IntakeRunnerId: utils.PtrString(model.RunnerId), // This is required by the API DisplayName: model.DisplayName, Description: model.Description, - Labels: model.Labels, + Labels: utils.PtrValue(model.Labels), } // Build catalog patch payload only if catalog-related flags are set @@ -261,7 +261,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp if model.Async { operationState = "Triggered update of" } - p.Outputf("%s Intake for project %q. Intake ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id)) + p.Outputf("%s Intake for project %q. Intake ID: %s\n", operationState, projectLabel, resp.Id) return nil }) } diff --git a/internal/cmd/beta/intake/update/update_test.go b/internal/cmd/beta/intake/update/update_test.go index 94602f885..626133cc4 100644 --- a/internal/cmd/beta/intake/update/update_test.go +++ b/internal/cmd/beta/intake/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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -23,8 +23,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testIntakeId = uuid.NewString() testRunnerId = uuid.NewString() @@ -160,9 +162,9 @@ func TestBuildRequest(t *testing.T) { { description: "base", model: fixtureInputModel(), - expectedReq: testClient.UpdateIntake(testCtx, testProjectId, testRegion, testIntakeId). + expectedReq: testClient.DefaultAPI.UpdateIntake(testCtx, testProjectId, testRegion, testIntakeId). UpdateIntakePayload(intake.UpdateIntakePayload{ - IntakeRunnerId: utils.Ptr(testRunnerId), + IntakeRunnerId: testRunnerId, DisplayName: utils.Ptr("new-display-name"), }), }, @@ -173,9 +175,9 @@ func TestBuildRequest(t *testing.T) { model.Description = utils.Ptr("new-desc") model.CatalogURI = utils.Ptr("new-uri") }), - expectedReq: testClient.UpdateIntake(testCtx, testProjectId, testRegion, testIntakeId). + expectedReq: testClient.DefaultAPI.UpdateIntake(testCtx, testProjectId, testRegion, testIntakeId). UpdateIntakePayload(intake.UpdateIntakePayload{ - IntakeRunnerId: utils.Ptr(testRunnerId), + IntakeRunnerId: testRunnerId, Description: utils.Ptr("new-desc"), Catalog: &intake.IntakeCatalogPatch{ Uri: utils.Ptr("new-uri"), @@ -196,12 +198,12 @@ func TestBuildRequest(t *testing.T) { model.DremioTokenEndpoint = utils.Ptr("final-endpoint") model.DremioToken = utils.Ptr("final-token") }), - expectedReq: testClient.UpdateIntake(testCtx, testProjectId, testRegion, testIntakeId). + expectedReq: testClient.DefaultAPI.UpdateIntake(testCtx, testProjectId, testRegion, testIntakeId). UpdateIntakePayload(intake.UpdateIntakePayload{ - IntakeRunnerId: utils.Ptr(testRunnerId), + IntakeRunnerId: testRunnerId, DisplayName: utils.Ptr("another-name"), Description: utils.Ptr("final-desc"), - Labels: utils.Ptr(map[string]string{"a": "b"}), + Labels: map[string]string{"a": "b"}, Catalog: &intake.IntakeCatalogPatch{ Uri: utils.Ptr("final-uri"), Warehouse: utils.Ptr("final-warehouse"), @@ -226,6 +228,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(tt.expectedReq, request, cmp.AllowUnexported(request), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -253,12 +256,12 @@ func TestOutputResult(t *testing.T) { }, { name: "json output", - args: args{outputFormat: print.JSONOutputFormat, resp: &intake.IntakeResponse{Id: utils.Ptr("intake-id-123")}}, + args: args{outputFormat: print.JSONOutputFormat, resp: &intake.IntakeResponse{Id: "intake-id-123"}}, wantErr: false, }, { name: "yaml output", - args: args{outputFormat: print.YAMLOutputFormat, resp: &intake.IntakeResponse{Id: utils.Ptr("runner-id-123")}}, + args: args{outputFormat: print.YAMLOutputFormat, resp: &intake.IntakeResponse{Id: "runner-id-123"}}, wantErr: false, }, { diff --git a/internal/cmd/beta/intake/user/create/create.go b/internal/cmd/beta/intake/user/create/create.go index 436560060..625b3c704 100644 --- a/internal/cmd/beta/intake/user/create/create.go +++ b/internal/cmd/beta/intake/user/create/create.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -90,7 +90,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Creating STACKIT Intake User", func() error { - _, err = wait.CreateOrUpdateIntakeUserWaitHandler(ctx, apiClient, model.ProjectId, model.Region, *model.IntakeId, resp.GetId()).WaitWithContext(ctx) + _, err = wait.CreateOrUpdateIntakeUserWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, *model.IntakeId, resp.GetId()).WaitWithContext(ctx) return err }) if err != nil { @@ -138,7 +138,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiCreateIntakeUserRequest { - req := apiClient.CreateIntakeUser(ctx, model.ProjectId, model.Region, *model.IntakeId) + req := apiClient.DefaultAPI.CreateIntakeUser(ctx, model.ProjectId, model.Region, *model.IntakeId) var userType *intake.UserType if model.UserType != nil { @@ -146,11 +146,11 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIC } payload := intake.CreateIntakeUserPayload{ - DisplayName: model.DisplayName, - Password: model.Password, + DisplayName: utils.PtrString(model.DisplayName), + Password: utils.PtrString(model.Password), Type: userType, Description: model.Description, - Labels: model.Labels, + Labels: utils.PtrValue(model.Labels), } req = req.CreateIntakeUserPayload(payload) @@ -168,7 +168,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s Intake User for project %q. User ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id)) + p.Outputf("%s Intake User for project %q. User ID: %s\n", operationState, projectLabel, resp.Id) return nil }) } diff --git a/internal/cmd/beta/intake/user/create/create_test.go b/internal/cmd/beta/intake/user/create/create_test.go index 4d28c92c7..2817f517e 100644 --- a/internal/cmd/beta/intake/user/create/create_test.go +++ b/internal/cmd/beta/intake/user/create/create_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -33,7 +33,9 @@ var ( // testCtx dummy context for testing purposes testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") // testClient mock API client - testClient = &intake.APIClient{} + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testIntakeId = uuid.NewString() @@ -83,11 +85,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakeUserPayload)) intake.CreateIntakeUserPayload { userType := intake.UserType(testUserType) payload := intake.CreateIntakeUserPayload{ - DisplayName: utils.Ptr(testDisplayName), - Password: utils.Ptr(testPassword), + DisplayName: testDisplayName, + Password: testPassword, Type: &userType, Description: utils.Ptr(testDescription), - Labels: utils.Ptr(testLabels), + Labels: testLabels, } for _, mod := range mods { mod(&payload) @@ -97,7 +99,7 @@ func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakeUserPayload)) // fixtureRequest generates an API request for tests func fixtureRequest(mods ...func(request *intake.ApiCreateIntakeUserRequest)) intake.ApiCreateIntakeUserRequest { - request := testClient.CreateIntakeUser(testCtx, testProjectId, testRegion, testIntakeId) + request := testClient.DefaultAPI.CreateIntakeUser(testCtx, testProjectId, testRegion, testIntakeId) request = request.CreateIntakeUserPayload(fixtureCreatePayload()) for _, mod := range mods { mod(&request) @@ -199,7 +201,7 @@ func TestBuildRequest(t *testing.T) { model.UserType = nil }), expectedRequest: fixtureRequest(func(request *intake.ApiCreateIntakeUserRequest) { - *request = (*request).CreateIntakeUserPayload(fixtureCreatePayload(func(payload *intake.CreateIntakeUserPayload) { + *request = request.CreateIntakeUserPayload(fixtureCreatePayload(func(payload *intake.CreateIntakeUserPayload) { payload.Description = nil payload.Labels = nil payload.Type = nil @@ -214,6 +216,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -238,7 +241,7 @@ func TestOutputResult(t *testing.T) { args: args{ model: fixtureInputModel(), projectLabel: "my-project", - resp: &intake.IntakeUserResponse{Id: utils.Ptr("user-id-123")}, + resp: &intake.IntakeUserResponse{Id: "user-id-123"}, }, wantErr: false, }, @@ -249,7 +252,7 @@ func TestOutputResult(t *testing.T) { model.Async = true }), projectLabel: "my-project", - resp: &intake.IntakeUserResponse{Id: utils.Ptr("user-id-123")}, + resp: &intake.IntakeUserResponse{Id: "user-id-123"}, }, wantErr: false, }, @@ -259,7 +262,7 @@ func TestOutputResult(t *testing.T) { model: fixtureInputModel(func(model *inputModel) { model.OutputFormat = print.JSONOutputFormat }), - resp: &intake.IntakeUserResponse{Id: utils.Ptr("user-id-123")}, + resp: &intake.IntakeUserResponse{Id: "user-id-123"}, }, wantErr: false, }, diff --git a/internal/cmd/beta/intake/user/delete/delete.go b/internal/cmd/beta/intake/user/delete/delete.go index f6d43b51d..0916cd430 100644 --- a/internal/cmd/beta/intake/user/delete/delete.go +++ b/internal/cmd/beta/intake/user/delete/delete.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -72,7 +72,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Deleting STACKIT Intake User", func() error { - _, err = wait.DeleteIntakeUserWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId, model.UserId).WaitWithContext(ctx) + _, err = wait.DeleteIntakeUserWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.IntakeId, model.UserId).WaitWithContext(ctx) return err }) if err != nil { @@ -121,6 +121,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu // buildRequest creates the API request to delete an Intake User func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiDeleteIntakeUserRequest { - req := apiClient.DeleteIntakeUser(ctx, model.ProjectId, model.Region, model.IntakeId, model.UserId) + req := apiClient.DefaultAPI.DeleteIntakeUser(ctx, model.ProjectId, model.Region, model.IntakeId, model.UserId) return req } diff --git a/internal/cmd/beta/intake/user/delete/delete_test.go b/internal/cmd/beta/intake/user/delete/delete_test.go index 9aa042552..f5e02d8ed 100644 --- a/internal/cmd/beta/intake/user/delete/delete_test.go +++ b/internal/cmd/beta/intake/user/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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -24,7 +24,9 @@ var ( // testCtx is a dummy context for testing purposes testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") // testClient is a mock API client - testClient = &intake.APIClient{} + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testIntakeId = uuid.NewString() testUserId = uuid.NewString() @@ -73,7 +75,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // fixtureRequest generates an API request for tests func fixtureRequest(mods ...func(request *intake.ApiDeleteIntakeUserRequest)) intake.ApiDeleteIntakeUserRequest { - request := testClient.DeleteIntakeUser(testCtx, testProjectId, testRegion, testIntakeId, testUserId) + request := testClient.DefaultAPI.DeleteIntakeUser(testCtx, testProjectId, testRegion, testIntakeId, testUserId) for _, mod := range mods { mod(&request) } @@ -166,6 +168,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/intake/user/describe/describe.go b/internal/cmd/beta/intake/user/describe/describe.go index 5a12896aa..66c53cda2 100644 --- a/internal/cmd/beta/intake/user/describe/describe.go +++ b/internal/cmd/beta/intake/user/describe/describe.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -97,7 +97,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiGetIntakeUserRequest { - req := apiClient.GetIntakeUser(ctx, model.ProjectId, model.Region, model.IntakeId, model.UserId) + req := apiClient.DefaultAPI.GetIntakeUser(ctx, model.ProjectId, model.Region, model.IntakeId, model.UserId) return req } @@ -113,10 +113,7 @@ func outputResult(p *print.Printer, outputFormat string, user *intake.IntakeUser table.AddRow("ID", user.GetId()) table.AddRow("Name", user.GetDisplayName()) table.AddRow("State", user.GetState()) - - if user.Type != nil { - table.AddRow("Type", *user.Type) - } + table.AddRow("Type", user.Type) table.AddRow("Username", user.GetUser()) table.AddRow("Created", user.GetCreateTime()) diff --git a/internal/cmd/beta/intake/user/describe/describe_test.go b/internal/cmd/beta/intake/user/describe/describe_test.go index b3aacd8bb..d8f286866 100644 --- a/internal/cmd/beta/intake/user/describe/describe_test.go +++ b/internal/cmd/beta/intake/user/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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -22,8 +22,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testIntakeId = uuid.NewString() testUserId = uuid.NewString() @@ -68,7 +70,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *intake.ApiGetIntakeUserRequest)) intake.ApiGetIntakeUserRequest { - request := testClient.GetIntakeUser(testCtx, testProjectId, testRegion, testIntakeId, testUserId) + request := testClient.DefaultAPI.GetIntakeUser(testCtx, testProjectId, testRegion, testIntakeId, testUserId) for _, mod := range mods { mod(&request) } @@ -161,6 +163,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testClient.DefaultAPI), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/intake/user/list/list.go b/internal/cmd/beta/intake/user/list/list.go index 3c1f57520..a81e10c53 100644 --- a/internal/cmd/beta/intake/user/list/list.go +++ b/internal/cmd/beta/intake/user/list/list.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -17,7 +17,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/intake/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -127,7 +126,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { // buildRequest creates the API request to list Intake Users func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiListIntakeUsersRequest { - req := apiClient.ListIntakeUsers(ctx, model.ProjectId, model.Region, *model.IntakeId) + req := apiClient.DefaultAPI.ListIntakeUsers(ctx, model.ProjectId, model.Region, *model.IntakeId) return req } @@ -145,7 +144,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel, intakeId string, table.AddRow( user.GetId(), user.GetDisplayName(), - utils.PtrString(user.Type), + user.Type, user.GetState(), ) } diff --git a/internal/cmd/beta/intake/user/list/list_test.go b/internal/cmd/beta/intake/user/list/list_test.go index f83246a44..16c726645 100644 --- a/internal/cmd/beta/intake/user/list/list_test.go +++ b/internal/cmd/beta/intake/user/list/list_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -25,8 +25,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testIntakeId = uuid.NewString() testLimit = int64(5) @@ -60,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *intake.ApiListIntakeUsersRequest)) intake.ApiListIntakeUsersRequest { - request := testClient.ListIntakeUsers(testCtx, testProjectId, testRegion, testIntakeId) + request := testClient.DefaultAPI.ListIntakeUsers(testCtx, testProjectId, testRegion, testIntakeId) for _, mod := range mods { mod(&request) } @@ -156,6 +158,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreUnexported(intake.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/beta/intake/user/update/update.go b/internal/cmd/beta/intake/user/update/update.go index a2b1b881c..cde043061 100644 --- a/internal/cmd/beta/intake/user/update/update.go +++ b/internal/cmd/beta/intake/user/update/update.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/intake" - "github.com/stackitcloud/stackit-sdk-go/services/intake/wait" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" + "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -79,7 +79,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(p.Printer, "Updating STACKIT Intake User", func() error { - _, err = wait.CreateOrUpdateIntakeUserWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId, model.UserId).WaitWithContext(ctx) + _, err = wait.CreateOrUpdateIntakeUserWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.IntakeId, model.UserId).WaitWithContext(ctx) return err }) @@ -135,13 +135,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiUpdateIntakeUserRequest { - req := apiClient.UpdateIntakeUser(ctx, model.ProjectId, model.Region, model.IntakeId, model.UserId) + req := apiClient.DefaultAPI.UpdateIntakeUser(ctx, model.ProjectId, model.Region, model.IntakeId, model.UserId) payload := intake.UpdateIntakeUserPayload{ DisplayName: model.DisplayName, Description: model.Description, Password: model.Password, - Labels: model.Labels, + Labels: utils.PtrValue(model.Labels), } if model.UserType != nil { @@ -164,7 +164,7 @@ func outputResult(p *print.Printer, model *inputModel, resp *intake.IntakeUserRe if model.Async { operationState = "Triggered update of" } - p.Outputf("%s Intake User for intake %q. User ID: %s\n", operationState, model.IntakeId, utils.PtrString(resp.Id)) + p.Outputf("%s Intake User for intake %q. User ID: %s\n", operationState, model.IntakeId, resp.Id) return nil }) } diff --git a/internal/cmd/beta/intake/user/update/update_test.go b/internal/cmd/beta/intake/user/update/update_test.go index f887ac4a0..f81e68dc5 100644 --- a/internal/cmd/beta/intake/user/update/update_test.go +++ b/internal/cmd/beta/intake/user/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/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -23,8 +23,10 @@ const ( ) var ( - testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &intake.APIClient{} + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &intake.APIClient{ + DefaultAPI: &intake.DefaultAPIService{}, + } testProjectId = uuid.NewString() testIntakeId = uuid.NewString() testUserId = uuid.NewString() @@ -69,7 +71,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *intake.ApiUpdateIntakeUserRequest)) intake.ApiUpdateIntakeUserRequest { - request := testClient.UpdateIntakeUser(testCtx, testProjectId, testRegion, testIntakeId, testUserId) + request := testClient.DefaultAPI.UpdateIntakeUser(testCtx, testProjectId, testRegion, testIntakeId, testUserId) payload := intake.UpdateIntakeUserPayload{ DisplayName: utils.Ptr("new-display-name"), } @@ -174,7 +176,7 @@ func TestBuildRequest(t *testing.T) { payload := intake.UpdateIntakeUserPayload{ Description: utils.Ptr("new-desc"), } - *request = (*request).UpdateIntakeUserPayload(payload) + *request = request.UpdateIntakeUserPayload(payload) }), }, { @@ -191,11 +193,11 @@ func TestBuildRequest(t *testing.T) { payload := intake.UpdateIntakeUserPayload{ DisplayName: utils.Ptr("another-name"), Description: utils.Ptr("final-desc"), - Labels: utils.Ptr(map[string]string{"a": "b"}), + Labels: map[string]string{"a": "b"}, Type: &userType, Password: utils.Ptr("Secret123!"), } - *request = (*request).UpdateIntakeUserPayload(payload) + *request = request.UpdateIntakeUserPayload(payload) }), }, } @@ -207,6 +209,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(tt.expectedReq, request, cmp.AllowUnexported(request), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreUnexported(intake.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -234,7 +237,7 @@ func TestOutputResult(t *testing.T) { }, { name: "json output", - args: args{outputFormat: print.JSONOutputFormat, resp: &intake.IntakeUserResponse{Id: utils.Ptr("user-id-123")}}, + args: args{outputFormat: print.JSONOutputFormat, resp: &intake.IntakeUserResponse{Id: "user-id-123"}}, wantErr: false, }, { diff --git a/internal/pkg/services/intake/client/client.go b/internal/pkg/services/intake/client/client.go index 2a0e89400..be6080862 100644 --- a/internal/pkg/services/intake/client/client.go +++ b/internal/pkg/services/intake/client/client.go @@ -2,7 +2,7 @@ package client import ( "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/intake" + intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi" "github.com/stackitcloud/stackit-cli/internal/pkg/config" genericclient "github.com/stackitcloud/stackit-cli/internal/pkg/generic-client"