Files
python-congressclient/congressclient/osc/v1/api_versions.py
Rui Chen f9858a8106 Support version list API in client
The Congress API should be able to list
current supported API versions. This patch
implement the feature in congress client side.

Change-Id: I9d089411640161ea5220a32f078f8c4eb87be1b7
Implements: blueprint api-version
2015-07-27 15:19:04 +08:00

41 lines
1.3 KiB
Python

# Copyright 2015 Huawei.
# 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.
"""List API versions implemenations"""
import logging
from cliff import lister
from congressclient.common import utils
class ListAPIVersions(lister.Lister):
"""List API Versions."""
log = logging.getLogger(__name__ + '.ListAPIVersions')
def get_parser(self, prog_name):
return super(ListAPIVersions, self).get_parser(prog_name)
def take_action(self, parsed_args):
client = self.app.client_manager.congressclient
data = client.list_api_versions()['versions']
# sort API by id
data.sort(key=lambda item: item.get('id'))
columns = ['id', 'status', 'updated']
return (columns,
(utils.get_dict_properties(s, columns) for s in data))