Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
75913d4
chore(logs): bump version
j1n-o9r Jun 22, 2026
3acefb4
chore(logs): substitute imports
j1n-o9r Jun 22, 2026
50e5a37
chore(logs): refactor instance create
j1n-o9r Jun 22, 2026
2e00a3a
chore(logs): refactor utils
j1n-o9r Jun 22, 2026
da218a7
chore(logs): refactor delete
j1n-o9r Jun 22, 2026
2ff7dd8
chore(logs): refactor client
j1n-o9r Jun 22, 2026
cb1363d
chore(logs): refactor instance describe
j1n-o9r Jun 22, 2026
5ba3ea6
chore(logs): refactor instance list
j1n-o9r Jun 22, 2026
13004ae
chore(logs): refactored instance create and update and reworked Reten…
j1n-o9r Jun 22, 2026
548c2cb
chore(logs): refactored access token create
j1n-o9r Jun 22, 2026
46ecb8f
chore(logs): redo using highest level testutils func
j1n-o9r Jun 22, 2026
1cbc7ec
chore(logs): refactor access token delete
j1n-o9r Jun 22, 2026
4bcd415
chore(logs): refactor access token delete all
j1n-o9r Jun 22, 2026
84d2262
chore(logs): refactor access token delete all expired
j1n-o9r Jun 22, 2026
f46ccfe
chore(logs): refactor access token describe
j1n-o9r Jun 22, 2026
2531f78
chore(logs): refactor access token list
j1n-o9r Jun 22, 2026
6f5e585
chore(logs): refactor access token update
j1n-o9r Jun 22, 2026
5c3eea0
chore(logs): generate docs
j1n-o9r Jun 22, 2026
e963496
chore(logs): remove unnecessary check
j1n-o9r Jun 22, 2026
6118f9d
chore(logs): fix test
j1n-o9r Jun 22, 2026
b21d307
chore(logs): remove fragment from test
j1n-o9r Jun 22, 2026
eab7b25
chore(logs): rework cmpopts.EquateComparabl
j1n-o9r Jun 24, 2026
d67730f
chore(logs): copy utils func
j1n-o9r Jun 24, 2026
f1fa7e3
chore(logs): further improvements
j1n-o9r Jun 24, 2026
c5aa95f
chore(logs): further improvements
j1n-o9r Jun 24, 2026
2c39f1b
chore(logs): further improvements
j1n-o9r Jun 24, 2026
d731282
chore(logs): fix errors
j1n-o9r Jun 24, 2026
b719c76
chore(logs): fix errors
j1n-o9r Jun 24, 2026
d9facbc
chore(logs): make acl desired type in model (like in logme syslog)
j1n-o9r Jul 6, 2026
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
2 changes: 1 addition & 1 deletion docs/stackit_logs_access-token_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ stackit logs access-token create [flags]
--display-name string Display name for the access token
-h, --help Help for "stackit logs access-token create"
--instance-id string ID of the Logs instance
--lifetime int Lifetime of the access token in days [1 - 180]
--lifetime int32 Lifetime of the access token in days [1 - 180]
--permissions strings Permissions of the access token ["read" "write"]
```

Expand Down
10 changes: 5 additions & 5 deletions docs/stackit_logs_instance_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ stackit logs instance create [flags]
### Options

```
--acl strings Access control list
--description string Description
--display-name string Display name
-h, --help Help for "stackit logs instance create"
--retention-days int The days for how long the logs should be stored before being cleaned up
--acl strings Access control list
--description string Description
--display-name string Display name
-h, --help Help for "stackit logs instance create"
--retention-days int32 The days for how long the logs should be stored before being cleaned up
```

### Options inherited from parent commands
Expand Down
10 changes: 5 additions & 5 deletions docs/stackit_logs_instance_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ stackit logs instance update INSTANCE_ID [flags]
### Options

```
--acl strings Access control list
--description string Description
--display-name string Display name
-h, --help Help for "stackit logs instance update"
--retention-days int The days for how long the logs should be stored before being cleaned up
--acl strings Access control list
--description string Description
--display-name string Display name
-h, --help Help for "stackit logs instance update"
--retention-days int32 The days for how long the logs should be stored before being cleaned up
```

### 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 @@ -24,7 +24,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0
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/logs v0.10.0
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,8 @@ github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 h1:1dvL7tX9
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0/go.mod h1:+Ld3dn648I+YKcBV3fEkYpDSr3fel421+LurJGywSBs=
github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 h1:csZlzmvAB+klgUQo7AjoGO+YkpdxRFY3yE5Y7SDeB5w=
github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0/go.mod h1:JDOOYaGgcBts2x52nKPRMFgSZe7qqOFmfz1xIXCQgRY=
github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 h1:vr4atxFRT+EL+DqONMT5R44f7AzEMbePa9U7PEE0THU=
github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2/go.mod h1:CAPsiTX7osAImfrG5RnIjaJ/Iz3QpoBKuH2fS346wuQ=
github.com/stackitcloud/stackit-sdk-go/services/logs v0.10.0 h1:g7zpfQFFq3UhAWrMK9rPaZY6dLMAuMJf5g6+r7VRTXc=
github.com/stackitcloud/stackit-sdk-go/services/logs v0.10.0/go.mod h1:tvRejL8w5KpGBbLFPQ+dXOJURgZ3OMbZmwxlKQrGMuA=
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6 h1:Y/byRjX2u/OZl0gKS/Rau6ob2bDyv26xnw6A6JNkKJk=
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6/go.mod h1:sY66ZgCgBc1mScPV95ek5WtUEGYizdP1RMsGaqbdbhw=
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8 h1:S7t4wcT6SN8ZzdoY8d6VbF903zFpGjzqrU0FN27rJPg=
Expand Down
21 changes: 11 additions & 10 deletions internal/cmd/logs/access_token/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

"github.com/stackitcloud/stackit-sdk-go/services/logs"
logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
Expand Down Expand Up @@ -35,7 +35,7 @@ type inputModel struct {
InstanceId string
Description *string
DisplayName string
Lifetime *int64
Lifetime *int32
Permissions []string
}

Expand Down Expand Up @@ -80,7 +80,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
projectLabel = model.ProjectId
}

instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId)
instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
instanceLabel = model.InstanceId
Expand Down Expand Up @@ -110,7 +110,7 @@ func configureFlags(cmd *cobra.Command) {
cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the Logs instance")
cmd.Flags().String(displayNameFlag, "", "Display name for the access token")
cmd.Flags().String(descriptionFlag, "", "Description of the access token")
cmd.Flags().Int64(lifetimeFlag, 0, "Lifetime of the access token in days [1 - 180]")
cmd.Flags().Int32(lifetimeFlag, 0, "Lifetime of the access token in days [1 - 180]")
cmd.Flags().StringSlice(permissionsFlag, []string{}, `Permissions of the access token ["read" "write"]`)

err := flags.MarkFlagsRequired(cmd, instanceIdFlag, displayNameFlag, permissionsFlag)
Expand All @@ -128,7 +128,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
DisplayName: flags.FlagToStringValue(p, cmd, displayNameFlag),
InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag),
Description: flags.FlagToStringPointer(p, cmd, descriptionFlag),
Lifetime: flags.FlagToInt64Pointer(p, cmd, lifetimeFlag),
Lifetime: flags.FlagToInt32Pointer(p, cmd, lifetimeFlag),
Permissions: flags.FlagToStringSliceValue(p, cmd, permissionsFlag),
}

Expand All @@ -137,13 +137,14 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiCreateAccessTokenRequest {
req := apiClient.CreateAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId)

req := apiClient.DefaultAPI.CreateAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId)
return req.CreateAccessTokenPayload(logs.CreateAccessTokenPayload{
Description: model.Description,
DisplayName: &model.DisplayName,
DisplayName: model.DisplayName,
Lifetime: model.Lifetime,
Permissions: &model.Permissions,
Permissions: utils.Map(model.Permissions, func(t string) logs.PermissionsInner {
return logs.PermissionsInner(t)
}),
})
}

Expand All @@ -152,7 +153,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, accessTo
return fmt.Errorf("access token cannot be nil")
}
return p.OutputResult(outputFormat, accessToken, func() error {
p.Outputf("Created access token for Logs instance %q.\n\nID: %s\nToken: %s\n", instanceLabel, utils.PtrValue(accessToken.Id), utils.PtrValue(accessToken.AccessToken))
p.Outputf("Created access token for Logs instance %q.\n\nID: %s\nToken: %s\n", instanceLabel, accessToken.Id, utils.PtrValue(accessToken.AccessToken))
return nil
})
}
41 changes: 21 additions & 20 deletions internal/cmd/logs/access_token/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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/logs"
logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api"
)

const (
Expand All @@ -26,7 +26,7 @@ type testCtxKey struct{}

var (
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
testClient = &logs.APIClient{}
testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}}
testProjectId = uuid.NewString()
testInstanceId = uuid.NewString()
)
Expand Down Expand Up @@ -59,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
InstanceId: testInstanceId,
Description: utils.Ptr(testDescription),
DisplayName: testDisplayName,
Lifetime: utils.Ptr(int64(0)),
Lifetime: utils.Ptr(int32(0)),
Permissions: []string{
"read",
"write",
Expand All @@ -72,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *logs.ApiCreateAccessTokenRequest)) logs.ApiCreateAccessTokenRequest {
request := testClient.CreateAccessToken(testCtx, testProjectId, testRegion, testInstanceId)
request := testClient.DefaultAPI.CreateAccessToken(testCtx, testProjectId, testRegion, testInstanceId)
request = request.CreateAccessTokenPayload(fixturePayload())
for _, mod := range mods {
mod(&request)
Expand All @@ -82,13 +82,13 @@ func fixtureRequest(mods ...func(request *logs.ApiCreateAccessTokenRequest)) log

func fixturePayload(mods ...func(payload *logs.CreateAccessTokenPayload)) logs.CreateAccessTokenPayload {
payload := logs.CreateAccessTokenPayload{
DisplayName: utils.Ptr(testDisplayName),
DisplayName: testDisplayName,
Description: utils.Ptr(testDescription),
Lifetime: utils.Ptr(int64(0)),
Permissions: utils.Ptr([]string{
"read",
"write",
}),
Lifetime: utils.Ptr(int32(0)),
Permissions: []logs.PermissionsInner{
logs.PERMISSIONSINNER_READ,
logs.PERMISSIONSINNER_WRITE,
},
}
for _, mod := range mods {
mod(&payload)
Expand Down Expand Up @@ -215,7 +215,8 @@ func TestBuildRequest(t *testing.T) {

diff := cmp.Diff(tt.expectedRequest, request,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx),
cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}),
cmpopts.EquateEmpty(),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
Expand All @@ -240,16 +241,16 @@ func TestOutputResult(t *testing.T) {
args: args{
instanceLabel: "",
accessToken: utils.Ptr(logs.AccessToken{
Id: utils.Ptr(uuid.NewString()),
Permissions: utils.Ptr([]string{
"read",
"write",
}),
DisplayName: utils.Ptr("Token"),
Id: uuid.NewString(),
Permissions: []logs.PermissionsInner{
Comment thread
j1n-o9r marked this conversation as resolved.
logs.PERMISSIONSINNER_READ,
logs.PERMISSIONSINNER_WRITE,
},
DisplayName: "Token",
AccessToken: utils.Ptr("Secret access token"),
Creator: utils.Ptr(uuid.NewString()),
Expires: utils.Ptr(false),
Status: utils.Ptr(logs.ACCESSTOKENSTATUS_ACTIVE),
Creator: uuid.NewString(),
Expires: false,
Status: logs.ACCESSTOKENSTATUS_ACTIVE,
}),
},
wantErr: false,
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/logs/access_token/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/stackitcloud/stackit-sdk-go/services/logs"
logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api"

"github.com/stackitcloud/stackit-cli/internal/pkg/flags"
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
Expand Down Expand Up @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
}

// Get the display name for confirmation
accessTokenLabel, err := logUtils.GetAccessTokenName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId)
accessTokenLabel, err := logUtils.GetAccessTokenName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get access token: %v", err)
}
Expand Down Expand Up @@ -113,5 +113,5 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiDeleteAccessTokenRequest {
return apiClient.DeleteAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId)
return apiClient.DefaultAPI.DeleteAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId)
}
8 changes: 4 additions & 4 deletions internal/cmd/logs/access_token/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/logs"
logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api"
)

const (
Expand All @@ -21,7 +21,7 @@ type testCtxKey struct{}

var (
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
testClient = &logs.APIClient{}
testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}}

testProjectId = uuid.NewString()
testInstanceId = uuid.NewString()
Expand Down Expand Up @@ -69,7 +69,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *logs.ApiDeleteAccessTokenRequest)) logs.ApiDeleteAccessTokenRequest {
request := testClient.DeleteAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId)
request := testClient.DefaultAPI.DeleteAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -197,7 +197,7 @@ func TestBuildRequest(t *testing.T) {

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx),
cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
Expand Down
14 changes: 6 additions & 8 deletions internal/cmd/logs/access_token/delete_all/delete_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ import (
"context"
"fmt"

"github.com/stackitcloud/stackit-sdk-go/services/logs"
logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api"

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

"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
"github.com/stackitcloud/stackit-cli/internal/pkg/flags"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/client"
logUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/utils"
"github.com/stackitcloud/stackit-cli/internal/pkg/types"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -55,7 +53,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
}

instanceLabel, err := logUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId)
instanceLabel, err := logUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
instanceLabel = model.InstanceId
Expand All @@ -77,7 +75,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return fmt.Errorf("delete all access token: nil result")
}

params.Printer.Outputf("Deleted %d access token(s)\n", len(utils.PtrValue(items.Tokens)))
params.Printer.Outputf("Deleted %d access token(s)\n", len(items.Tokens))
return nil
},
}
Expand Down Expand Up @@ -108,5 +106,5 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiDeleteAllAccessTokensRequest {
return apiClient.DeleteAllAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId)
return apiClient.DefaultAPI.DeleteAllAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/logs"
logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api"
)

const (
Expand All @@ -21,7 +21,7 @@ type testCtxKey struct{}

var (
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
testClient = &logs.APIClient{}
testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}}

testProjectId = uuid.NewString()
testInstanceId = uuid.NewString()
Expand Down Expand Up @@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *logs.ApiDeleteAllAccessTokensRequest)) logs.ApiDeleteAllAccessTokensRequest {
request := testClient.DeleteAllAccessTokens(testCtx, testProjectId, testRegion, testInstanceId)
request := testClient.DefaultAPI.DeleteAllAccessTokens(testCtx, testProjectId, testRegion, testInstanceId)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -153,7 +153,7 @@ func TestBuildRequest(t *testing.T) {

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx),
cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
Expand Down
Loading
Loading