def Run(self, args):
        self._UpdateDefaultOutputFormatForGracefulValidation(args)

        holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
        client = holder.client

        resource_arg = instance_groups_flags.MULTISCOPE_INSTANCE_GROUP_MANAGER_ARG
        default_scope = compute_scope.ScopeEnum.ZONE
        scope_lister = flags.GetDefaultScopeLister(client)
        igm_ref = resource_arg.ResolveAsResource(args,
                                                 holder.resources,
                                                 default_scope=default_scope,
                                                 scope_lister=scope_lister)

        if igm_ref.Collection() == 'compute.instanceGroupManagers':
            instances_holder_field = 'instanceGroupManagersDeleteInstancesRequest'
            request = self._CreateZonalIgmDeleteInstancesRequest(
                client.messages, igm_ref, args)
        elif igm_ref.Collection() == 'compute.regionInstanceGroupManagers':
            instances_holder_field = 'regionInstanceGroupManagersDeleteInstancesRequest'
            request = self._CreateRegionalIgmDeleteInstancesRequest(
                client.messages, igm_ref, args)
        else:
            raise ValueError('Unknown reference type {0}'.format(
                igm_ref.Collection()))

        return instance_groups_utils.SendInstancesRequestsAndPostProcessOutputs(
            api_holder=holder,
            method_name='DeleteInstances',
            request_template=request,
            instances_holder_field=instances_holder_field,
            igm_ref=igm_ref,
            instances=args.instances,
            per_instance_status_enabled=True)
  def Run(self, args):
    holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
    client = holder.client
    igm_ref = (instance_groups_flags.MULTISCOPE_INSTANCE_GROUP_MANAGER_ARG
               .ResolveAsResource)(
                   args,
                   holder.resources,
                   default_scope=compute_scope.ScopeEnum.ZONE,
                   scope_lister=flags.GetDefaultScopeLister(client))

    update_instances_utils.ValidateIgmReference(igm_ref)

    if igm_ref.Collection() == 'compute.instanceGroupManagers':
      minimal_action = update_instances_utils.ParseInstanceActionFlag(
          '--minimal-action', args.minimal_action or 'none',
          client.messages.InstanceGroupManagersApplyUpdatesRequest
          .MinimalActionValueValuesEnum)
      most_disruptive_allowed_action = (
          update_instances_utils.ParseInstanceActionFlag)(
              '--most-disruptive-allowed-action',
              args.most_disruptive_allowed_action or 'replace',
              client.messages.InstanceGroupManagersApplyUpdatesRequest
              .MostDisruptiveAllowedActionValueValuesEnum)
      instances_holder_field = 'instanceGroupManagersApplyUpdatesRequest'
      request = self._CreateZonalApplyUpdatesRequest(
          igm_ref, minimal_action, most_disruptive_allowed_action, client)
    elif igm_ref.Collection() == 'compute.regionInstanceGroupManagers':
      minimal_action = update_instances_utils.ParseInstanceActionFlag(
          '--minimal-action', args.minimal_action or 'none',
          client.messages.RegionInstanceGroupManagersApplyUpdatesRequest
          .MinimalActionValueValuesEnum)
      most_disruptive_allowed_action = (
          update_instances_utils.ParseInstanceActionFlag)(
              '--most-disruptive-allowed-action',
              args.most_disruptive_allowed_action or 'replace',
              client.messages.RegionInstanceGroupManagersApplyUpdatesRequest
              .MostDisruptiveAllowedActionValueValuesEnum)
      instances_holder_field = 'regionInstanceGroupManagersApplyUpdatesRequest'
      request = self._CreateRegionalApplyUpdatesRequest(
          igm_ref, minimal_action, most_disruptive_allowed_action, client)
    else:
      raise ValueError('Unknown reference type {0}'.format(
          igm_ref.Collection()))

    if args.all_instances:
      return instance_groups_utils.SendAllInstancesRequest(
          api_holder=holder,
          method_name='ApplyUpdatesToInstances',
          request_template=request,
          all_instances_holder_field=instances_holder_field,
          igm_ref=igm_ref)
    else:
      return instance_groups_utils.SendInstancesRequestsAndPostProcessOutputs(
          api_holder=holder,
          method_name='ApplyUpdatesToInstances',
          request_template=request,
          instances_holder_field=instances_holder_field,
          igm_ref=igm_ref,
          instances=args.instances)
    def Run(self, args):
        holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
        client = holder.client

        resource_arg = instance_groups_flags.MULTISCOPE_INSTANCE_GROUP_MANAGER_ARG
        default_scope = compute_scope.ScopeEnum.ZONE
        scope_lister = flags.GetDefaultScopeLister(client)
        igm_ref = resource_arg.ResolveAsResource(args,
                                                 holder.resources,
                                                 default_scope=default_scope,
                                                 scope_lister=scope_lister)

        if igm_ref.Collection() == 'compute.instanceGroupManagers':
            instances_holder_field = 'instanceGroupManagersSuspendInstancesRequest'
            request = client.messages.ComputeInstanceGroupManagersSuspendInstancesRequest(
                instanceGroupManager=igm_ref.Name(),
                instanceGroupManagersSuspendInstancesRequest=client.messages.
                InstanceGroupManagersSuspendInstancesRequest(instances=[]),
                project=igm_ref.project,
                zone=igm_ref.zone)
        elif igm_ref.Collection() == 'compute.regionInstanceGroupManagers':
            instances_holder_field = 'regionInstanceGroupManagersSuspendInstancesRequest'
            request = client.messages.ComputeRegionInstanceGroupManagersSuspendInstancesRequest(
                instanceGroupManager=igm_ref.Name(),
                regionInstanceGroupManagersSuspendInstancesRequest=client.
                messages.RegionInstanceGroupManagersSuspendInstancesRequest(
                    instances=[]),
                project=igm_ref.project,
                region=igm_ref.region,
            )
        else:
            raise ValueError('Unknown reference type {0}'.format(
                igm_ref.Collection()))

        if args.IsSpecified('force'):
            if igm_ref.Collection() == 'compute.instanceGroupManagers':
                request.instanceGroupManagersSuspendInstancesRequest.forceSuspend = args.force
            else:
                request.regionInstanceGroupManagersSuspendInstancesRequest.forceSuspend = args.force

        return instance_groups_utils.SendInstancesRequestsAndPostProcessOutputs(
            api_holder=holder,
            method_name='SuspendInstances',
            request_template=request,
            instances_holder_field=instances_holder_field,
            igm_ref=igm_ref,
            instances=args.instances)