Skip to content

Commit

Permalink
Add user preferences feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanclark committed Jun 28, 2023
1 parent 73cfb29 commit 2cba5a8
Show file tree
Hide file tree
Showing 37 changed files with 2,229 additions and 52 deletions.
27 changes: 24 additions & 3 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import (
pluginspb "github.com/gravitational/teleport/api/gen/proto/go/teleport/plugins/v1"
samlidppb "github.com/gravitational/teleport/api/gen/proto/go/teleport/samlidp/v1"
trustpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/trust/v1"
userpreferencespb "github.com/gravitational/teleport/api/gen/proto/go/userpreferences/v1"
"github.com/gravitational/teleport/api/internalutils/stream"
"github.com/gravitational/teleport/api/metadata"
"github.com/gravitational/teleport/api/observability/tracing"
Expand All @@ -79,6 +80,7 @@ type AuthServiceClient struct {
proto.AuthServiceClient
assist.AssistServiceClient
auditlogpb.AuditLogServiceClient
userpreferencespb.UserPreferencesServiceClient
}

// Client is a gRPC Client that connects to a Teleport Auth server either
Expand Down Expand Up @@ -470,9 +472,10 @@ func (c *Client) dialGRPC(ctx context.Context, addr string) error {

c.conn = conn
c.grpc = AuthServiceClient{
AuthServiceClient: proto.NewAuthServiceClient(c.conn),
AssistServiceClient: assist.NewAssistServiceClient(c.conn),
AuditLogServiceClient: auditlogpb.NewAuditLogServiceClient(c.conn),
AuthServiceClient: proto.NewAuthServiceClient(c.conn),
AssistServiceClient: assist.NewAssistServiceClient(c.conn),
AuditLogServiceClient: auditlogpb.NewAuditLogServiceClient(c.conn),
UserPreferencesServiceClient: userpreferencespb.NewUserPreferencesServiceClient(c.conn),
}
c.JoinServiceClient = NewJoinServiceClient(proto.NewJoinServiceClient(c.conn))

Expand Down Expand Up @@ -3980,3 +3983,21 @@ func (c *Client) GetAssistantEmbeddings(ctx context.Context, in *assist.GetAssis
}
return result, nil
}

// GetUserPreferences returns the user preferences for a given user.
func (c *Client) GetUserPreferences(ctx context.Context, in *userpreferencespb.GetUserPreferencesRequest) (*userpreferencespb.UserPreferences, error) {
resp, err := c.grpc.GetUserPreferences(ctx, in)
if err != nil {
return nil, trail.FromGRPC(err)
}
return resp, nil
}

// UpsertUserPreferences creates or updates user preferences for a given username.
func (c *Client) UpsertUserPreferences(ctx context.Context, in *userpreferencespb.UpsertUserPreferencesRequest) error {
_, err := c.grpc.UpsertUserPreferences(ctx, in)
if err != nil {
return trail.FromGRPC(err)
}
return nil
}
258 changes: 258 additions & 0 deletions api/gen/proto/go/userpreferences/v1/assist.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2cba5a8

Please sign in to comment.