Exemplo n.º 1
0
 /// <summary>
 /// Deletes a subscription
 /// </summary>
 /// <param name="subscriptionFullName">The full name of the subscription to delete.</param>
 public async Task DeleteSubscriptionAsync(string subscriptionFullName)
 {
     try
     {
         ProjectsResource.SubscriptionsResource.DeleteRequest request =
             Service.Projects.Subscriptions.Delete(subscriptionFullName);
         await request.ExecuteAsync();
     }
     catch (GoogleApiException e)
     {
         throw new DataSourceException(e.Message, e);
     }
 }
Exemplo n.º 2
0
 protected override void ProcessRecord()
 {
     foreach (string subscriptionName in Subscription)
     {
         string formattedSubscription = GetProjectPrefixForSubscription(subscriptionName, Project);
         try
         {
             if (ShouldProcess(formattedSubscription, "Remove Subscription"))
             {
                 ProjectsResource.SubscriptionsResource.DeleteRequest request = Service.Projects.Subscriptions.Delete(formattedSubscription);
                 request.Execute();
             }
         }
         catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound)
         {
             WriteResourceMissingError(
                 exceptionMessage: $"Subscription '{subscriptionName}' does not exist in project '{Project}'.",
                 errorId: "SubscriptionNotFound",
                 targetObject: subscriptionName);
         }
     }
 }