<filename>otcextensions/osclient/dws/v1/tag.py
#   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.
#
'''DWS cluster v1 implementations'''
import logging

from osc_lib import utils
from osc_lib.command import command
from otcextensions.common import sdk_utils

from otcextensions.i18n import _

LOG = logging.getLogger(__name__)


def _flatten_output(obj):
    data = {
        'key': obj.mkey,
        'value': obj.mvalue,
    }
    return data


def _get_columns(item):
    column_map = {
    }
    return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map)


class Tags(command.Lister):
    _description = _('Show tags of a DWS cluster')
    columns = (
        'key',
        'value',
    )

    table_columns = (
        'key',
        'value',
    )

    def get_parser(self, prog_name):
        parser = super(Tags, self).get_parser(prog_name)
        parser.add_argument(
            'cluster',
            metavar='<cluster>',
            # default='system',
            help=_('Cluster name (currently only `system`)')
        )
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.dws

        data = client.tags(
            clusterid=parsed_args.cluster,
        )

        table = (self.columns,
                 (utils.get_dict_properties(
                     _flatten_output(s), self.columns
                 ) for s in data))
        return table

        display_columns = self.table_columns
        data = utils.get_item_properties(data, self.columns)

        return display_columns, data

<filename>otcextensions/osclient/dws/v1/tag.py
#   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.
#
'''DWS cluster v1 implementations'''
import logging

from osc_lib import utils
from osc_lib.command import command
from otcextensions.common import sdk_utils

from otcextensions.i18n import _

LOG = logging.getLogger(__name__)


def _flatten_output(obj):
    data = {
        'key': obj.mkey,
        'value': obj.mvalue,
    }
    return data


def _get_columns(item):
    column_map = {
    }
    return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map)


class Tags(command.Lister):
    _description = _('Show tags of a DWS cluster')
    columns = (
        'key',
        'value',
    )

    table_columns = (
        'key',
        'value',
    )

    def get_parser(self, prog_name):
        parser = super(Tags, self).get_parser(prog_name)
        parser.add_argument(
            'cluster',
            metavar='<cluster>',
            # default='system',
            help=_('Cluster name (currently only `system`)')
        )
        return parser

    def take_action(self, parsed_args):
        client = self.app.client_manager.dws

        data = client.tags(
            clusterid=parsed_args.cluster,
        )

        table = (self.columns,
                 (utils.get_dict_properties(
                     _flatten_output(s), self.columns
                 ) for s in data))
        return table

        display_columns = self.table_columns
        data = utils.get_item_properties(data, self.columns)

        return display_columns, data

#   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. # DWS cluster v1 implementations # default='system',