public static string ToCollectionName(this VaultUriCollection ve) { switch (ve) { case VaultUriCollection.Keys: return("keys"); case VaultUriCollection.Secrets: return("secrets"); case VaultUriCollection.Certificates: return("certificates"); default: throw new ArgumentException($"Invalid VaultEndpoint {ve}"); } }
public VaultUriBase(Regex uriRegex, string uriString) : base(uriString?.Replace(@"\", "/")) { Guard.ArgumentNotNull(uriRegex, nameof(uriRegex)); Guard.ArgumentNotNullOrEmptyString(uriString, nameof(uriString)); var m = uriRegex.Match(ToString()); if (false == m.Success) { throw new ArgumentException($"Invalid vault URI {uriString}, URI must satisfy the following regex: {uriRegex}", nameof(uriString)); } VaultName = m.Groups["VaultName"].Value; VaultUriCollection vuc; Enum.TryParse(m.Groups["Collection"].Value, true, out vuc); Collection = vuc; ItemName = m.Groups["Name"].Value; Version = string.IsNullOrEmpty(m.Groups["Version"].Value) ? null : m.Groups["Version"].Value; }