blob: a8890d579961ca2ef5fb9689e37b4345fd5eff61 [file] [log] [blame]
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +03001from keystonev3.common import send
2from keystonev3.arg_converter import get_by_name_or_uuid_multiple
3try:
4 from urllib.parse import urlencode
5except ImportError:
6 from urllib import urlencode
7
8
9@get_by_name_or_uuid_multiple([('domain', 'domain_id')])
10@send('post')
11def group_create(domain_id, name, **kwargs):
12 url = '/groups'
13 json = {
14 'group':{
15 'name': name,
16 'domain_id': domain_id,
17 }
18 }
19 json['group'].update(kwargs)
20 return url, json
21
22
23@get_by_name_or_uuid_multiple([('group', 'group_id')])
24@send('get')
25def group_get_details(group_id, **kwargs):
26 url = '/groups/{}'.format(group_id)
27 return url, None
28
29
30@get_by_name_or_uuid_multiple([('group', 'group_id')])
31@send('patch')
32def group_update(group_id, **kwargs):
33 url = '/groups/{}'.format(group_id)
34 json = {
35 'group': kwargs,
36 }
37 return url, json
38
39
40@get_by_name_or_uuid_multiple([('group', 'group_id')])
41@send('delete')
42def group_delete(group_id, **kwargs):
43 url = '/groups/{}'.format(group_id)
44 return url, None
45
46@get_by_name_or_uuid_multiple([('group', 'group_id')])
47@send('get')
48def group_user_list(group_id, **kwargs):
49 url = '/groups/{}?{}'.format(group_id, urlencode(kwargs))
50 return url, None
51
52
53@get_by_name_or_uuid_multiple([('group', 'group_id'), ('user', 'user_id')])
54@send('put')
55def group_user_add(group_id, user_id, **kwargs):
56 url = '/groups/{}/users/{}'.format(group_id, user_id)
57 return url, None
58
59
60@get_by_name_or_uuid_multiple([('group', 'group_id'), ('user', 'user_id')])
61@send('head')
62def group_user_check(group_id, user_id, **kwargs):
63 url = '/groups/{}/users/{}'.format(group_id, user_id)
64 return url, None
65
66
67@get_by_name_or_uuid_multiple([('group', 'group_id'), ('user', 'user_id')])
68@send('delete')
69def group_user_remove(group_id, user_id, **kwargs):
70 url = '/groups/{}/users/{}'.format(group_id, user_id)
71 return url, None