48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
# 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.
|
|
|
|
import copy
|
|
|
|
import otc_metadata.data
|
|
|
|
__all__ = ['Services']
|
|
|
|
BUILTIN_DATA = otc_metadata.data.read_data('services.yaml')
|
|
|
|
|
|
def _normalize_type(service_type):
|
|
if service_type:
|
|
return service_type.replace('_', '-')
|
|
|
|
|
|
class Services(object):
|
|
"""Encapsulation of the OTC Services data
|
|
"""
|
|
|
|
def __init__(self):
|
|
self._service_data = BUILTIN_DATA
|
|
|
|
@property
|
|
def all_services(self):
|
|
"Service Categories data listing."
|
|
return copy.deepcopy(self._service_data['services'])
|
|
|
|
def services_by_category(self, category):
|
|
"""List services matching category
|
|
"""
|
|
res = []
|
|
for srv in self.all_services:
|
|
if srv['service_category'] == category:
|
|
res.append(copy.deepcopy(srv))
|
|
return res
|