diff --git a/lib/auth/authclient/api.go b/lib/auth/authclient/api.go index 2fb3153441ebd..932d78a383505 100644 --- a/lib/auth/authclient/api.go +++ b/lib/auth/authclient/api.go @@ -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 @@ -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 { diff --git a/lib/cache/cache.go b/lib/cache/cache.go index 3a3894ee6686e..8602447ace828 100644 --- a/lib/cache/cache.go +++ b/lib/cache/cache.go @@ -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 ( @@ -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) +}