Skip to content

Commit

Permalink
Add policies to client initialization and create policy listing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkb-code committed Sep 5, 2024
1 parent b01147a commit da5efca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
10 changes: 10 additions & 0 deletions acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ func TestRolesList(t *testing.T) {
fmt.Printf("%#v\n", role)
}
}

func TestPoliciesList(t *testing.T) {
policies, err := initClient(t).Policies.List(context.Background())
require.NoError(t, err)
require.NotEmpty(t, policies)

for _, policy := range policies {
fmt.Printf("%#v\n", policy)
}
}
35 changes: 18 additions & 17 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import (
type Client struct {
Collections *ResourceClient[Collection, string]
CustomTranslations *ResourceClient[CustomTranslation, string]
Dashboards *ResourceClient[Dashboard, string]
Files *ResourceClient[File, string]
Flows *ResourceClient[Flow, string]
Folders *ResourceClient[Folder, string]
Roles *ResourceClient[Role, string]
Users *ResourceClient[User, string]
Presets *ResourceClient[Preset, int64]
Operations *ResourceClient[Operation, string]
Flows *ResourceClient[Flow, string]
Files *ResourceClient[File, string]
Permissions *ResourceClient[Permission, int64]
Dashboards *ResourceClient[Dashboard, string]
Panels *ResourceClient[Panel, string]
Permissions *ResourceClient[Permission, int64]
Policies *ResourceClient[Policy, string]
Relations *clientRelations
Presets *ResourceClient[Preset, int64]
Roles *ResourceClient[Role, string]
Users *ResourceClient[User, string]
Fields *clientFields
Settings *clientSettings
Relations *clientRelations
Server *clientServer
Settings *clientSettings

instance, token string
logger *slog.Logger
Expand Down Expand Up @@ -65,20 +65,21 @@ func NewClient(instance string, token string, opts ...ClientOption) *Client {

client.Collections = NewResourceClient[Collection, string](client, "collections")
client.CustomTranslations = NewResourceClient[CustomTranslation, string](client, "translations")
client.Dashboards = NewResourceClient[Dashboard, string](client, "dashboards")
client.Files = NewResourceClient[File, string](client, "files")
client.Flows = NewResourceClient[Flow, string](client, "flows")
client.Folders = NewResourceClient[Folder, string](client, "folders")
client.Roles = NewResourceClient[Role, string](client, "roles")
client.Users = NewResourceClient[User, string](client, "users")
client.Presets = NewResourceClient[Preset, int64](client, "presets")
client.Operations = NewResourceClient[Operation, string](client, "operations")
client.Flows = NewResourceClient[Flow, string](client, "flows")
client.Files = NewResourceClient[File, string](client, "files")
client.Permissions = NewResourceClient[Permission, int64](client, "permissions")
client.Dashboards = NewResourceClient[Dashboard, string](client, "dashboards")
client.Panels = NewResourceClient[Panel, string](client, "panels")
client.Permissions = NewResourceClient[Permission, int64](client, "permissions")
client.Policies = NewResourceClient[Policy, string](client, "policies")
client.Presets = NewResourceClient[Preset, int64](client, "presets")
client.Roles = NewResourceClient[Role, string](client, "roles")
client.Users = NewResourceClient[User, string](client, "users")
client.Fields = &clientFields{client: client}
client.Relations = &clientRelations{client: client}
client.Settings = &clientSettings{client: client}
client.Server = &clientServer{client: client}
client.Settings = &clientSettings{client: client}

return client
}
Expand Down

0 comments on commit da5efca

Please sign in to comment.