# Path: muranoclient/apiclient/exceptions.py
# class ClientException(Exception):
# class MissingArgs(ClientException):
# class ValidationError(ClientException):
# class UnsupportedVersion(ClientException):
# class CommandError(ClientException):
# class AuthorizationFailure(ClientException):
# class ConnectionRefused(ClientException):
# class AuthPluginOptionsMissing(AuthorizationFailure):
# class AuthSystemNotFound(AuthorizationFailure):
# class NoUniqueMatch(ClientException):
# class EndpointException(ClientException):
# class EndpointNotFound(EndpointException):
# class AmbiguousEndpoints(EndpointException):
# class HttpError(ClientException):
# class HTTPRedirection(HttpError):
# class HTTPClientError(HttpError):
# class HttpServerError(HttpError):
# class MultipleChoices(HTTPRedirection):
# class BadRequest(HTTPClientError):
# class Unauthorized(HTTPClientError):
# class PaymentRequired(HTTPClientError):
# class Forbidden(HTTPClientError):
# class NotFound(HTTPClientError):
# class MethodNotAllowed(HTTPClientError):
# class NotAcceptable(HTTPClientError):
# class ProxyAuthenticationRequired(HTTPClientError):
# class RequestTimeout(HTTPClientError):
# class Conflict(HTTPClientError):
# class Gone(HTTPClientError):
# class LengthRequired(HTTPClientError):
# class PreconditionFailed(HTTPClientError):
# class RequestEntityTooLarge(HTTPClientError):
# class RequestUriTooLong(HTTPClientError):
# class UnsupportedMediaType(HTTPClientError):
# class RequestedRangeNotSatisfiable(HTTPClientError):
# class ExpectationFailed(HTTPClientError):
# class UnprocessableEntity(HTTPClientError):
# class InternalServerError(HttpServerError):
# class HttpNotImplemented(HttpServerError):
# class BadGateway(HttpServerError):
# class ServiceUnavailable(HttpServerError):
# class GatewayTimeout(HttpServerError):
# class HttpVersionNotSupported(HttpServerError):
#     def __init__(self, missing):
#     def __init__(self, opt_names):
#     def __init__(self, auth_system):
#     def __init__(self, endpoints=None):
#     def __init__(self, message=None, details=None,
#                  response=None, request_id=None,
#                  url=None, method=None, http_status=None):
#     def __init__(self, *args, **kwargs):
# def from_response(response, url, method):
# 
# Path: muranoclient/common/utils.py
# LOG = logging.getLogger(__name__)
# def arg(*args, **kwargs):
#     def _decorator(func):
# def json_formatter(js):
# def text_wrap_formatter(d):
# def pretty_choice_list(l):
# def print_list(objs, fields, field_labels, formatters=None, sortby=0):
# def print_dict(d, formatters=None):
# def find_resource(manager, name_or_id, *args, **kwargs):
# def string_to_bool(arg):
# def env(*vars, **kwargs):
# def exit(msg=''):
# def getsockopt(self, *args, **kwargs):
# def exception_to_str(exc):
#     def __init__(self, obj):
#     def close(self):
#     def __getattr__(self, name):
#     def __init__(self, name, binary=True):
#     def open(self):
# def to_url(filename, base_url, version='', path='/', extension=''):
#     def __init__(self, file_wrapper):
#     def file(self):
#     def close(self):
#     def save(self, dst, binary=True):
#     def __del__(self):
#     def from_file(file_obj):
#     def fromFile(file_obj):
#     def from_location(name, base_url='', version='', url='', path=None):
#     def validate(self):
#     def contents(self):
#     def manifest(self):
#     def images(self):
#     def resolvers(self):
#     def classes(self):
#     def ui(self):
#     def logo(self):
#     def _get_package_order(self, packages_graph):
#         def topological_sort(graph, start_node):
#             def dfs(node):
#         def transpose_graph(graph):
#         def top_sort_by_components(graph, component_order):
#             def dfs(node):
#     def requirements(self, base_url, path=None, dep_dict=None):
#     def _get_direct_deps(package, base_url, path):
# def save_image_local(image_spec, base_url, dst):
# def ensure_images(glance_client, image_specs, base_url,
#                   local_path=None,
#                   is_package_public=False):
#     def _image_valid(image, keys):
#     def from_file(file_obj):
#     def fromFile(file_obj):
#     def package_specs(self):
#     def packages(self, base_url='', path=None):
# def yaql_constructor(loader, node):
# def traverse_and_replace(obj,
#                          pattern=re.compile(r'^===id(\d+)===$'),
#                          replacements=None):
#     def _maybe_replace(obj, key, value):
#     def __init__(self, namespaces):
#     def resolve_name(self, name, relative=None):
# class NoCloseProxy(object):
# class File(object):
# class FileWrapperMixin(object):
# class Package(FileWrapperMixin):
# class Bundle(FileWrapperMixin):
# class DummyYaqlYamlLoader(yaml.SafeLoader):
# class YaqlYamlLoader(yaml.SafeLoader):
# class NamespaceResolver(object):


