Table of Contents

Interface IApiKeyRepository

Namespace
Tharga.Team.Service
Assembly
Tharga.Team.Service.dll

Repository interface for API key persistence. Auto-registered by Tharga.MongoDB.

public interface IApiKeyRepository : IRepository

Methods

AddAsync(ApiKeyEntity)

Persists a new API key entity and returns it.

Task<ApiKeyEntity> AddAsync(ApiKeyEntity apiKeyEntity)

Parameters

apiKeyEntity ApiKeyEntity

Returns

Task<ApiKeyEntity>

CleanLegacyTagsAsync()

One-time migration: removes the legacy Tags field from documents where it is still stored as a BSON document (the pre-#75 Dictionary<string,string> representation). Runs server-side and returns the number of documents cleaned. Safe to run repeatedly. Reading is already tolerant of the legacy shape; this just purges it permanently.

Task<long> CleanLegacyTagsAsync()

Returns

Task<long>

DeleteAsync(string)

Deletes the API key entity with the specified key.

Task DeleteAsync(string key)

Parameters

key string

Returns

Task

GetAsync()

Returns all stored API key entities.

IAsyncEnumerable<ApiKeyEntity> GetAsync()

Returns

IAsyncEnumerable<ApiKeyEntity>

GetAsync(string)

Returns the API key entity with the specified key, or null if not found.

Task<ApiKeyEntity> GetAsync(string key)

Parameters

key string

Returns

Task<ApiKeyEntity>

GetByPrefixAsync(string)

Returns API key entities matching the given prefix.

IAsyncEnumerable<ApiKeyEntity> GetByPrefixAsync(string prefix)

Parameters

prefix string

Returns

IAsyncEnumerable<ApiKeyEntity>

LockKeyAsync(string)

Marks the API key as locked so it cannot be used.

Task LockKeyAsync(string key)

Parameters

key string

Returns

Task

PurgeExpiredAsync()

Deletes all expired API key entities.

Task PurgeExpiredAsync()

Returns

Task

SetDisabledAsync(string, DateTime?, string)

Marks the key disabled, or clears the mark when disabledAtUtc is null. A disabled key is refused at authentication.

Task SetDisabledAsync(string key, DateTime? disabledAtUtc, string disabledBy)

Parameters

key string
disabledAtUtc DateTime?
disabledBy string

Returns

Task

SetLastUsedAsync(string, DateTime)

Sets the "last used" timestamp for the key via a targeted field update (no full-document replace).

Task SetLastUsedAsync(string key, DateTime lastUsedAtUtc)

Parameters

key string
lastUsedAtUtc DateTime

Returns

Task

UpdateAsync(string, ApiKeyEntity)

Replaces the API key entity identified by the given key.

Task UpdateAsync(string key, ApiKeyEntity apiKeyEntity)

Parameters

key string
apiKeyEntity ApiKeyEntity

Returns

Task