- ignore rollback errors
[plcapi.git] / PLC / Methods / GetAttributes.py
1 from PLC.Method import Method
2 from PLC.Parameter import Parameter, Mixed
3 from PLC.Auth import PasswordAuth
4 from PLC.Attributes import Attribute, Attributes
5
6 class GetAttributes(Method):
7     """
8     Return an array of structs containing details about all possible
9     slice and node attributes. If attribute_id_or_name_list is
10     specified, only the specified attributes will be queried.
11     """
12
13     roles = ['admin', 'pi', 'user', 'tech']
14
15     accepts = [
16         PasswordAuth(),
17         [Mixed(Attribute.fields['attribute_id'],
18                Attribute.fields['name'])],
19         ]
20
21     returns = [Attribute.fields]
22
23     def call(self, auth, attribute_id_or_name_list = None):
24         # Get slice attribute information
25         attributes = Attributes(self.api, attribute_id_or_name_list).values()
26         
27         # Turn each attribute into a real dict.
28         attributes = [dict(attribute) for attribute in attributes]
29
30         return attributes