Debian Codegraph @

keystoneclient/v3/contrib/federation/mappings.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
12
13 from keystoneclient import base
14
15
16 class Mapping(base.Resource):
17 """An object representing mapping container.
18
19 Attributes:
20 * id: user defined unique string identifying mapping.
21
22 """
23
24 pass
25
26
27 class MappingManager(base.CrudManager):
28 """Manager class for manipulating federation mappings."""
29
30 resource_class = Mapping
31 collection_key = 'mappings'
32 key = 'mapping'
33 base_url = 'OS-FEDERATION'
34
35 def _build_url_and_put(self, **kwargs):
36 url = self.build_url(dict_args_in_out=kwargs)
37 body = {self.key: kwargs}
38 return self._update(url, body=body,
39 response_key=self.key,
40 method='PUT')
41
42 def create(self, mapping_id, **kwargs):
43 """Create federation mapping.
44
45 Utilize Identity API operation:
46 PUT /OS-FEDERATION/mappings/$mapping_id
47
48 :param mapping_id: user defined string identifier of the federation
49 mapping.
50 :param rules: a list of mapping rules.
51
52 Example of the ``rules`` parameter::
53
54 [
55 {
56 "local": [
57 {
58 "group": {
59 "id": "0cd5e9"
60 }
61 }
62 ],
63 "remote": [
64 {
65 "type": "orgPersonType",
66 "not_any_of": [
67 "Contractor",
68 "Guest"
69 ]
70 }
71 ]
72 }
73 ]
74
75 """
76 return self._build_url_and_put(
77 mapping_id=mapping_id, **kwargs)
78
79 def get(self, mapping):
80 """Fetch federation mapping identified by mapping id.
81
82 Utilize Identity API operation:
83 GET /OS-FEDERATION/mappings/$mapping_id
84
85 :param mapping: a Mapping type object with mapping id
86 stored inside.
87
88 """
89 return super(MappingManager, self).get(
90 mapping_id=base.getid(mapping))
91
92 def list(self, **kwargs):
93 """List all federation mappings.
94
95 Utilize Identity API operation:
96 GET /OS-FEDERATION/mappings
97
98 """
99 return super(MappingManager, self).list(**kwargs)
100
101 def update(self, mapping, **kwargs):
102 """Update federation mapping identified by mapping id.
103
104 Utilize Identity API operation:
105 PATCH /OS-FEDERATION/mappings/$mapping_id
106
107 :param mapping: a Mapping type object with mapping id
108 stored inside.
109 :param rules: a list of mapping rules.
110
111 Example of the ``rules`` parameter::
112
113
114 [
115 {
116 "local": [
117 {
118 "group": {
119 "id": "0cd5e9"
120 }
121 }
122 ],
123 "remote": [
124 {
125 "type": "orgPersonType",
126 "not_any_of": [
127 "Contractor",
128 "Guest"
129 ]
130 }
131 ]
132 }
133 ]
134
135 """
136 return super(MappingManager, self).update(
137 mapping_id=base.getid(mapping), **kwargs)
138
139 def delete(self, mapping):
140 """Delete federation mapping identified by mapping id.
141
142 Utilize Identity API operation:
143 DELETE /OS-FEDERATION/mappings/$mapping_id
144
145 :param mapping: a Mapping type object with mapping id
146 stored inside.
147
148 """
149 return super(MappingManager, self).delete(
150 mapping_id=base.getid(mapping))