/// <summary> /// /// <para>DeleteAllFilePubSubNotifications:</para> /// /// <para>Deletes all file pub/sub notifications for a bucket/topic</para> /// /// <para>Parameters:</para> /// <para><paramref name="_BucketName"/> Name of the Bucket</para> /// <para><paramref name="_TopicName"/> Optional topic name to be pushed; if null; all will be deleted</para> /// <para><paramref name="_ErrorMessageAction"/> Error messages will be pushed to this action</para> /// /// <returns> Returns: Operation success </returns> /// /// </summary> public bool DeleteAllFilePubSubNotifications( string _BucketName, string _TopicName = null, Action <string> _ErrorMessageAction = null) { if (_TopicName != null) { _TopicName = "//pubsub.googleapis.com/projects/" + ProjectID + "/topics/" + _TopicName; } try { var Created = GSClient.ListNotifications(_BucketName); if (Created == null || Created.Count == 0) { return(true); } foreach (var Current in Created) { if (_TopicName == null || Current.Topic == _TopicName) { //Async cannot be used to run in parallel; throws "The project exceeded the rate limit for creating and deleting buckets" GSClient.DeleteNotification(_BucketName, Current.Id); } } } catch (Exception e) { _ErrorMessageAction?.Invoke("BFileServiceGC->DeleteAllFilePubSubNotifications: " + e.Message + ", trace: " + e.StackTrace); return(false); } return(true); }
public void DeleteNotification() { var projectId = _fixture.ProjectId; string bucket = _fixture.BucketName; var notificationId = _fixture.CreateNotification("prefix3").Id; // Snippet: DeleteNotification(string, string, *) StorageClient client = StorageClient.Create(); client.DeleteNotification(bucket, notificationId); // End snippet }