Skip to content

Commit 1e8c409

Browse files
yago-123Yago Carlos Fernandez Gou
andauthored
feat(intake): port to v1betaapi (#1364)
* Use new SDK hierarchy * Bump go.mod version * Fix linting issues * Update docs * make fmt --------- Co-authored-by: Yago Carlos Fernandez Gou <yago.fernandez_gou@mail.schwarz>
1 parent e17c7ff commit 1e8c409

35 files changed

Lines changed: 268 additions & 226 deletions

docs/stackit_beta_intake_runner_create.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ stackit beta intake runner create [flags]
2323
### Options
2424

2525
```
26-
--description string Description
27-
--display-name string Display name
28-
-h, --help Help for "stackit beta intake runner create"
29-
--labels stringToString Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2" (default [])
30-
--max-message-size-kib int Maximum message size in KiB
31-
--max-messages-per-hour int Maximum number of messages per hour
26+
--description string Description
27+
--display-name string Display name
28+
-h, --help Help for "stackit beta intake runner create"
29+
--labels stringToString Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2" (default [])
30+
--max-message-size-kib int32 Maximum message size in KiB
31+
--max-messages-per-hour int32 Maximum number of messages per hour
3232
```
3333

3434
### Options inherited from parent commands

docs/stackit_beta_intake_runner_update.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ stackit beta intake runner update RUNNER_ID [flags]
2323
### Options
2424

2525
```
26-
--description string Description
27-
--display-name string Display name
28-
-h, --help Help for "stackit beta intake runner update"
29-
--labels stringToString Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2". (default [])
30-
--max-message-size-kib int Maximum message size in KiB. Note: Overall message capacity cannot be decreased.
31-
--max-messages-per-hour int Maximum number of messages per hour. Note: Overall message capacity cannot be decreased.
26+
--description string Description
27+
--display-name string Display name
28+
-h, --help Help for "stackit beta intake runner update"
29+
--labels stringToString Labels in key=value format, separated by commas. Example: --labels "key1=value1,key2=value2". (default [])
30+
--max-message-size-kib int32 Maximum message size in KiB. Note: Overall message capacity cannot be decreased.
31+
--max-messages-per-hour int32 Maximum number of messages per hour. Note: Overall message capacity cannot be decreased.
3232
```
3333

3434
### Options inherited from parent commands

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3
2424
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3
2525
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5
26-
github.com/stackitcloud/stackit-sdk-go/services/intake v0.4.4
26+
github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1
2727
github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2
2828
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8
2929
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,8 @@ github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3 h1:VIjkSofZz9utOOkBd
610610
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.3/go.mod h1:EJk1Ss9GTel2NPIu/w3+x9XcQcEd2k3ibea5aQDzVhQ=
611611
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5 h1:W57+XRa8wTLsi5CV9Tqa7mGgt/PvlRM//RurXSmvII8=
612612
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5/go.mod h1:lTWjW57eAq1bwfM6nsNinhoBr3MHFW/GaFasdAsYfDM=
613-
github.com/stackitcloud/stackit-sdk-go/services/intake v0.4.4 h1:cbXM7jUBCL7A5zxJKFWolRIDl45sdJMMMAzeumeIEOA=
614-
github.com/stackitcloud/stackit-sdk-go/services/intake v0.4.4/go.mod h1:z+7KKZf0uHXU/Kb4CRs/oaBrXRJ01LpiD0OH11MXLOk=
613+
github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 h1:7ZSrwps/zI41rl+xYkG4osld8cyAwssyl/UZ/Iu/F2g=
614+
github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1/go.mod h1:ZIvwBZwEMFO+YfJLCNXqabslI0Fp9zxV7ZBwlZjk7uE=
615615
github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2 h1:2ulSL2IkIAKND59eAjbEhVkOoBMyvm48ojwz1a3t0U0=
616616
github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2/go.mod h1:cuIaMMiHeHQsbvy7BOFMutoV3QtN+ZBx7Tg3GmYUw7s=
617617
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0 h1:DxrN85V738CRLynu6MULQHO+OXyYnkhVPgoZKULfFIs=

internal/cmd/beta/intake/create/create.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66

77
"github.com/spf13/cobra"
8-
"github.com/stackitcloud/stackit-sdk-go/services/intake"
9-
"github.com/stackitcloud/stackit-sdk-go/services/intake/wait"
8+
intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi"
9+
"github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait"
1010

1111
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1212
cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -113,7 +113,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command {
113113
// Wait for async operation, if async mode not enabled
114114
if !model.Async {
115115
err := spinner.Run(p.Printer, "Creating STACKIT Intake instance", func() error {
116-
_, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx)
116+
_, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx)
117117
return err
118118
})
119119
if err != nil {
@@ -185,19 +185,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
185185
}
186186

187187
func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiCreateIntakeRequest {
188-
req := apiClient.CreateIntake(ctx, model.ProjectId, model.Region)
188+
req := apiClient.DefaultAPI.CreateIntake(ctx, model.ProjectId, model.Region)
189189

190190
// Build catalog authentication
191191
var catalogAuth *intake.CatalogAuth
192192
if model.CatalogAuthType != nil {
193193
authType := intake.CatalogAuthType(*model.CatalogAuthType)
194194
catalogAuth = &intake.CatalogAuth{
195-
Type: &authType,
195+
Type: authType,
196196
}
197197
if *model.CatalogAuthType == "dremio" {
198198
catalogAuth.Dremio = &intake.DremioAuth{
199-
TokenEndpoint: model.DremioTokenEndpoint,
200-
PersonalAccessToken: model.DremioToken,
199+
TokenEndpoint: utils.PtrString(model.DremioTokenEndpoint),
200+
PersonalAccessToken: utils.PtrString(model.DremioToken),
201201
}
202202
}
203203
}
@@ -209,22 +209,22 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIC
209209

210210
// Build catalog
211211
catalogPayload := intake.IntakeCatalog{
212-
Uri: model.CatalogURI,
213-
Warehouse: model.CatalogWarehouse,
212+
Uri: utils.PtrString(model.CatalogURI),
213+
Warehouse: utils.PtrString(model.CatalogWarehouse),
214214
Namespace: model.CatalogNamespace,
215215
TableName: model.CatalogTableName,
216216
Partitioning: partitioning,
217-
PartitionBy: model.CatalogPartitionBy,
217+
PartitionBy: utils.PtrValue(model.CatalogPartitionBy),
218218
Auth: catalogAuth,
219219
}
220220

221221
// Build main payload
222222
payload := intake.CreateIntakePayload{
223-
DisplayName: model.DisplayName,
224-
IntakeRunnerId: model.RunnerId,
223+
DisplayName: utils.PtrString(model.DisplayName),
224+
IntakeRunnerId: utils.PtrString(model.RunnerId),
225225
Description: model.Description,
226-
Labels: model.Labels,
227-
Catalog: &catalogPayload,
226+
Labels: utils.PtrValue(model.Labels),
227+
Catalog: catalogPayload,
228228
}
229229
req = req.CreateIntakePayload(payload)
230230

@@ -242,7 +242,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp
242242
if model.Async {
243243
operationState = "Triggered creation of"
244244
}
245-
p.Outputf("%s Intake for project %q. Intake ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id))
245+
p.Outputf("%s Intake for project %q. Intake ID: %s\n", operationState, projectLabel, resp.Id)
246246
return nil
247247
})
248248
}

