# Path: raxcli/models.py
# class Collection(object):
#     """
#     A collection of resources for outputting to a list.
#     """
#     def __init__(self, objs):
#         self.objs = objs
# 
#     def generate_output(self):
#         columns = []
#         data = []
#         for obj in self.objs:
#             if not columns:
#                 columns = [attr for attr, _ in
#                            obj.get_attrs(view_type='view_list')]
# 
#             values = []
#             for key in columns:
#                 attr = getattr(obj, key)
#                 value = attr.get_value()
#                 values.append(value)
# 
#             data.append(values)
# 
#         return (columns, data)
# 
# Path: raxcli/commands.py
# class BaseListCommand(BaseCommand, Lister):
#     def get_parser(self, prog_name):
#         parser = super(BaseListCommand, self).get_parser(prog_name=prog_name)
#         return parser
# 
#     @property
#     def formatter_default(self):
#         return 'paginated_table'
# 
# Path: raxcli/apps/loadbalancer/resources.py
# class Balancer(Model):
#     id = Attribute()
#     name = Attribute()
#     state = Attribute(transform_func=state_to_string)
#     ip = Attribute()
#     port = Attribute()
# 
# Path: raxcli/apps/loadbalancer/utils.py
# class LoadBalancerCommand(BaseCommand):
#     def get_parser(self, prog_name):
#         parser = super(LoadBalancerCommand, self).\
#             get_parser(prog_name=prog_name)
#         parser.add_argument('--auth-url', dest='auth_url')
#         parser.add_argument('--region', dest='region')
#         return parser
# 
# Path: raxcli/apps/loadbalancer/utils.py
# def for_all_regions(action_func, parsed_args):
#     return base_get_all_regions(get_client_func=get_client,
#                                 catalog_entry=SERVICE_CATALOG_ENTRY_NAME,
#                                 action_func=action_func,
#                                 parsed_args=parsed_args)


import logging
from raxcli.models import Collection
from raxcli.commands import BaseListCommand
from raxcli.apps.loadbalancer.resources import Balancer
from raxcli.apps.loadbalancer.utils import LoadBalancerCommand
from raxcli.apps.loadbalancer.utils import for_all_regions
# Copyright 2013 Rackspace
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.




class ListCommand(LoadBalancerCommand, BaseListCommand):
    """
    Output Balancers list.
    """
    log = logging.getLogger(__name__)

    def take_action(self, parsed_args):
        def get_balancers(client):
            return [Balancer(b) for b in client.list_balancers()]


# Path: raxcli/models.py
# class Collection(object):
#     """
#     A collection of resources for outputting to a list.
#     """
#     def __init__(self, objs):
#         self.objs = objs
# 
#     def generate_output(self):
#         columns = []
#         data = []
#         for obj in self.objs:
#             if not columns:
#                 columns = [attr for attr, _ in
#                            obj.get_attrs(view_type='view_list')]
# 
#             values = []
#             for key in columns:
#                 attr = getattr(obj, key)
#                 value = attr.get_value()
#                 values.append(value)
# 
#             data.append(values)
# 
#         return (columns, data)
# 
# Path: raxcli/commands.py
# class BaseListCommand(BaseCommand, Lister):
#     def get_parser(self, prog_name):
#         parser = super(BaseListCommand, self).get_parser(prog_name=prog_name)
#         return parser
# 
#     @property
#     def formatter_default(self):
#         return 'paginated_table'
# 
# Path: raxcli/apps/loadbalancer/resources.py
# class Balancer(Model):
#     id = Attribute()
#     name = Attribute()
#     state = Attribute(transform_func=state_to_string)
#     ip = Attribute()
#     port = Attribute()
# 
# Path: raxcli/apps/loadbalancer/utils.py
# class LoadBalancerCommand(BaseCommand):
#     def get_parser(self, prog_name):
#         parser = super(LoadBalancerCommand, self).\
#             get_parser(prog_name=prog_name)
#         parser.add_argument('--auth-url', dest='auth_url')
#         parser.add_argument('--region', dest='region')
#         return parser
# 
# Path: raxcli/apps/loadbalancer/utils.py
# def for_all_regions(action_func, parsed_args):
#     return base_get_all_regions(get_client_func=get_client,
#                                 catalog_entry=SERVICE_CATALOG_ENTRY_NAME,
#                                 action_func=action_func,
#                                 parsed_args=parsed_args)


# Path: raxcli/apps/loadbalancer/commands/balancers/list.py
import logging
from raxcli.models import Collection
from raxcli.commands import BaseListCommand
from raxcli.apps.loadbalancer.resources import Balancer
from raxcli.apps.loadbalancer.utils import LoadBalancerCommand
from raxcli.apps.loadbalancer.utils import for_all_regions

# Copyright 2013 Rackspace
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.




class ListCommand(LoadBalancerCommand, BaseListCommand):
    """
    Output Balancers list.
    """
    log = logging.getLogger(__name__)

    def take_action(self, parsed_args):
        def get_balancers(client):
            return [Balancer(b) for b in client.list_balancers()]


        balancers = for_all_regions(action_func=get_balancers,