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;
}
}
}
///
/// Represents a pending enterprise secret that needs to be stored in the OS keyring.
///
/// The secret ID.
/// The secret name.
/// The decrypted secret data.
public sealed record PendingEnterpriseSecret(
string SecretId,
string SecretName,
string SecretData);
///
/// Static container for pending enterprise secrets during plugin loading.
///
public static class PendingEnterpriseSecrets
{
private static readonly List PENDING_SECRETS = [];
private static readonly Lock LOCK = new();
///
/// Adds a pending enterprise secret to the list.
///
/// The pending enterprise secret to add.
public static void Add(PendingEnterpriseSecret secret)
{
lock (LOCK)
PENDING_SECRETS.Add(secret);
}
///
/// Gets and clears all pending enterprise secrets.
///
/// A list of all pending enterprise secrets.
public static IReadOnlyList GetAndClear()
{
lock (LOCK)
{
var secrets = PENDING_SECRETS.ToList();
PENDING_SECRETS.Clear();
return secrets;
}
}
}