internal/cmd/beta/intake/create/create_test.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/google/go-cmp/cmp/cmpopts"
99
"github.com/google/uuid"
1010
"github.com/spf13/cobra"
11-
"github.com/stackitcloud/stackit-sdk-go/services/intake"
11+
intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi"
1212

1313
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1414
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
@@ -41,7 +41,9 @@ var (
4141
// testCtx dummy context for testing purposes
4242
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
4343
// testClient mock API client
44-
testClient = &intake.APIClient{}
44+
testClient = &intake.APIClient{
45+
DefaultAPI: &intake.DefaultAPIService{},
46+
}
4547
testProjectId = uuid.NewString()
4648
testRunnerId = uuid.NewString()
4749

@@ -107,22 +109,22 @@ func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakePayload)) int
107109
authType := intake.CatalogAuthType(testCatalogAuthType)
108110
testPartitioningType := intake.PartitioningType(testCatalogPartitioning)
109111
payload := intake.CreateIntakePayload{
110-
DisplayName: utils.Ptr(testDisplayName),
111-
IntakeRunnerId: utils.Ptr(testRunnerId),
112+
DisplayName: testDisplayName,
113+
IntakeRunnerId: testRunnerId,
112114
Description: utils.Ptr(testDescription),
113-
Labels: utils.Ptr(testLabels),
114-
Catalog: &intake.IntakeCatalog{
115-
Uri: utils.Ptr(testCatalogURI),
116-
Warehouse: utils.Ptr(testCatalogWarehouse),
115+
Labels: testLabels,
116+
Catalog: intake.IntakeCatalog{
117+
Uri: testCatalogURI,
118+
Warehouse: testCatalogWarehouse,
117119
Namespace: utils.Ptr(testCatalogNamespace),
118120
TableName: utils.Ptr(testCatalogTableName),
119121
Partitioning: &testPartitioningType,
120-
PartitionBy: utils.Ptr(testCatalogPartitionBy),
122+
PartitionBy: testCatalogPartitionBy,
121123
Auth: &intake.CatalogAuth{
122-
Type: &authType,
124+
Type: authType,
123125
Dremio: &intake.DremioAuth{
124-
TokenEndpoint: utils.Ptr(testDremioTokenEndpoint),
125-
PersonalAccessToken: utils.Ptr(testDremioToken),
126+
TokenEndpoint: testDremioTokenEndpoint,
127+
PersonalAccessToken: testDremioToken,
126128
},
127129
},
128130
},
@@ -135,7 +137,7 @@ func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakePayload)) int
135137

