private void DeleteUri()
        {
            var body = new InstanceGroupManagersDeleteInstancesRequest
            {
                Instances = InstanceUri
            };

            if (ShouldProcess("Deleting instances: " + JoinInstanceNames(body.Instances), null,
                              $"Managed Instance Group {Project}/{Zone}/{Name}"))
            {
                InstanceGroupManagersResource.DeleteInstancesRequest request =
                    Service.InstanceGroupManagers.DeleteInstances(body, Project, Zone, Name);
                Operation operation = request.Execute();
                AddZoneOperation(Project, Zone, operation, () =>
                {
                    WriteObject(Service.InstanceGroupManagers.Get(Project, Zone, Name));
                });
            }
        }
        /// <summary>
        /// Deletes the specified instances. The instances are deleted, then removed from the instance group and any target pools of which they were a member. The targetSize of the instance group manager is reduced by the number of instances deleted.
        /// Documentation https://developers.google.com/replicapool/v1beta2/reference/instanceGroupManagers/deleteInstances
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Replicapool service.</param>
        /// <param name="project">The Google Developers Console project name.</param>
        /// <param name="zone">The name of the zone in which the instance group manager resides.</param>
        /// <param name="instanceGroupManager">The name of the instance group manager.</param>
        /// <param name="body">A valid Replicapool v1beta2 body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation DeleteInstances(ReplicapoolService service, string project, string zone, string instanceGroupManager, InstanceGroupManagersDeleteInstancesRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (zone == null)
                {
                    throw new ArgumentNullException(zone);
                }
                if (instanceGroupManager == null)
                {
                    throw new ArgumentNullException(instanceGroupManager);
                }

                // Make the request.
                return(service.InstanceGroupManagers.DeleteInstances(body, project, zone, instanceGroupManager).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request InstanceGroupManagers.DeleteInstances failed.", ex);
            }
        }
 private void DeleteUri()
 {
     var body = new InstanceGroupManagersDeleteInstancesRequest
     {
         Instances = InstanceUri
     };
     if (ShouldProcess("Deleting instances: " + JoinInstanceNames(body.Instances), null,
         $"Managed Instance Group {Project}/{Zone}/{Name}"))
     {
         InstanceGroupManagersResource.DeleteInstancesRequest request =
             Service.InstanceGroupManagers.DeleteInstances(body, Project, Zone, Name);
         Operation operation = request.Execute();
         AddZoneOperation(Project, Zone, operation, () =>
         {
             WriteObject(Service.InstanceGroupManagers.Get(Project, Zone, Name));
         });
     }
 }
Beispiel #4
0
        /// <summary>
        /// Schedules a group action to delete the specified instances in the managed instance group. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method.If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.You can specify a maximum of 1000 instances with this method per request.
        /// Documentation https://developers.google.com/compute/v1/reference/instanceGroupManagers/deleteInstances
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="zone">The name of the zone where the managed instance group is located.</param>
        /// <param name="instanceGroupManager">The name of the managed instance group.</param>
        /// <param name="body">A valid Compute v1 body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation DeleteInstances(ComputeService service, string project, string zone, string instanceGroupManager, InstanceGroupManagersDeleteInstancesRequest body, InstanceGroupManagersDeleteInstancesOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (zone == null)
                {
                    throw new ArgumentNullException(zone);
                }
                if (instanceGroupManager == null)
                {
                    throw new ArgumentNullException(instanceGroupManager);
                }

                // Building the initial request.
                var request = service.InstanceGroupManagers.DeleteInstances(body, project, zone, instanceGroupManager);

                // Applying optional parameters to the request.
                request = (InstanceGroupManagersResource.DeleteInstancesRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request InstanceGroupManagers.DeleteInstances failed.", ex);
            }
        }