f9ea7466d097f3f47774081268e7cc3d9ad0d1a6
[plcapi.git] / PLC / Methods / AddRole.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Roles import Role, Roles
5 from PLC.Auth import Auth
6
7 class AddRole(Method):
8     """
9     Adds a new role.
10
11     Returns 1 if successful, faults otherwise.
12     """
13
14     roles = ['admin']
15
16     accepts = [
17         Auth(),
18         Role.fields['name']
19         ]
20
21     returns = Parameter(int, '1 if successful')
22
23
24     def call(self, auth, name):
25         role = Roles(self.api, {'name': name})
26         role.sync(insert=True)
27         #self.api.client_shell.keystone.roles.create(name=name) 
28         return 1