namespace AIStudio.Tools.PluginSystem;
///
/// Represents a pending API key that needs to be stored in the OS keyring.
/// This is used during plugin loading to collect API keys from configuration plugins
/// before storing them asynchronously.
///
/// The secret ID (provider ID).
/// The secret name (provider instance name).
/// The decrypted API key.
/// The type of secret store to use.
public sealed record PendingEnterpriseApiKey(
string SecretId,
string SecretName,
string ApiKey,
SecretStoreType StoreType);
///
/// Static container for pending API keys during plugin loading.
///
public static class PendingEnterpriseApiKeys
{
private static readonly List PENDING_KEYS = [];
private static readonly Lock LOCK = new();
///
/// Adds a pending API key to the list.
///
/// The pending API key to add.
public static void Add(PendingEnterpriseApiKey key)
{
lock (LOCK)
PENDING_KEYS.Add(key);
}
///
/// Gets and clears all pending API keys.
///
/// A list of all pending API keys.
public static IReadOnlyList GetAndClear()
{
lock (LOCK)
{
var keys = PENDING_KEYS.ToList();
PENDING_KEYS.Clear();
return keys;
}
}
}