Debian Codegraph @

keystoneclient/v3/contrib/federation/protocols.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 Protocol(base.Resource):
17 """An object representing federation protocol container.
18
19 Attributes:
20 * id: user-defined unique per Identity Provider string identifying
21 federation protocol.
22
23 """
24
25 pass
26
27
28 class ProtocolManager(base.CrudManager):
29 """Manager class for manipulating federation protocols."""
30
31 resource_class = Protocol
32 collection_key = 'protocols'
33 key = 'protocol'
34 base_url = 'OS-FEDERATION/identity_providers'
35
36 def build_url(self, dict_args_in_out=None):
37 """Build URL for federation protocols."""
38 if dict_args_in_out is None:
39 dict_args_in_out = {}
40
41 identity_provider_id = dict_args_in_out.pop('identity_provider_id',
42 None)
43 if identity_provider_id:
44 base_url = '/'.join([self.base_url, identity_provider_id])
45 else:
46 base_url = self.base_url
47
48 dict_args_in_out.setdefault('base_url', base_url)
49 return super(ProtocolManager, self).build_url(dict_args_in_out)
50
51 def _build_url_and_put(self, request_body=None, **kwargs):
52 url = self.build_url(dict_args_in_out=kwargs)
53 body = {self.key: request_body}
54 return self._update(url, body=body,
55 response_key=self.key,
56 method='PUT')
57
58 def create(self, protocol_id, identity_provider, mapping, **kwargs):
59 """Create federation protocol object and tie to the Identity Provider.
60
61 Utilize Identity API operation:
62 PUT /OS-FEDERATION/identity_providers/
63 $identity_provider/protocols/$protocol
64
65 :param protocol_id: a string type parameter identifying a federation
66 protocol
67 :param identity_provider: a string type parameter identifying an
68 Identity Provider
69 :param mapping: a base.Resource object with federation mapping id
70
71 """
72 return self._build_url_and_put(
73 request_body={'mapping_id': base.getid(mapping)},
74 identity_provider_id=base.getid(identity_provider),
75 protocol_id=protocol_id, **kwargs)
76
77 def get(self, identity_provider, protocol, **kwargs):
78 """Fetch federation protocol object tied to the Identity Provider.
79
80 Utilize Identity API operation:
81 GET /OS-FEDERATION/identity_providers/
82 $identity_provider/protocols/$protocol
83
84 :param identity_provider: a base.Resource type object with Identity
85 Provider id stored inside
86 :param protocol: a base.Resource type object with federation protocol
87 id stored inside
88
89 """
90 return super(ProtocolManager, self).get(
91 identity_provider_id=base.getid(identity_provider),
92 protocol_id=base.getid(protocol), **kwargs)
93
94 def list(self, identity_provider, **kwargs):
95 """List all federation protocol objects tied to the Identity Provider.
96
97 Utilize Identity API operation:
98 GET /OS-FEDERATION/identity_providers/
99 $identity_provider/protocols
100
101 :param identity_provider: a base.Resource type object with Identity
102 Provider id stored inside
103
104 """
105 return super(ProtocolManager, self).list(
106 identity_provider_id=base.getid(identity_provider), **kwargs)
107
108 def update(self, identity_provider, protocol, mapping, **kwargs):
109 """Update Protocol object tied to the Identity Provider.
110
111 Utilize Identity API operation:
112 PATCH /OS-FEDERATION/identity_providers/
113 $identity_provider/protocols/$protocol
114
115 :param identity_provider: a base.Resource type object with Identity
116 Provider id stored inside
117 :param protocol: a base.Resource type object with federation protocol
118 id stored inside
119 :param mapping: a base.Resource object with federation mapping id
120
121
122 """
123 return super(ProtocolManager, self).update(
124 identity_provider_id=base.getid(identity_provider),
125 protocol_id=base.getid(protocol), mapping_id=base.getid(mapping),
126 **kwargs)
127
128 def delete(self, identity_provider, protocol):
129 """Delete Protocol object tied to the Identity Provider.
130
131 Utilize Identity API operation:
132 DELETE /OS-FEDERATION/identity_providers/
133 $identity_provider/protocols/$protocol
134
135 :param identity_provider: a base.Resource type object with
136 Identity Provider id stored inside
137 :param protocol: a base.Resource type object with federation
138 protocol id stored inside
139
140 """
141 return super(ProtocolManager, self).delete(
142 identity_provider_id=base.getid(identity_provider),
143 protocol_id=base.getid(protocol))