public async Task DeleteAsync(Srn srn) { // TODO: need to find out how to get version if (!srn.HasNamespace()) { throw new SrnException("Performing a mount point reset is not yet supported."); } await ExecuteVaultContext(async() => { await _engine.DestroySecretAsync(GetKeyPath(srn), new List <int> { 0 }, _mountPoint); return(Task.CompletedTask); }); }
public async Task DeleteAsync(Srn srn) { if (!srn.HasKey()) { // we're deleting the namespace itself _cache.Remove(srn.Namespace); _watcher.EnableRaisingEvents = false; File.Delete(BuildPath(srn.Namespace)); _watcher.EnableRaisingEvents = true; return; } await SetAsync(srn, null); }
public async Task <dynamic> GetAsync(Srn srn) { if (!srn.HasNamespace()) { // Retrieve all namespaces return(Directory.GetFiles(_servicePath).Select(Path.GetFileNameWithoutExtension)); } var obj = await GetCacheDictAsync(srn.Namespace); if (!srn.HasKey()) { return(obj); } return(obj?[srn.Key]); }
public async Task <dynamic> GetAsync(Srn srn) { return(await ExecuteVaultContext(async() => { // List all namespaces if (!srn.HasNamespace()) { return (await _engine.ReadSecretPathsAsync("/", _mountPoint))?.Data.Keys; } // List all keys in namespace (non-recursive, though!) if (!srn.HasKey()) { return (await _engine.ReadSecretPathsAsync($"/{srn.Namespace}", _mountPoint))?.Data.Keys; } return (await _engine.ReadSecretAsync(GetKeyPath(srn), null, _mountPoint))?.Data.Data; })); }
public async Task SetAsync(Srn srn, dynamic value) { if (!srn.HasNamespace() || !srn.HasKey()) { throw new Exception("Setting namespaces directly is not supported."); } var obj = await GetCacheDictAsync(srn.Namespace, true); if (obj == null) { return; } obj[srn.Key] = value; // Save the JSON file. _watcher.EnableRaisingEvents = false; await File.WriteAllTextAsync(BuildPath(srn.Namespace), JsonConvert.SerializeObject(obj)); _watcher.EnableRaisingEvents = true; }
private static string GetKeyPath(Srn srn) => $"{srn.Namespace}/{srn.Key.Replace('.', '/')}";
public async Task SetAsync(Srn srn, dynamic value) { srn.ThrowIfNotFullyQualified(); await ExecuteVaultContext(async() => await _engine.WriteSecretAsync(GetKeyPath(srn), value, null, _mountPoint)); }
public async Task DeleteAsync(Srn srn, string provider = "default") => await srn.ToNamespace(this).DeleteAsync(srn.Key, provider);
public async Task SetAsync(Srn srn, dynamic value, string provider = "default") => await srn.ToNamespace(this).SetAsync(srn.Key, value, provider);
public async Task <dynamic> GetAsync(Srn srn, IList <string> providers) => await srn.ToNamespace(this).GetAsync(srn.Key, providers);
public async Task <dynamic> GetAsync(Srn srn, string provider = "any") => await srn.ToNamespace(this).GetAsync(srn.Key, provider);