2 # -------------------------------------------------------------------------
3 # Copyright (C) 2020 Wipro Limited.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # -------------------------------------------------------------------------
20 class Candidate(object):
21 def __init__(self, info):
22 self.candidate_id = info.get('candidate_id')
23 if info.get('candidate_type'):
24 self.candidate_type = info.get('candidate_type')
25 if info.get('service_resource_id'):
26 self.service_resource_id = info.get('service_resource_id')
27 self.inventory_provider = info.get('inventory_provider')
28 self.inventory_type = info.get('inventory_type')
29 self.uniqueness = info.get('uniqueness')
30 self.cost = info.get('cost')
32 def convert_nested_dict_to_dict(self):
34 nested_dict = self.__dict__
35 keys = nested_dict.keys()
37 if type(nested_dict.get(key)) == dict:
38 candidate.update(nested_dict.get(key, {}))
40 candidate[key] = nested_dict.get(key, "")
44 def build_candidate_info(inv_prov, inv_type, cost, uniqueness, id, service_resource_id=None):
46 info['candidate_id'] = id
47 # info['candidate_type']
48 info['inventory_provider'] = inv_prov
49 info['inventory_type'] = inv_type
50 info['uniqueness'] = uniqueness
52 info['service_resource_id'] = service_resource_id