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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/stackit_beta_intake_runner_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions docs/stackit_beta_intake_runner_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
30 changes: 15 additions & 15 deletions internal/cmd/beta/intake/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
}
}
}
Expand All @@ -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)

Expand All @@ -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
})
}
41 changes: 22 additions & 19 deletions internal/cmd/beta/intake/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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,
},
},
},
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
}))
}),
Expand All @@ -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)
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/intake/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
9 changes: 6 additions & 3 deletions internal/cmd/beta/intake/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"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"
Expand All @@ -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()
)
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/intake/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading