/// <summary> /// Deletes a topic. /// </summary> /// <param name="topicFullName">The full name of the topic.</param> public async Task DeleteTopicAsync(string topicFullName) { try { ProjectsResource.TopicsResource.DeleteRequest request = Service.Projects.Topics.Delete(topicFullName); await request.ExecuteAsync(); } catch (GoogleApiException e) { throw new DataSourceException(e.Message, e); } }
protected override void ProcessRecord() { foreach (string topicName in Topic) { string formattedTopicName = GetProjectPrefixForTopic(topicName, Project); try { if (ShouldProcess(formattedTopicName, "Remove Topic")) { ProjectsResource.TopicsResource.DeleteRequest request = Service.Projects.Topics.Delete(formattedTopicName); request.Execute(); } } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { WriteResourceMissingError( exceptionMessage: $"Topic '{topicName}' does not exist in project '{Project}'.", errorId: "TopicNotFound", targetObject: topicName); } } }