import json
import sys
import urllib
import jsonpatch
from osc_lib.command import command
from osc_lib import utils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from muranoclient.apiclient import exceptions
from muranoclient.common import utils as murano_utils

class EnvironmentDelete(command.Lister):
    """Delete an environment."""

    def get_parser(self, prog_name):
        parser = super(EnvironmentDelete, self).get_parser(prog_name)
        parser.add_argument(
            'id',
            metavar="<NAME or ID>",
            nargs="+",
            help="Id or name of environment(s) to delete.",
        )
        parser.add_argument(
            '--abandon',
            action='store_true',
            default=False,
            help="If set will abandon environment without deleting any of its"
                 " resources.",
        )

        return parser

    def take_action(self, parsed_args):
        LOG.debug("take_action({0})".format(parsed_args))
        client = self.app.client_manager.application_catalog

        abandon = getattr(parsed_args, 'abandon', False)
        failure_count = 0
        for environment_id in parsed_args.id:
            try:

# Path: muranoclient/apiclient/exceptions.py
# class ClientException(Exception):
# class MissingArgs(ClientException):
# class ValidationError(ClientException):
# class UnsupportedVersion(ClientException):
# class CommandError(ClientException):
# class AuthorizationFailure(ClientException):
# class ConnectionRefused(ClientException):
# class AuthPluginOptionsMissing(AuthorizationFailure):
# class AuthSystemNotFound(AuthorizationFailure):
# class NoUniqueMatch(ClientException):
# class EndpointException(ClientException):
# class EndpointNotFound(EndpointException):
# class AmbiguousEndpoints(EndpointException):
# class HttpError(ClientException):
# class HTTPRedirection(HttpError):
# class HTTPClientError(HttpError):
# class HttpServerError(HttpError):
# class MultipleChoices(HTTPRedirection):
# class BadRequest(HTTPClientError):
# class Unauthorized(HTTPClientError):
# class PaymentRequired(HTTPClientError):
# class Forbidden(HTTPClientError):
# class NotFound(HTTPClientError):
# class MethodNotAllowed(HTTPClientError):
# class NotAcceptable(HTTPClientError):
# class ProxyAuthenticationRequired(HTTPClientError):
# class RequestTimeout(HTTPClientError):
# class Conflict(HTTPClientError):
# class Gone(HTTPClientError):
# class LengthRequired(HTTPClientError):
# class PreconditionFailed(HTTPClientError):
# class RequestEntityTooLarge(HTTPClientError):
# class RequestUriTooLong(HTTPClientError):
# class UnsupportedMediaType(HTTPClientError):
# class RequestedRangeNotSatisfiable(HTTPClientError):
# class ExpectationFailed(HTTPClientError):
# class UnprocessableEntity(HTTPClientError):
# class InternalServerError(HttpServerError):
# class HttpNotImplemented(HttpServerError):
# class BadGateway(HttpServerError):
# class ServiceUnavailable(HttpServerError):
# class GatewayTimeout(HttpServerError):
# class HttpVersionNotSupported(HttpServerError):
#     def __init__(self, missing):
#     def __init__(self, opt_names):
#     def __init__(self, auth_system):
#     def __init__(self, endpoints=None):
#     def __init__(self, message=None, details=None,
#                  response=None, request_id=None,
#                  url=None, method=None, http_status=None):
#     def __init__(self, *args, **kwargs):
# def from_response(response, url, method):
# 
# Path: muranoclient/common/utils.py
# LOG = logging.getLogger(__name__)
# def arg(*args, **kwargs):
#     def _decorator(func):
# def json_formatter(js):
# def text_wrap_formatter(d):
# def pretty_choice_list(l):
# def print_list(objs, fields, field_labels, formatters=None, sortby=0):
# def print_dict(d, formatters=None):
# def find_resource(manager, name_or_id, *args, **kwargs):
# def string_to_bool(arg):
# def env(*vars, **kwargs):
# def exit(msg=''):
# def getsockopt(self, *args, **kwargs):
# def exception_to_str(exc):
#     def __init__(self, obj):
#     def close(self):
#     def __getattr__(self, name):
#     def __init__(self, name, binary=True):
#     def open(self):
# def to_url(filename, base_url, version='', path='/', extension=''):
#     def __init__(self, file_wrapper):
#     def file(self):
#     def close(self):
#     def save(self, dst, binary=True):
#     def __del__(self):
#     def from_file(file_obj):
#     def fromFile(file_obj):
#     def from_location(name, base_url='', version='', url='', path=None):
#     def validate(self):
#     def contents(self):
#     def manifest(self):
#     def images(self):
#     def resolvers(self):
#     def classes(self):
#     def ui(self):
#     def logo(self):
#     def _get_package_order(self, packages_graph):
#         def topological_sort(graph, start_node):
#             def dfs(node):
#         def transpose_graph(graph):
#         def top_sort_by_components(graph, component_order):
#             def dfs(node):
#     def requirements(self, base_url, path=None, dep_dict=None):
#     def _get_direct_deps(package, base_url, path):
# def save_image_local(image_spec, base_url, dst):
# def ensure_images(glance_client, image_specs, base_url,
#                   local_path=None,
#                   is_package_public=False):
#     def _image_valid(image, keys):
#     def from_file(file_obj):
#     def fromFile(file_obj):
#     def package_specs(self):
#     def packages(self, base_url='', path=None):
# def yaql_constructor(loader, node):
# def traverse_and_replace(obj,
#                          pattern=re.compile(r'^===id(\d+)===$'),
#                          replacements=None):
#     def _maybe_replace(obj, key, value):
#     def __init__(self, namespaces):
#     def resolve_name(self, name, relative=None):
# class NoCloseProxy(object):
# class File(object):
# class FileWrapperMixin(object):
# class Package(FileWrapperMixin):
# class Bundle(FileWrapperMixin):
# class DummyYaqlYamlLoader(yaml.SafeLoader):
# class YaqlYamlLoader(yaml.SafeLoader):
# class NamespaceResolver(object):


# Path: muranoclient/osc/v1/environment.py
import json
import sys
import urllib
import jsonpatch
from osc_lib.command import command
from osc_lib import utils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from muranoclient.apiclient import exceptions
from muranoclient.common import utils as murano_utils


class EnvironmentDelete(command.Lister):
    """Delete an environment."""

    def get_parser(self, prog_name):
        parser = super(EnvironmentDelete, self).get_parser(prog_name)
        parser.add_argument(
            'id',
            metavar="<NAME or ID>",
            nargs="+",
            help="Id or name of environment(s) to delete.",
        )
        parser.add_argument(
            '--abandon',
            action='store_true',
            default=False,
            help="If set will abandon environment without deleting any of its"
                 " resources.",
        )

        return parser

    def take_action(self, parsed_args):
        LOG.debug("take_action({0})".format(parsed_args))
        client = self.app.client_manager.application_catalog

        abandon = getattr(parsed_args, 'abandon', False)
        failure_count = 0
        for environment_id in parsed_args.id:
            try:

                environment = murano_utils.find_resource(client.environments,