2 # -*- coding: utf-8 -*-
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
16 # @author: David Blaisonneau <david.blaisonneau@orange.com>
17 # @author: Arnaud Morin <arnaud1.morin@orange.com>
20 from opensteak.foreman_objects.item import ForemanItem
21 from opensteak.foreman_objects.itemOverrideValues import ItemOverrideValues
24 class ItemSmartClassParameter(ForemanItem):
26 ItemSmartClassParameter class
27 Represent the content of a foreman smart class parameter as a dict
30 objName = 'smart_class_parameters'
31 payloadObj = 'smart_class_parameter'
33 def __init__(self, api, key, *args, **kwargs):
35 Represent the content of a foreman object as a dict
37 @param api: The foreman api
38 @param key: The object Key
39 @param *args, **kwargs: the dict representation
40 @return RETURN: Itself
42 ForemanItem.__init__(self, api, key,
43 self.objName, self.payloadObj,
45 self.update({'override_values':
46 list(map(lambda x: ItemOverrideValues(self.api,
51 self['override_values']))})
53 def __setitem__(self, key, attributes):
54 """ Function __setitem__
55 Set a parameter of a foreman object as a dict
57 @param key: The key to modify
58 @param attribute: The data
59 @return RETURN: The API result
61 payload = {self.payloadObj: {key: attributes}}
62 return self.api.set(self.objName, self.key, payload)