public async Task <Result> Delete(Action <QueueDeleteAction> action, CancellationToken cancellationToken = default) { cancellationToken.RequestCanceled(); var impl = new QueueDeleteActionImpl(); action(impl); string queue = impl.QueueName.Value; string vhost = impl.VirtualHost.Value; var errors = new List <Error>(); if (string.IsNullOrWhiteSpace(vhost)) { errors.Add(new ErrorImpl("The name of the virtual host is missing.")); } if (string.IsNullOrWhiteSpace(queue)) { errors.Add(new ErrorImpl("The name of the queue is missing.")); } if (errors.Any()) { return(new FaultedResult(errors)); } string url = $"api/queues/{SanitizeVirtualHostName(vhost)}/{queue}"; string query = impl.Query.Value; if (!string.IsNullOrWhiteSpace(query)) { url = $"{url}?{query}"; } Result result = await Delete(url, cancellationToken); return(result); }
public async Task <Result> DeleteAsync(Action <QueueDeleteAction> action, CancellationToken cancellationToken = new CancellationToken()) { cancellationToken.RequestCanceled(LogInfo); var impl = new QueueDeleteActionImpl(); action(impl); string queue = impl.QueueName.Value; string vhost = impl.VirtualHost.Value; if (string.IsNullOrWhiteSpace(queue)) { throw new QueueMissingException("The name of the queue is missing."); } if (string.IsNullOrWhiteSpace(vhost)) { throw new VirtualHostMissingException("The name of the virtual host is missing."); } string sanitizedVHost = vhost.SanitizeVirtualHostName(); string url = $"api/queues/{sanitizedVHost}/{queue}"; string query = impl.Query.Value; if (string.IsNullOrWhiteSpace(query)) { url = $"{url}?{query}"; } HttpResponseMessage response = await HttpDelete(url, cancellationToken); Result result = response.GetResponse(); LogInfo($"Sent request to RabbitMQ server to delete queue '{queue}' from virtual host '{sanitizedVHost}'."); return(result); }
public async Task <Result> Delete(Action <QueueDeleteAction> action, CancellationToken cancellationToken = default) { cancellationToken.RequestCanceled(); var impl = new QueueDeleteActionImpl(); action(impl); impl.Validate(); string url = $"api/queues/{impl.VirtualHost.Value.ToSanitizedName()}/{impl.QueueName.Value}"; if (!string.IsNullOrWhiteSpace(impl.Query.Value)) { url = $"{url}?{impl.Query.Value}"; } if (impl.Errors.Value.Any()) { return(new FaultedResult(impl.Errors.Value, new DebugInfoImpl(url))); } return(await Delete(url, cancellationToken).ConfigureAwait(false)); }