/// <summary> /// Retrieves the SecretCacheVersion corresponding to the Version Stage /// specified by the SecretCacheConfiguration. /// </summary> private SecretCacheVersion GetVersion(DescribeSecretResponse describeResult) { if (null == describeResult?.VersionIdsToStages) { return(null); } String currentVersionId = null; foreach (KeyValuePair <String, List <String> > entry in describeResult.VersionIdsToStages) { if (entry.Value.Contains(config.VersionStage)) { currentVersionId = entry.Key; break; } } if (currentVersionId != null) { SecretCacheVersion version = versions.Get <SecretCacheVersion>(currentVersionId); if (null == version) { version = versions.Set(currentVersionId, new SecretCacheVersion(secretId, currentVersionId, client, config)); if (versions.Count > MAX_VERSIONS_CACHE_SIZE) { TrimCacheToSizeLimit(); } } return(version); } return(null); }
/// <summary> /// Asynchronously retrieves the GetSecretValueResponse from the proper SecretCacheVersion. /// </summary> protected override async Task <GetSecretValueResponse> GetSecretValueAsync(DescribeSecretResponse result) { SecretCacheVersion version = GetVersion(result); if (version == null) { return(null); } return(await version.GetSecretValue()); }