# Path: awscfncli2/runner/commands/command.py
# class Command(object):
#     SKIP_UPDATE_REFERENCES = False
# 
#     def __init__(self, pretty_printer, options):
#         assert isinstance(pretty_printer, StackPrettyPrinter)
#         self.ppt = pretty_printer
#         self.options = options
# 
#     def run(self, stack_context):
#         raise NotImplementedError
# 
# Path: awscfncli2/runner/commands/utils.py
# def update_termination_protection(session,
#                                   termination_protection,
#                                   stack_name,
#                                   ppt):
#     """Update termination protection on a stack"""
# 
#     if termination_protection is None:
#         # don't care, don't change
#         return
# 
#     client = session.client('cloudformation')
# 
#     if termination_protection:
#         ppt.secho('Enabling TerminationProtection')
#     else:
#         ppt.secho('Disabling TerminationProtection', fg='red')
# 
#     client.update_termination_protection(
#         StackName=stack_name,
#         EnableTerminationProtection=termination_protection)
# 
# def is_stack_does_not_exist_exception(ex):
#     """Check whether given exception is "stack does not exist",
#     botocore doesn't throw a distinct exception class in this case.
#     """
#     if isinstance(ex, botocore.exceptions.ClientError):
#         error = ex.response.get('Error', {})
#         error_message = error.get('Message', 'Unknown')
#         return error_message.endswith('does not exist')
#     else:
#         return False


from collections import namedtuple
from .command import Command
from .utils import update_termination_protection, \
    is_stack_does_not_exist_exception



class StackDeleteOptions(namedtuple('StackDeleteOptions',
                                    ['no_wait',
                                     'ignore_missing'])):
    pass


class StackDeleteCommand(Command):
    SKIP_UPDATE_REFERENCES = True

    def run(self, stack_context):
        # stack contexts
        session = stack_context.session
        parameters = stack_context.parameters
        metadata = stack_context.metadata

        self.ppt.pprint_stack_name(stack_context.stack_key,
                                   parameters['StackName'],
                                   'Deleting stack ')

        # create boto3 cfn resource
        cfn = session.resource('cloudformation')
        self.ppt.pprint_session(session)
        self.ppt.pprint_parameters(parameters)

        # call boto3
        stack = cfn.Stack(parameters['StackName'])
        try:

# Path: awscfncli2/runner/commands/command.py
# class Command(object):
#     SKIP_UPDATE_REFERENCES = False
# 
#     def __init__(self, pretty_printer, options):
#         assert isinstance(pretty_printer, StackPrettyPrinter)
#         self.ppt = pretty_printer
#         self.options = options
# 
#     def run(self, stack_context):
#         raise NotImplementedError
# 
# Path: awscfncli2/runner/commands/utils.py
# def update_termination_protection(session,
#                                   termination_protection,
#                                   stack_name,
#                                   ppt):
#     """Update termination protection on a stack"""
# 
#     if termination_protection is None:
#         # don't care, don't change
#         return
# 
#     client = session.client('cloudformation')
# 
#     if termination_protection:
#         ppt.secho('Enabling TerminationProtection')
#     else:
#         ppt.secho('Disabling TerminationProtection', fg='red')
# 
#     client.update_termination_protection(
#         StackName=stack_name,
#         EnableTerminationProtection=termination_protection)
# 
# def is_stack_does_not_exist_exception(ex):
#     """Check whether given exception is "stack does not exist",
#     botocore doesn't throw a distinct exception class in this case.
#     """
#     if isinstance(ex, botocore.exceptions.ClientError):
#         error = ex.response.get('Error', {})
#         error_message = error.get('Message', 'Unknown')
#         return error_message.endswith('does not exist')
#     else:
#         return False


# Path: awscfncli2/runner/commands/stack_delete_command.py
from collections import namedtuple
from .command import Command
from .utils import update_termination_protection, \
    is_stack_does_not_exist_exception




class StackDeleteOptions(namedtuple('StackDeleteOptions',
                                    ['no_wait',
                                     'ignore_missing'])):
    pass


class StackDeleteCommand(Command):
    SKIP_UPDATE_REFERENCES = True

    def run(self, stack_context):
        # stack contexts
        session = stack_context.session
        parameters = stack_context.parameters
        metadata = stack_context.metadata

        self.ppt.pprint_stack_name(stack_context.stack_key,
                                   parameters['StackName'],
                                   'Deleting stack ')

        # create boto3 cfn resource
        cfn = session.resource('cloudformation')
        self.ppt.pprint_session(session)
        self.ppt.pprint_parameters(parameters)

        # call boto3
        stack = cfn.Stack(parameters['StackName'])
        try:

            update_termination_protection(