blob: 3f6c06aecf88a1e86c9cc261b8b5c8617565b2eb [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
3
Vasyl Saienko4eda4f22018-04-26 19:30:39 +03004
5try:
6 from urllib.parse import urlencode
7except ImportError:
8 from urllib import urlencode
9
10
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030011@get_by_name_or_uuid_multiple([('project', 'project_id'), ('user', 'user_id'),
12 ('role', 'role_id')])
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030013@send('put')
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030014def role_assign_for_user_on_project(project_id, user_id, role_id, **kwargs):
15 url = '/projects/{}/users/{}/roles/{}'.format(project_id, user_id, role_id)
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030016 return url, None
17
18
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030019@get_by_name_or_uuid_multiple([('domain', 'domain_id'), ('user', 'user_id'),
20 ('role', 'role_id')])
21@send('put')
22def role_assign_for_user_on_domain(domain_id, user_id, role_id, **kwargs):
23 url = '/domains/{}/users/{}/roles/{}'.format(domain_id, user_id, role_id)
24 return url, None
25
26
27@get_by_name_or_uuid_multiple([('project', 'project_id'), ('user', 'user_id'),
28 ('role', 'role_id')])
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030029@send('delete')
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030030def role_unassign_for_user_on_project(project_id, user_id, role_id, **kwargs):
31 url = '/projects/{}/users/{}/roles/{}'.format(project_id, user_id, role_id)
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030032 return url, None
33
34
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030035@get_by_name_or_uuid_multiple([('domain', 'domain_id'), ('user', 'user_id'),
36 ('role', 'role_id')])
37@send('delete')
38def role_unassign_for_user_on_domain(domain_id, user_id, role_id, **kwargs):
39 url = '/domains/{}/users/{}/roles/{}'.format(domain_id, user_id, role_id)
40 return url, None
41
42
43@get_by_name_or_uuid_multiple([('project', 'project_id'), ('user', 'user_id'),
44 ('role', 'role_id')])
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030045@send('head')
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030046def role_assign_check_for_user_on_project(project_id, user_id, role_id,
47 **kwargs):
48 url = '/projects/{}/users/{}/roles/{}'.format(project_id, user_id, role_id)
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030049 return url, None
50
51
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030052@get_by_name_or_uuid_multiple([('domain', 'domain_id'), ('user', 'user_id'),
53 ('role', 'role_id')])
54@send('head')
55def role_assign_check_for_user_on_domain(domain_id, user_id, role_id,
56 **kwargs):
57 url = '/domains/{}/users/{}/roles/{}'.format(domain_id, user_id, role_id)
58 return url, None
59
60
61@get_by_name_or_uuid_multiple([('role', 'role_id')])
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030062@send('get')
63def role_get_details(role_id, **kwargs):
64 url = '/roles/{}?{}'.format(role_id, urlencode(kwargs))
65 return url, None
66
67
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030068@get_by_name_or_uuid_multiple([('role', 'role_id')])
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030069@send('patch')
70def role_update(role_id, **kwargs):
71 url = '/roles/{}'.format(role_id)
72 json = {
73 'role': kwargs,
74 }
75 return url, json
76
77
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030078@get_by_name_or_uuid_multiple([('role', 'role_id')])
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030079@send('delete')
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030080def role_delete(role_id, **kwargs):
Vasyl Saienko4eda4f22018-04-26 19:30:39 +030081 url = '/roles/{}'.format(role_id)
82 return url, None
83
84
85@send('post')
86def role_create(**kwargs):
87 url = '/roles'
88 json = {
89 'role': kwargs,
90 }
91 return url, json
Oleksiy Petrenkoe03e2c72018-08-10 13:24:32 +030092
93
94@get_by_name_or_uuid_multiple([('role', 'prior_role_id')])
95@send('get')
96def role_inference_rule_for_role_list(prior_role_id, **kwargs):
97 url = '/roles/{}/implies'.format(prior_role_id)
98 return url, None
99
100
101@get_by_name_or_uuid_multiple([('role', 'prior_role_id'),
102 ('role', 'implies_role_id')])
103@send('put')
104def role_inference_rule_create(prior_role_id, implies_role_id, **kwargs):
105 url = '/roles/{}/implies/{}'.format(prior_role_id, implies_role_id)
106 return url, None
107
108
109@get_by_name_or_uuid_multiple([('role', 'prior_role_id'),
110 ('role', 'implies_role_id')])
111@send('get')
112def role_inference_rule_get(prior_role_id, implies_role_id, **kwargs):
113 url = '/roles/{}/implies/{}'.format(prior_role_id, implies_role_id)
114 return url, None
115
116
117@get_by_name_or_uuid_multiple([('role', 'prior_role_id'),
118 ('role', 'implies_role_id')])
119@send('head')
120def role_inference_rule_confirm(prior_role_id, implies_role_id, **kwargs):
121 url = '/roles/{}/implies/{}'.format(prior_role_id, implies_role_id)
122 return url, None
123
124
125@get_by_name_or_uuid_multiple([('role', 'prior_role_id'),
126 ('role', 'implies_role_id')])
127@send('delete')
128def role_inference_rule_delete(prior_role_id, implies_role_id, **kwargs):
129 url = '/roles/{}/implies/{}'.format(prior_role_id, implies_role_id)
130 return url, None