# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command for deleting instances."""

from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import request_helper
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.core.console import console_io

AUTO_DELETE_OVERRIDE_CHOICES = ['boot', 'data', 'all']


class Delete(base_classes.ZonalDeleter):
  """Delete Google Compute Engine virtual machine instances."""

  @staticmethod
  def Args(parser):
    auto_delete_metavar = '{' + ','.join(AUTO_DELETE_OVERRIDE_CHOICES) + '}'

    auto_delete_override = parser.add_mutually_exclusive_group()

    delete_disks = auto_delete_override.add_argument(
        '--delete-disks',
        choices=AUTO_DELETE_OVERRIDE_CHOICES,
        metavar=auto_delete_metavar,
        help=('The types of disks to delete with instance deletion '
              "regardless of the disks' auto-delete configuration."))
    delete_disks.detailed_help = """\
        The types of disks to delete with instance deletion regardless
        of the disks' auto-delete configuration. When this flag is
        provided, the auto-delete bits on the attached disks are
        modified accordingly before the instance deletion requests are
        issued. For more information on disk auto-deletion, see
        link:https://cloud.google.com/compute/docs/disks/persistent-disks#updateautodelete[].
        """

    keep_disks = auto_delete_override.add_argument(
        '--keep-disks',
        choices=AUTO_DELETE_OVERRIDE_CHOICES,
        metavar=auto_delete_metavar,
        help=('The types of disks to not delete with instance deletion '
              "regardless of the disks' auto-delete configuration."))
    keep_disks.detailed_help = """\
        The types of disks to not delete with instance deletion regardless
        of the disks' auto-delete configuration. When this flag is
        provided, the auto-delete bits on the attached disks are
        modified accordingly before the instance deletion requests are
        issued. For more information on disk auto-deletion, see
        link:https://cloud.google.com/compute/docs/disks/persistent-disks#updateautodelete[].
        """