Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 1 | from keystonev3.common import send |
| 2 | from keystonev3.arg_converter import get_by_name_or_uuid_multiple |
| 3 | |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 4 | |
| 5 | try: |
| 6 | from urllib.parse import urlencode |
| 7 | except ImportError: |
| 8 | from urllib import urlencode |
| 9 | |
| 10 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 11 | @get_by_name_or_uuid_multiple([('project', 'project_id'), ('user', 'user_id'), |
| 12 | ('role', 'role_id')]) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 13 | @send('put') |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 14 | def 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 Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 16 | return url, None |
| 17 | |
| 18 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 19 | @get_by_name_or_uuid_multiple([('domain', 'domain_id'), ('user', 'user_id'), |
| 20 | ('role', 'role_id')]) |
| 21 | @send('put') |
| 22 | def 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 Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 29 | @send('delete') |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 30 | def 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 Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 32 | return url, None |
| 33 | |
| 34 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 35 | @get_by_name_or_uuid_multiple([('domain', 'domain_id'), ('user', 'user_id'), |
| 36 | ('role', 'role_id')]) |
| 37 | @send('delete') |
| 38 | def 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 Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 45 | @send('head') |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 46 | def 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 Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 49 | return url, None |
| 50 | |
| 51 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 52 | @get_by_name_or_uuid_multiple([('domain', 'domain_id'), ('user', 'user_id'), |
| 53 | ('role', 'role_id')]) |
| 54 | @send('head') |
| 55 | def 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 Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 62 | @send('get') |
| 63 | def role_get_details(role_id, **kwargs): |
| 64 | url = '/roles/{}?{}'.format(role_id, urlencode(kwargs)) |
| 65 | return url, None |
| 66 | |
| 67 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 68 | @get_by_name_or_uuid_multiple([('role', 'role_id')]) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 69 | @send('patch') |
| 70 | def role_update(role_id, **kwargs): |
| 71 | url = '/roles/{}'.format(role_id) |
| 72 | json = { |
| 73 | 'role': kwargs, |
| 74 | } |
| 75 | return url, json |
| 76 | |
| 77 | |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 78 | @get_by_name_or_uuid_multiple([('role', 'role_id')]) |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 79 | @send('delete') |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 80 | def role_delete(role_id, **kwargs): |
Vasyl Saienko | 4eda4f2 | 2018-04-26 19:30:39 +0300 | [diff] [blame] | 81 | url = '/roles/{}'.format(role_id) |
| 82 | return url, None |
| 83 | |
| 84 | |
| 85 | @send('post') |
| 86 | def role_create(**kwargs): |
| 87 | url = '/roles' |
| 88 | json = { |
| 89 | 'role': kwargs, |
| 90 | } |
| 91 | return url, json |
Oleksiy Petrenko | e03e2c7 | 2018-08-10 13:24:32 +0300 | [diff] [blame] | 92 | |
| 93 | |
| 94 | @get_by_name_or_uuid_multiple([('role', 'prior_role_id')]) |
| 95 | @send('get') |
| 96 | def 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') |
| 104 | def 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') |
| 112 | def 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') |
| 120 | def 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') |
| 128 | def 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 |