public Task DeleteTopicAsync(string topicName) { if (string.IsNullOrWhiteSpace(topicName)) { throw new ArgumentException($"A non-null/empty '{topicName}' is required.", nameof(topicName)); } return(deleteTopicAsync()); async Task deleteTopicAsync() { var topic = await _sns.FindTopicAsync(topicName); if (topic == null) { throw new InvalidOperationException($"A topic having name '{topicName}' does not exist."); } var response = await _sns.DeleteTopicAsync(topic.TopicArn); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new InvalidOperationException($"Unable to delete topic '{topicName}'."); } } }
async Task ClientContext.DeleteTopic(Topic topic) { var topicArn = await CreateTopic(topic).ConfigureAwait(false); var response = await _amazonSns.DeleteTopicAsync(topicArn).ConfigureAwait(false); EnsureSuccessfulResponse(response); }
public static async Task Delete(IAmazonSimpleNotificationService sns, string topicArn) { await Console.Out.WriteLineAsync($"Deleting topic with ARN '{topicArn}'."); await sns.DeleteTopicAsync(topicArn).ConfigureAwait(false); await Console.Out.WriteLineAsync($"Deleted topic with ARN '{topicArn}'."); }
private static async Task DeleteTopicIfExists(IAmazonSimpleNotificationService client, string topicName) { var matchingTopic = await GetExistingTopic(client, topicName); if (matchingTopic != null) { await client.DeleteTopicAsync(matchingTopic.TopicArn); } }
async Task ClientContext.DeleteTopic(Topology.Entities.Topic topic) { var topicArn = await CreateTopic(topic).ConfigureAwait(false); TransportLogMessages.DeleteTopic(topicArn); var response = await _amazonSns.DeleteTopicAsync(topicArn, _cancellationToken).ConfigureAwait(false); EnsureSuccessfulResponse(response); }
protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) { _snsClient.UnsubscribeAsync(_subscriptionArn).GetAwaiter().GetResult(); _snsClient.DeleteTopicAsync(_topicArn).GetAwaiter().GetResult(); _amazonSQS.DeleteQueueAsync(_queueUrl).GetAwaiter().GetResult(); _disposed = true; } }
async Task ClientContext.DeleteTopic(Topology.Entities.Topic topic) { var topicInfo = await _topicCache.Get(topic, _cancellationToken).ConfigureAwait(false); TransportLogMessages.DeleteTopic(topicInfo.Arn); var response = await _amazonSns.DeleteTopicAsync(topicInfo.Arn, _cancellationToken).ConfigureAwait(false); response.EnsureSuccessfulResponse(); _topicCache.RemoveByName(topic.EntityName); }
public static async Task DeleteAllTopicsWithPrefix(IAmazonSimpleNotificationService snsClient, string topicNamePrefix) { var deletedTopicArns = new HashSet <string>(StringComparer.Ordinal); try { ListTopicsResponse upToHundredTopics = null; do { upToHundredTopics = await snsClient.ListTopicsAsync(upToHundredTopics?.NextToken); // if everything returned here has already been deleted it is probably a good time to stop trying due to the eventual consistency if (upToHundredTopics.Topics.All(topic => deletedTopicArns.Contains(topic.TopicArn))) { return; } var deletionTasks = new List <Task>(upToHundredTopics.Topics.Count); deletionTasks.AddRange(upToHundredTopics.Topics .Where(topic => !deletedTopicArns.Contains(topic.TopicArn)) .Select(async topic => { if (!topic.TopicArn.Contains($":{topicNamePrefix}")) { return; } try { await snsClient.DeleteTopicAsync(topic.TopicArn).ConfigureAwait(false); deletedTopicArns.Add(topic.TopicArn); } catch (Exception) { Console.WriteLine($"Unable to delete topic '{topic.TopicArn}'"); } })); await Task.WhenAll(deletionTasks).ConfigureAwait(false); } while (upToHundredTopics.NextToken != null && upToHundredTopics.Topics.Count > 0); } catch (Exception) { Console.WriteLine($"Unable to delete topics with prefix '{topicNamePrefix}'"); } }
public async Task DeleteSnsTopic(IAmazonSimpleNotificationService snsClient, string topicArn) { try { Console.WriteLine("Deleting SNS Topic"); await snsClient.DeleteTopicAsync( new DeleteTopicRequest() { TopicArn = topicArn }); Console.WriteLine($"SNS Topic deletion success: {topicArn}"); } catch (Exception e) { Console.WriteLine($"SNS Topic deletion failed: {e}"); //do not throw exception here, because we want subsequent cleanups to run } }
private Amazon.SimpleNotificationService.Model.DeleteTopicResponse CallAWSServiceOperation(IAmazonSimpleNotificationService client, Amazon.SimpleNotificationService.Model.DeleteTopicRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Notification Service (SNS)", "DeleteTopic"); try { #if DESKTOP return(client.DeleteTopic(request)); #elif CORECLR return(client.DeleteTopicAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
private Task DeleteTopic(string topicArn) { return(_snsClient.DeleteTopicAsync(topicArn)); }
protected override void PostAssertTeardown() { Bus.DeleteTopicAsync(CreatedTopic.Arn).Wait(); base.PostAssertTeardown(); }
public async Task DeleteTopic(string topicName) { var topicArn = await GetTopic(topicName).ConfigureAwait(false); await _amazonSns.DeleteTopicAsync(topicArn).ConfigureAwait(false); }
async Task ClientContext.DeleteTopic(string topicName) { var topicArn = await CreateTopic(topicName).ConfigureAwait(false); await _amazonSns.DeleteTopicAsync(topicArn).ConfigureAwait(false); }