Merge "Remove Compass from genesis."
[genesis.git] / opensteak / tools / opensteak / foreman_objects / itemSmartClassParameter.py
1 #!/usr/bin/python3
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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
13 # under the License.
14 #
15 # Authors:
16 # @author: David Blaisonneau <david.blaisonneau@orange.com>
17 # @author: Arnaud Morin <arnaud1.morin@orange.com>
18
19
20 from opensteak.foreman_objects.item import ForemanItem
21 from opensteak.foreman_objects.itemOverrideValues import ItemOverrideValues
22
23
24 class ItemSmartClassParameter(ForemanItem):
25     """
26     ItemSmartClassParameter class
27     Represent the content of a foreman smart class parameter as a dict
28     """
29
30     objName = 'smart_class_parameters'
31     payloadObj = 'smart_class_parameter'
32
33     def __init__(self, api, key, *args, **kwargs):
34         """ Function __init__
35         Represent the content of a foreman object as a dict
36
37         @param api: The foreman api
38         @param key: The object Key
39         @param *args, **kwargs: the dict representation
40         @return RETURN: Itself
41         """
42         ForemanItem.__init__(self, api, key,
43                              self.objName, self.payloadObj,
44                              *args, **kwargs)
45         self.update({'override_values':
46             list(map(lambda x: ItemOverrideValues(self.api,
47                                                   x['id'],
48                                                   self.objName,
49                                                   key,
50                                                   x),
51                  self['override_values']))})
52
53     def __setitem__(self, key, attributes):
54         """ Function __setitem__
55         Set a parameter of a foreman object as a dict
56
57         @param key: The key to modify
58         @param attribute: The data
59         @return RETURN: The API result
60         """
61         payload = {self.payloadObj: {key: attributes}}
62         return self.api.set(self.objName, self.key, payload)