/// <summary> /// Deletes the specified topic. /// </summary> /// <param name="topicName">Name of the topic.</param> /// <returns><c>true</c> if deleted, <c>false</c> if not found.</returns> public async Task <bool> DeleteTopic(string topicName) { try { await _publisherServiceApiClient.DeleteTopicAsync(new TopicName(_projectId, topicName)); return(true); } catch (RpcException e) when(e.StatusCode == StatusCode.NotFound) { // If it wasn't found, then do nothing as non-existence was the desired result. return(false); } }
/// <summary>Snippet for DeleteTopicAsync</summary> public async Task DeleteTopicAsync() { // Snippet: DeleteTopicAsync(TopicName,CallSettings) // Additional: DeleteTopicAsync(TopicName,CancellationToken) // Create client PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync(); // Initialize request argument(s) TopicName topic = new TopicName("[PROJECT]", "[TOPIC]"); // Make the request await publisherServiceApiClient.DeleteTopicAsync(topic); // End snippet }
/// <summary>Snippet for DeleteTopicAsync</summary> public async Task DeleteTopicAsync() { // Snippet: DeleteTopicAsync(string, CallSettings) // Additional: DeleteTopicAsync(string, CancellationToken) // Create client PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync(); // Initialize request argument(s) string topic = "projects/[PROJECT]/topics/[TOPIC]"; // Make the request await publisherServiceApiClient.DeleteTopicAsync(topic); // End snippet }
/// <summary>Snippet for DeleteTopicAsync</summary> public async Task DeleteTopicAsync_RequestObject() { // Snippet: DeleteTopicAsync(DeleteTopicRequest,CallSettings) // Create client PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync(); // Initialize request argument(s) DeleteTopicRequest request = new DeleteTopicRequest { TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"), }; // Make the request await publisherServiceApiClient.DeleteTopicAsync(request); // End snippet }
public async Task DeleteTopicAsync() { string projectId = _fixture.ProjectId; string topicId = _fixture.CreateTopicId(); await PublisherServiceApiClient.Create().CreateTopicAsync(new TopicName(projectId, topicId)); // Snippet: DeleteTopicAsync(TopicName,CallSettings) // Additional: DeleteTopicAsync(TopicName,CancellationToken) PublisherServiceApiClient client = PublisherServiceApiClient.Create(); TopicName topicName = new TopicName(projectId, topicId); await client.DeleteTopicAsync(topicName); Console.WriteLine($"Deleted {topicName}"); // End snippet }
public static async Task <bool> DeleteTopic(TopicName topicName) { PublisherServiceApiClient publisherService = await PublisherServiceApiClient.CreateAsync(); try { await publisherService.DeleteTopicAsync(topicName); Console.WriteLine($" => Topic deleted: {topicName}"); return(true); } catch (Exception e) { Console.WriteLine($" => Failed to delete {topicName}. (Error: {e.Message}"); return(false); } }
/// <summary>Snippet for DeleteTopicAsync</summary> public async Task DeleteTopicRequestObjectAsync() { // Snippet: DeleteTopicAsync(DeleteTopicRequest, CallSettings) // Additional: DeleteTopicAsync(DeleteTopicRequest, CancellationToken) // Create client PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync(); // Initialize request argument(s) DeleteTopicRequest request = new DeleteTopicRequest { TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), }; // Make the request await publisherServiceApiClient.DeleteTopicAsync(request); // End snippet }