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 pprint import pprint as pp
23 class ItemOverrideValues(ForemanItem):
25 ItemOverrideValues class
26 Represent the content of a foreman smart class parameter as a dict
29 objName = 'override_values'
30 payloadObj = 'override_value'
32 def __init__(self, api, key, parentName, parentKey, *args, **kwargs):
34 Represent the content of a foreman object as a dict
36 @param api: The foreman api
37 @param key: The object Key
38 @param parentName: The object parent name (eg: smart_class_parameter)
39 @param parentKey: The object parent key
40 @param *args, **kwargs: the dict representation
41 @return RETURN: Itself
43 self.parentName = parentName
44 self.parentKey = parentKey
45 ForemanItem.__init__(self, api, key,
46 self.objName, self.payloadObj,
49 def __setitem__(self, key, attributes):
50 """ Function __setitem__
51 Set a parameter of a foreman object as a dict
53 @param key: The key to modify
54 @param attribute: The data
55 @return RETURN: The API result
57 payload = {self.payloadObj: {key: attributes}}
58 return self.api.set('{}/{}/{}'.format(self.parentName,