136138
// fixtureRequest generates an API request for tests
137139
func fixtureRequest(mods ...func(request *intake.ApiCreateIntakeRequest)) intake.ApiCreateIntakeRequest {
138-
request := testClient.CreateIntake(testCtx, testProjectId, testRegion)
140+
request := testClient.DefaultAPI.CreateIntake(testCtx, testProjectId, testRegion)
139141
request = request.CreateIntakePayload(fixtureCreatePayload())
140142
for _, mod := range mods {
141143
mod(&request)
@@ -248,7 +250,7 @@ func TestBuildRequest(t *testing.T) {
248250
model.DremioToken = nil
249251
}),
250252
expectedRequest: fixtureRequest(func(request *intake.ApiCreateIntakeRequest) {
251-
*request = (*request).CreateIntakePayload(fixtureCreatePayload(func(payload *intake.CreateIntakePayload) {
253+
*request = request.CreateIntakePayload(fixtureCreatePayload(func(payload *intake.CreateIntakePayload) {
252254
payload.Description = nil
253255
payload.Labels = nil
254256
payload.Catalog.Namespace = nil
@@ -267,9 +269,9 @@ func TestBuildRequest(t *testing.T) {
267269
model.DremioToken = nil
268270
}),
269271
expectedRequest: fixtureRequest(func(request *intake.ApiCreateIntakeRequest) {
270-
*request = (*request).CreateIntakePayload(fixtureCreatePayload(func(payload *intake.CreateIntakePayload) {
272+
*request = request.CreateIntakePayload(fixtureCreatePayload(func(payload *intake.CreateIntakePayload) {
271273
authType := intake.CatalogAuthType("none")
272-
payload.Catalog.Auth.Type = &authType
274+
payload.Catalog.Auth.Type = authType
273275
payload.Catalog.Auth.Dremio = nil
274276
}))
275277
}),
@@ -282,6 +284,7 @@ func TestBuildRequest(t *testing.T) {
282284
diff := cmp.Diff(request, tt.expectedRequest,
283285
cmp.AllowUnexported(tt.expectedRequest),
284286
cmpopts.EquateComparable(testCtx),
287+
cmpopts.EquateComparable(testClient.DefaultAPI),
285288
)
286289
if diff != "" {
287290
t.Fatalf("Data does not match: %s", diff)
@@ -306,7 +309,7 @@ func TestOutputResult(t *testing.T) {
306309
args: args{
307310
model: fixtureInputModel(),
308311
projectLabel: "my-project",
309-
resp: &intake.IntakeResponse{Id: utils.Ptr("intake-id-123")},
312+
resp: &intake.IntakeResponse{Id: "intake-id-123"},
310313
},
311314
wantErr: false,
312315
},
@@ -317,7 +320,7 @@ func TestOutputResult(t *testing.T) {
317320
model.Async = true
318321
}),
319322
projectLabel: "my-project",
320-
resp: &intake.IntakeResponse{Id: utils.Ptr("intake-id-123")},
323+
resp: &intake.IntakeResponse{Id: "intake-id-123"},
321324
},
322325
wantErr: false,
323326
},
@@ -327,7 +330,7 @@ func TestOutputResult(t *testing.T) {
327330
model: fixtureInputModel(func(model *inputModel) {
328331
model.OutputFormat = print.JSONOutputFormat
329332
}),
330-
resp: &intake.IntakeResponse{Id: utils.Ptr("intake-id-123")},
333+
resp: &intake.IntakeResponse{Id: "intake-id-123"},
331334
},
332335
wantErr: false,
333336
},

internal/cmd/beta/intake/delete/delete.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"fmt"
66

77
"github.com/spf13/cobra"
8-
"github.com/stackitcloud/stackit-sdk-go/services/intake/wait"
8+
"github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi/wait"
99

10-
"github.com/stackitcloud/stackit-sdk-go/services/intake"
10+
intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi"
1111

1212
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1313
cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -70,7 +70,7 @@ func NewCmd(p *types.CmdParams) *cobra.Command {
7070
// Wait for async operation, if async mode not enabled
7171
if !model.Async {
7272
err := spinner.Run(p.Printer, "Deleting STACKIT Intake instance", func() error {
73-
_, err = wait.DeleteIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx)
73+
_, err = wait.DeleteIntakeWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx)
7474
return err
7575
})
7676
if err != nil {
@@ -110,6 +110,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
110110

111111
// buildRequest creates the API request to delete an Intake
112112
func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiDeleteIntakeRequest {
113-
req := apiClient.DeleteIntake(ctx, model.ProjectId, model.Region, model.IntakeId)
113+
req := apiClient.DefaultAPI.DeleteIntake(ctx, model.ProjectId, model.Region, model.IntakeId)
114114
return req
115115
}

internal/cmd/beta/intake/delete/delete_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/google/go-cmp/cmp"
88
"github.com/google/go-cmp/cmp/cmpopts"
99
"github.com/google/uuid"
10-
"github.com/stackitcloud/stackit-sdk-go/services/intake"
10+
intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi"
1111

1212
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1313
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
@@ -24,7 +24,9 @@ var (
2424
// testCtx is a dummy context for testing purposes
2525
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2626
// testClient is a mock API client
27-
testClient = &intake.APIClient{}
27+
testClient = &intake.APIClient{
28+
DefaultAPI: &intake.DefaultAPIService{},
29+
}
2830
testProjectId = uuid.NewString()
2931
testIntakeId = uuid.NewString()
3032
)
@@ -70,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
7072

7173
// fixtureRequest generates an API request for tests
7274
func fixtureRequest(mods ...func(request *intake.ApiDeleteIntakeRequest)) intake.ApiDeleteIntakeRequest {
73-
request := testClient.DeleteIntake(testCtx, testProjectId, testRegion, testIntakeId)
75+
request := testClient.DefaultAPI.DeleteIntake(testCtx, testProjectId, testRegion, testIntakeId)
7476
for _, mod := range mods {
7577
mod(&request)
7678
}
@@ -147,6 +149,7 @@ func TestBuildRequest(t *testing.T) {
147149
diff := cmp.Diff(request, tt.expectedRequest,
148150
cmp.AllowUnexported(tt.expectedRequest),
149151
cmpopts.EquateComparable(testCtx),
152+
cmpopts.EquateComparable(testClient.DefaultAPI),
150153
)
151154
if diff != "" {
152155
t.Fatalf("Data does not match: %s", diff)

internal/cmd/beta/intake/describe/describe.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77

88
"github.com/spf13/cobra"
9-
"github.com/stackitcloud/stackit-sdk-go/services/intake"
9+
intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi"
1010

1111
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1212
cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -86,7 +86,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
8686
}
8787

8888
func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiGetIntakeRequest {
89-
req := apiClient.GetIntake(ctx, model.ProjectId, model.Region, model.IntakeId)
89+
req := apiClient.DefaultAPI.GetIntake(ctx, model.ProjectId, model.Region, model.IntakeId)
9090
return req
9191
}
9292

@@ -131,8 +131,8 @@ func outputResult(p *print.Printer, outputFormat string, intk *intake.IntakeResp
131131
table.AddRow("Catalog Table Name", tableName)
132132
}
133133
table.AddRow("Catalog Partitioning", catalog.GetPartitioning())
134-
if partitionBy := catalog.GetPartitionBy(); partitionBy != nil && len(*partitionBy) > 0 {
135-
table.AddRow("Catalog Partition By", strings.Join(*partitionBy, ", "))
134+
if partitionBy := catalog.GetPartitionBy(); len(partitionBy) > 0 {
135+
table.AddRow("Catalog Partition By", strings.Join(partitionBy, ", "))
136136
}
137137

138138
err := table.Display(p)

0 commit comments

Comments
 (0)