public async Task <Result> DeleteAsync(Action <UserPermissionsDeleteAction> action, CancellationToken cancellationToken = new CancellationToken()) { cancellationToken.RequestCanceled(LogInfo); var impl = new UserPermissionsDeleteActionImpl(); action(impl); string username = impl.Username.Value; string vhost = impl.VirtualHost.Value; if (string.IsNullOrWhiteSpace(username)) { throw new UserCredentialsMissingException("The username and/or password is missing."); } if (string.IsNullOrWhiteSpace(vhost)) { throw new VirtualHostMissingException("The name of the virtual host is missing."); } string sanitizedVHost = vhost.SanitizeVirtualHostName(); string url = $"api/permissions/{sanitizedVHost}/{username}"; HttpResponseMessage response = await HttpDelete(url, cancellationToken); Result result = response.GetResponse(); LogInfo($"Sent request to RabbitMQ server to create user '{username}'"); return(result); }
public async Task <Result> Delete(Action <UserPermissionsDeleteAction> action, CancellationToken cancellationToken = default) { cancellationToken.RequestCanceled(); var impl = new UserPermissionsDeleteActionImpl(); action(impl); string username = impl.Username.Value; string vhost = impl.VirtualHost.Value; var errors = new List <Error>(); if (string.IsNullOrWhiteSpace(username)) { errors.Add(new ErrorImpl("The username and/or password is missing.")); } if (string.IsNullOrWhiteSpace(vhost)) { errors.Add(new ErrorImpl("The name of the virtual host is missing.")); } if (errors.Any()) { return(new FaultedResult(errors)); } string url = $"api/permissions/{SanitizeVirtualHostName(vhost)}/{username}"; Result result = await Delete(url, cancellationToken); return(result); }
public async Task <Result> Delete(Action <UserPermissionsDeleteAction> action, CancellationToken cancellationToken = default) { cancellationToken.RequestCanceled(); var impl = new UserPermissionsDeleteActionImpl(); action(impl); impl.Validate(); string url = $"api/permissions/{impl.VirtualHost.Value.ToSanitizedName()}/{impl.Username.Value}"; if (impl.Errors.Value.Any()) { return(new FaultedResult(impl.Errors.Value, new DebugInfoImpl(url))); } return(await Delete(url, cancellationToken).ConfigureAwait(false)); }