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 <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; }