Skip to content

Commit

Permalink
Expose Account Assignmnets via cache (#49567)
Browse files Browse the repository at this point in the history
Extends cache to allow consumers to fetch a specific Identity Center account
assignment, rather than just listing them.
  • Loading branch information
tcsc authored Dec 2, 2024
1 parent 7a1bfee commit 0885806
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/auth/authclient/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,9 @@ type Cache interface {
// GetProvisioningState gets a specific provisioning state
GetProvisioningState(context.Context, services.DownstreamID, services.ProvisioningStateID) (*provisioningv1.PrincipalState, error)

// GetAccountAssignment fetches specific IdentityCenter Account Assignment
GetAccountAssignment(context.Context, services.IdentityCenterAccountAssignmentID) (services.IdentityCenterAccountAssignment, error)

// ListAccountAssignments fetches a paginated list of IdentityCenter Account Assignments
ListAccountAssignments(context.Context, int, *pagination.PageRequestToken) ([]services.IdentityCenterAccountAssignment, pagination.NextPageToken, error)
}
Expand Down
13 changes: 13 additions & 0 deletions lib/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3560,6 +3560,19 @@ func (c *Cache) GetProvisioningState(ctx context.Context, downstream services.Do
return rg.reader.GetProvisioningState(ctx, downstream, id)
}

func (c *Cache) GetAccountAssignment(ctx context.Context, id services.IdentityCenterAccountAssignmentID) (services.IdentityCenterAccountAssignment, error) {
ctx, span := c.Tracer.Start(ctx, "cache/GetAccountAssignment")
defer span.End()

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

return rg.reader.GetAccountAssignment(ctx, 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")
Expand Down

0 comments on commit 0885806

Please sign in to comment.