Skip to content

Commit

Permalink
Exposes Identity Center Account Assignment listing on Cache interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tcsc committed Nov 8, 2024
1 parent 32b403e commit adacfc7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/auth/authclient/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/gravitational/teleport/api/types/discoveryconfig"
"github.com/gravitational/teleport/lib/events"
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/utils/pagination"
)

// Announcer specifies interface responsible for announcing presence
Expand Down Expand Up @@ -1235,6 +1236,9 @@ type Cache interface {

// GetProvisioningState gets a specific provisioning state
GetProvisioningState(context.Context, services.DownstreamID, services.ProvisioningStateID) (*provisioningv1.PrincipalState, error)

// ListAccountAssignments fetches a paginated list of IdentityCenter Account Assignments
ListAccountAssignments(context.Context, int, *pagination.PageRequestToken) ([]services.IdentityCenterAccountAssignment, pagination.NextPageToken, error)
}

type NodeWrapper struct {
Expand Down
15 changes: 15 additions & 0 deletions lib/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import (
"github.com/gravitational/teleport/lib/services/simple"
"github.com/gravitational/teleport/lib/utils"
"github.com/gravitational/teleport/lib/utils/interval"
"github.com/gravitational/teleport/lib/utils/pagination"
)

var (
Expand Down Expand Up @@ -3558,3 +3559,17 @@ func (c *Cache) GetProvisioningState(ctx context.Context, downstream services.Do

return rg.reader.GetProvisioningState(ctx, downstream, id)
}

// ListAccountAssignments fetches a paginated list of IdentityCenter Account Assignments
func (c *Cache) ListAccountAssignments(ctx context.Context, pageSize int, pageToken *pagination.PageRequestToken) ([]services.IdentityCenterAccountAssignment, pagination.NextPageToken, error) {
ctx, span := c.Tracer.Start(ctx, "cache/ListAccountAssignments")
defer span.End()

rg, err := readCollectionCache(c, c.collections.identityCenterAccountAssignments)
if err != nil {
return nil, "", trace.Wrap(err)
}
defer rg.Release()

return rg.reader.ListAccountAssignments(ctx, pageSize, pageToken)
}

0 comments on commit adacfc7

Please sign in to comment.