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
13import openstack.exceptions as exception
14from openstack.identity.v3 import application_credential as \
15    _application_credential
16from openstack.identity.v3 import credential as _credential
17from openstack.identity.v3 import domain as _domain
18from openstack.identity.v3 import endpoint as _endpoint
19from openstack.identity.v3 import federation_protocol as _federation_protocol
20from openstack.identity.v3 import group as _group
21from openstack.identity.v3 import identity_provider as _identity_provider
22from openstack.identity.v3 import limit as _limit
23from openstack.identity.v3 import mapping as _mapping
24from openstack.identity.v3 import policy as _policy
25from openstack.identity.v3 import project as _project
26from openstack.identity.v3 import region as _region
27from openstack.identity.v3 import registered_limit as _registered_limit
28from openstack.identity.v3 import role as _role
29from openstack.identity.v3 import role_assignment as _role_assignment
30from openstack.identity.v3 import role_domain_group_assignment \
31    as _role_domain_group_assignment
32from openstack.identity.v3 import role_domain_user_assignment \
33    as _role_domain_user_assignment
34from openstack.identity.v3 import role_project_group_assignment \
35    as _role_project_group_assignment
36from openstack.identity.v3 import role_project_user_assignment \
37    as _role_project_user_assignment
38from openstack.identity.v3 import service as _service
39from openstack.identity.v3 import trust as _trust
40from openstack.identity.v3 import user as _user
41from openstack import proxy
42
43
44class Proxy(proxy.Proxy):
45
46    def create_credential(self, **attrs):
47        """Create a new credential from attributes
48
49        :param dict attrs: Keyword arguments which will be used to create
50            a :class:`~openstack.identity.v3.credential.Credential`,
51            comprised of the properties on the Credential class.
52
53        :returns: The results of credential creation
54        :rtype: :class:`~openstack.identity.v3.credential.Credential`
55        """
56        return self._create(_credential.Credential, **attrs)
57
58    def delete_credential(self, credential, ignore_missing=True):
59        """Delete a credential
60
61        :param credential: The value can be either the ID of a credential or a
62               :class:`~openstack.identity.v3.credential.Credential` instance.
63        :param bool ignore_missing: When set to ``False``
64                    :class:`~openstack.exceptions.ResourceNotFound` will be
65                    raised when the credential does not exist.
66                    When set to ``True``, no exception will be set when
67                    attempting to delete a nonexistent credential.
68
69        :returns: ``None``
70        """
71        self._delete(_credential.Credential, credential,
72                     ignore_missing=ignore_missing)
73
74    def find_credential(self, name_or_id, ignore_missing=True):
75        """Find a single credential
76
77        :param name_or_id: The name or ID of a credential.
78        :param bool ignore_missing: When set to ``False``
79                    :class:`~openstack.exceptions.ResourceNotFound` will be
80                    raised when the resource does not exist.
81                    When set to ``True``, None will be returned when
82                    attempting to find a nonexistent resource.
83        :returns: One :class:`~openstack.identity.v3.credential.Credential`
84                  or None
85        """
86        return self._find(_credential.Credential, name_or_id,
87                          ignore_missing=ignore_missing)
88
89    def get_credential(self, credential):
90        """Get a single credential
91
92        :param credential: The value can be the ID of a credential or a
93            :class:`~openstack.identity.v3.credential.Credential` instance.
94
95        :returns: One :class:`~openstack.identity.v3.credential.Credential`
96        :raises: :class:`~openstack.exceptions.ResourceNotFound`
97                 when no resource can be found.
98        """
99        return self._get(_credential.Credential, credential)
100
101    def credentials(self, **query):
102        """Retrieve a generator of credentials
103
104        :param kwargs query: Optional query parameters to be sent to limit
105                                 the resources being returned.
106
107        :returns: A generator of credentials instances.
108        :rtype: :class:`~openstack.identity.v3.credential.Credential`
109        """
110        # TODO(briancurtin): This is paginated but requires base list changes.
111        return self._list(_credential.Credential, **query)
112
113    def update_credential(self, credential, **attrs):
114        """Update a credential
115
116        :param credential: Either the ID of a credential or a
117            :class:`~openstack.identity.v3.credential.Credential` instance.
118        :attrs kwargs: The attributes to update on the credential represented
119                       by ``value``.
120
121        :returns: The updated credential
122        :rtype: :class:`~openstack.identity.v3.credential.Credential`
123        """
124        return self._update(_credential.Credential, credential, **attrs)
125
126    def create_domain(self, **attrs):
127        """Create a new domain from attributes
128
129        :param dict attrs: Keyword arguments which will be used to create
130                           a :class:`~openstack.identity.v3.domain.Domain`,
131                           comprised of the properties on the Domain class.
132
133        :returns: The results of domain creation
134        :rtype: :class:`~openstack.identity.v3.domain.Domain`
135        """
136        return self._create(_domain.Domain, **attrs)
137
138    def delete_domain(self, domain, ignore_missing=True):
139        """Delete a domain
140
141        :param domain: The value can be either the ID of a domain or a
142                       :class:`~openstack.identity.v3.domain.Domain` instance.
143        :param bool ignore_missing: When set to ``False``
144                    :class:`~openstack.exceptions.ResourceNotFound` will be
145                    raised when the domain does not exist.
146                    When set to ``True``, no exception will be set when
147                    attempting to delete a nonexistent domain.
148
149        :returns: ``None``
150        """
151        self._delete(_domain.Domain, domain, ignore_missing=ignore_missing)
152
153    def find_domain(self, name_or_id, ignore_missing=True):
154        """Find a single domain
155
156        :param name_or_id: The name or ID of a domain.
157        :param bool ignore_missing: When set to ``False``
158                    :class:`~openstack.exceptions.ResourceNotFound` will be
159                    raised when the resource does not exist.
160                    When set to ``True``, None will be returned when
161                    attempting to find a nonexistent resource.
162        :returns: One :class:`~openstack.identity.v3.domain.Domain` or None
163        """
164        return self._find(_domain.Domain, name_or_id,
165                          ignore_missing=ignore_missing)
166
167    def get_domain(self, domain):
168        """Get a single domain
169
170        :param domain: The value can be the ID of a domain or a
171                       :class:`~openstack.identity.v3.domain.Domain` instance.
172
173        :returns: One :class:`~openstack.identity.v3.domain.Domain`
174        :raises: :class:`~openstack.exceptions.ResourceNotFound`
175                 when no resource can be found.
176        """
177        return self._get(_domain.Domain, domain)
178
179    def domains(self, **query):
180        """Retrieve a generator of domains
181
182        :param kwargs query: Optional query parameters to be sent to limit
183                                 the resources being returned.
184
185        :returns: A generator of domain instances.
186        :rtype: :class:`~openstack.identity.v3.domain.Domain`
187        """
188        # TODO(briancurtin): This is paginated but requires base list changes.
189        return self._list(_domain.Domain, **query)
190
191    def update_domain(self, domain, **attrs):
192        """Update a domain
193
194        :param domain: Either the ID of a domain or a
195                       :class:`~openstack.identity.v3.domain.Domain` instance.
196        :attrs kwargs: The attributes to update on the domain represented
197                       by ``value``.
198
199        :returns: The updated domain
200        :rtype: :class:`~openstack.identity.v3.domain.Domain`
201        """
202        return self._update(_domain.Domain, domain, **attrs)
203
204    def create_endpoint(self, **attrs):
205        """Create a new endpoint from attributes
206
207        :param dict attrs: Keyword arguments which will be used to create
208                           a :class:`~openstack.identity.v3.endpoint.Endpoint`,
209                           comprised of the properties on the Endpoint class.
210
211        :returns: The results of endpoint creation
212        :rtype: :class:`~openstack.identity.v3.endpoint.Endpoint`
213        """
214        return self._create(_endpoint.Endpoint, **attrs)
215
216    def delete_endpoint(self, endpoint, ignore_missing=True):
217        """Delete an endpoint
218
219        :param endpoint: The value can be either the ID of an endpoint or a
220               :class:`~openstack.identity.v3.endpoint.Endpoint` instance.
221        :param bool ignore_missing: When set to ``False``
222                    :class:`~openstack.exceptions.ResourceNotFound` will be
223                    raised when the endpoint does not exist.
224                    When set to ``True``, no exception will be set when
225                    attempting to delete a nonexistent endpoint.
226
227        :returns: ``None``
228        """
229        self._delete(_endpoint.Endpoint, endpoint,
230                     ignore_missing=ignore_missing)
231
232    def find_endpoint(self, name_or_id, ignore_missing=True):
233        """Find a single endpoint
234
235        :param name_or_id: The name or ID of a endpoint.
236        :param bool ignore_missing: When set to ``False``
237                    :class:`~openstack.exceptions.ResourceNotFound` will be
238                    raised when the resource does not exist.
239                    When set to ``True``, None will be returned when
240                    attempting to find a nonexistent resource.
241        :returns: One :class:`~openstack.identity.v3.endpoint.Endpoint` or None
242        """
243        return self._find(_endpoint.Endpoint, name_or_id,
244                          ignore_missing=ignore_missing)
245
246    def get_endpoint(self, endpoint):
247        """Get a single endpoint
248
249        :param endpoint: The value can be the ID of an endpoint or a
250                         :class:`~openstack.identity.v3.endpoint.Endpoint`
251                         instance.
252
253        :returns: One :class:`~openstack.identity.v3.endpoint.Endpoint`
254        :raises: :class:`~openstack.exceptions.ResourceNotFound`
255                 when no resource can be found.
256        """
257        return self._get(_endpoint.Endpoint, endpoint)
258
259    def endpoints(self, **query):
260        """Retrieve a generator of endpoints
261
262        :param kwargs query: Optional query parameters to be sent to limit
263                                 the resources being returned.
264
265        :returns: A generator of endpoint instances.
266        :rtype: :class:`~openstack.identity.v3.endpoint.Endpoint`
267        """
268        # TODO(briancurtin): This is paginated but requires base list changes.
269        return self._list(_endpoint.Endpoint, **query)
270
271    def update_endpoint(self, endpoint, **attrs):
272        """Update a endpoint
273
274        :param endpoint: Either the ID of a endpoint or a
275                         :class:`~openstack.identity.v3.endpoint.Endpoint`
276                         instance.
277        :attrs kwargs: The attributes to update on the endpoint represented
278                       by ``value``.
279
280        :returns: The updated endpoint
281        :rtype: :class:`~openstack.identity.v3.endpoint.Endpoint`
282        """
283        return self._update(_endpoint.Endpoint, endpoint, **attrs)
284
285    def create_group(self, **attrs):
286        """Create a new group from attributes
287
288        :param dict attrs: Keyword arguments which will be used to create
289                           a :class:`~openstack.identity.v3.group.Group`,
290                           comprised of the properties on the Group class.
291
292        :returns: The results of group creation
293        :rtype: :class:`~openstack.identity.v3.group.Group`
294        """
295        return self._create(_group.Group, **attrs)
296
297    def delete_group(self, group, ignore_missing=True):
298        """Delete a group
299
300        :param group: The value can be either the ID of a group or a
301                      :class:`~openstack.identity.v3.group.Group` instance.
302        :param bool ignore_missing: When set to ``False``
303                    :class:`~openstack.exceptions.ResourceNotFound` will be
304                    raised when the group does not exist.
305                    When set to ``True``, no exception will be set when
306                    attempting to delete a nonexistent group.
307
308        :returns: ``None``
309        """
310        self._delete(_group.Group, group, ignore_missing=ignore_missing)
311
312    def find_group(self, name_or_id, ignore_missing=True):
313        """Find a single group
314
315        :param name_or_id: The name or ID of a group.
316        :param bool ignore_missing: When set to ``False``
317                    :class:`~openstack.exceptions.ResourceNotFound` will be
318                    raised when the resource does not exist.
319                    When set to ``True``, None will be returned when
320                    attempting to find a nonexistent resource.
321        :returns: One :class:`~openstack.identity.v3.group.Group` or None
322        """
323        return self._find(_group.Group, name_or_id,
324                          ignore_missing=ignore_missing)
325
326    def get_group(self, group):
327        """Get a single group
328
329        :param group: The value can be the ID of a group or a
330                      :class:`~openstack.identity.v3.group.Group`
331                      instance.
332
333        :returns: One :class:`~openstack.identity.v3.group.Group`
334        :raises: :class:`~openstack.exceptions.ResourceNotFound`
335                 when no resource can be found.
336        """
337        return self._get(_group.Group, group)
338
339    def groups(self, **query):
340        """Retrieve a generator of groups
341
342        :param kwargs query: Optional query parameters to be sent to limit
343                                 the resources being returned.
344
345        :returns: A generator of group instances.
346        :rtype: :class:`~openstack.identity.v3.group.Group`
347        """
348        # TODO(briancurtin): This is paginated but requires base list changes.
349        return self._list(_group.Group, **query)
350
351    def update_group(self, group, **attrs):
352        """Update a group
353
354        :param group: Either the ID of a group or a
355                      :class:`~openstack.identity.v3.group.Group` instance.
356        :attrs kwargs: The attributes to update on the group represented
357                       by ``value``.
358
359        :returns: The updated group
360        :rtype: :class:`~openstack.identity.v3.group.Group`
361        """
362        return self._update(_group.Group, group, **attrs)
363
364    def create_policy(self, **attrs):
365        """Create a new policy from attributes
366
367        :param dict attrs: Keyword arguments which will be used to create
368                           a :class:`~openstack.identity.v3.policy.Policy`,
369                           comprised of the properties on the Policy class.
370
371        :returns: The results of policy creation
372        :rtype: :class:`~openstack.identity.v3.policy.Policy`
373        """
374        return self._create(_policy.Policy, **attrs)
375
376    def delete_policy(self, policy, ignore_missing=True):
377        """Delete a policy
378
379        :param policy: The value can be either the ID of a policy or a
380                       :class:`~openstack.identity.v3.policy.Policy` instance.
381        :param bool ignore_missing: When set to ``False``
382                    :class:`~openstack.exceptions.ResourceNotFound` will be
383                    raised when the policy does not exist.
384                    When set to ``True``, no exception will be set when
385                    attempting to delete a nonexistent policy.
386
387        :returns: ``None``
388        """
389        self._delete(_policy.Policy, policy, ignore_missing=ignore_missing)
390
391    def find_policy(self, name_or_id, ignore_missing=True):
392        """Find a single policy
393
394        :param name_or_id: The name or ID of a policy.
395        :param bool ignore_missing: When set to ``False``
396                    :class:`~openstack.exceptions.ResourceNotFound` will be
397                    raised when the resource does not exist.
398                    When set to ``True``, None will be returned when
399                    attempting to find a nonexistent resource.
400        :returns: One :class:`~openstack.identity.v3.policy.Policy` or None
401        """
402        return self._find(_policy.Policy, name_or_id,
403                          ignore_missing=ignore_missing)
404
405    def get_policy(self, policy):
406        """Get a single policy
407
408        :param policy: The value can be the ID of a policy or a
409                       :class:`~openstack.identity.v3.policy.Policy` instance.
410
411        :returns: One :class:`~openstack.identity.v3.policy.Policy`
412        :raises: :class:`~openstack.exceptions.ResourceNotFound`
413                 when no resource can be found.
414        """
415        return self._get(_policy.Policy, policy)
416
417    def policies(self, **query):
418        """Retrieve a generator of policies
419
420        :param kwargs query: Optional query parameters to be sent to limit
421                                 the resources being returned.
422
423        :returns: A generator of policy instances.
424        :rtype: :class:`~openstack.identity.v3.policy.Policy`
425        """
426        # TODO(briancurtin): This is paginated but requires base list changes.
427        return self._list(_policy.Policy, **query)
428
429    def update_policy(self, policy, **attrs):
430        """Update a policy
431
432        :param policy: Either the ID of a policy or a
433                       :class:`~openstack.identity.v3.policy.Policy` instance.
434        :attrs kwargs: The attributes to update on the policy represented
435                       by ``value``.
436
437        :returns: The updated policy
438        :rtype: :class:`~openstack.identity.v3.policy.Policy`
439        """
440        return self._update(_policy.Policy, policy, **attrs)
441
442    def create_project(self, **attrs):
443        """Create a new project from attributes
444
445        :param dict attrs: Keyword arguments which will be used to create
446                           a :class:`~openstack.identity.v3.project.Project`,
447                           comprised of the properties on the Project class.
448
449        :returns: The results of project creation
450        :rtype: :class:`~openstack.identity.v3.project.Project`
451        """
452        return self._create(_project.Project, **attrs)
453
454    def delete_project(self, project, ignore_missing=True):
455        """Delete a project
456
457        :param project: The value can be either the ID of a project or a
458            :class:`~openstack.identity.v3.project.Project` instance.
459        :param bool ignore_missing: When set to ``False``
460                    :class:`~openstack.exceptions.ResourceNotFound` will be
461                    raised when the project does not exist.
462                    When set to ``True``, no exception will be set when
463                    attempting to delete a nonexistent project.
464
465        :returns: ``None``
466        """
467        self._delete(_project.Project, project, ignore_missing=ignore_missing)
468
469    def find_project(self, name_or_id, ignore_missing=True, **attrs):
470        """Find a single project
471
472        :param name_or_id: The name or ID of a project.
473        :param bool ignore_missing: When set to ``False``
474                    :class:`~openstack.exceptions.ResourceNotFound` will be
475                    raised when the resource does not exist.
476                    When set to ``True``, None will be returned when
477                    attempting to find a nonexistent resource.
478        :returns: One :class:`~openstack.identity.v3.project.Project` or None
479        """
480        return self._find(_project.Project, name_or_id,
481                          ignore_missing=ignore_missing, **attrs)
482
483    def get_project(self, project):
484        """Get a single project
485
486        :param project: The value can be the ID of a project or a
487            :class:`~openstack.identity.v3.project.Project` instance.
488
489        :returns: One :class:`~openstack.identity.v3.project.Project`
490        :raises: :class:`~openstack.exceptions.ResourceNotFound`
491                 when no resource can be found.
492        """
493        return self._get(_project.Project, project)
494
495    def projects(self, **query):
496        """Retrieve a generator of projects
497
498        :param kwargs query: Optional query parameters to be sent to limit
499                                 the resources being returned.
500
501        :returns: A generator of project instances.
502        :rtype: :class:`~openstack.identity.v3.project.Project`
503        """
504        # TODO(briancurtin): This is paginated but requires base list changes.
505        return self._list(_project.Project, **query)
506
507    def user_projects(self, user, **query):
508        """Retrieve a generator of projects to which the user has authorization
509           to access.
510
511        :param user: Either the user id or an instance of
512                     :class:`~openstack.identity.v3.user.User`
513        :param kwargs query: Optional query parameters to be sent to limit
514                                 the resources being returned.
515
516        :returns: A generator of project instances.
517        :rtype: :class:`~openstack.identity.v3.project.UserProject`
518        """
519        user = self._get_resource(_user.User, user)
520        return self._list(_project.UserProject, user_id=user.id, **query)
521
522    def update_project(self, project, **attrs):
523        """Update a project
524
525        :param project: Either the ID of a project or a
526            :class:`~openstack.identity.v3.project.Project` instance.
527        :attrs kwargs: The attributes to update on the project represented
528                       by ``value``.
529
530        :returns: The updated project
531        :rtype: :class:`~openstack.identity.v3.project.Project`
532        """
533        return self._update(_project.Project, project, **attrs)
534
535    def create_service(self, **attrs):
536        """Create a new service from attributes
537
538        :param dict attrs: Keyword arguments which will be used to create
539                           a :class:`~openstack.identity.v3.service.Service`,
540                           comprised of the properties on the Service class.
541
542        :returns: The results of service creation
543        :rtype: :class:`~openstack.identity.v3.service.Service`
544        """
545        return self._create(_service.Service, **attrs)
546
547    def delete_service(self, service, ignore_missing=True):
548        """Delete a service
549
550        :param service: The value can be either the ID of a service or a
551            :class:`~openstack.identity.v3.service.Service` instance.
552        :param bool ignore_missing: When set to ``False``
553                    :class:`~openstack.exceptions.ResourceNotFound` will be
554                    raised when the service does not exist.
555                    When set to ``True``, no exception will be set when
556                    attempting to delete a nonexistent service.
557
558        :returns: ``None``
559        """
560        self._delete(_service.Service, service, ignore_missing=ignore_missing)
561
562    def find_service(self, name_or_id, ignore_missing=True):
563        """Find a single service
564
565        :param name_or_id: The name or ID of a service.
566        :param bool ignore_missing: When set to ``False``
567                    :class:`~openstack.exceptions.ResourceNotFound` will be
568                    raised when the resource does not exist.
569                    When set to ``True``, None will be returned when
570                    attempting to find a nonexistent resource.
571        :returns: One :class:`~openstack.identity.v3.service.Service` or None
572        """
573        return self._find(_service.Service, name_or_id,
574                          ignore_missing=ignore_missing)
575
576    def get_service(self, service):
577        """Get a single service
578
579        :param service: The value can be the ID of a service or a
580            :class:`~openstack.identity.v3.service.Service` instance.
581
582        :returns: One :class:`~openstack.identity.v3.service.Service`
583        :raises: :class:`~openstack.exceptions.ResourceNotFound`
584                 when no resource can be found.
585        """
586        return self._get(_service.Service, service)
587
588    def services(self, **query):
589        """Retrieve a generator of services
590
591        :param kwargs query: Optional query parameters to be sent to limit
592                                 the resources being returned.
593
594        :returns: A generator of service instances.
595        :rtype: :class:`~openstack.identity.v3.service.Service`
596        """
597        # TODO(briancurtin): This is paginated but requires base list changes.
598        return self._list(_service.Service, **query)
599
600    def update_service(self, service, **attrs):
601        """Update a service
602
603        :param service: Either the ID of a service or a
604            :class:`~openstack.identity.v3.service.Service` instance.
605        :attrs kwargs: The attributes to update on the service represented
606                       by ``value``.
607
608        :returns: The updated service
609        :rtype: :class:`~openstack.identity.v3.service.Service`
610        """
611        return self._update(_service.Service, service, **attrs)
612
613    def create_user(self, **attrs):
614        """Create a new user from attributes
615
616        :param dict attrs: Keyword arguments which will be used to create
617                           a :class:`~openstack.identity.v3.user.User`,
618                           comprised of the properties on the User class.
619
620        :returns: The results of user creation
621        :rtype: :class:`~openstack.identity.v3.user.User`
622        """
623        return self._create(_user.User, **attrs)
624
625    def delete_user(self, user, ignore_missing=True):
626        """Delete a user
627
628        :param user: The value can be either the ID of a user or a
629                     :class:`~openstack.identity.v3.user.User` instance.
630        :param bool ignore_missing: When set to ``False``
631                    :class:`~openstack.exceptions.ResourceNotFound` will be
632                    raised when the user does not exist.
633                    When set to ``True``, no exception will be set when
634                    attempting to delete a nonexistent user.
635
636        :returns: ``None``
637        """
638        self._delete(_user.User, user, ignore_missing=ignore_missing)
639
640    def find_user(self, name_or_id, ignore_missing=True, **attrs):
641        """Find a single user
642
643        :param name_or_id: The name or ID of a user.
644        :param bool ignore_missing: When set to ``False``
645                    :class:`~openstack.exceptions.ResourceNotFound` will be
646                    raised when the resource does not exist.
647                    When set to ``True``, None will be returned when
648                    attempting to find a nonexistent resource.
649        :returns: One :class:`~openstack.identity.v3.user.User` or None
650        """
651        return self._find(_user.User, name_or_id,
652                          ignore_missing=ignore_missing, **attrs)
653
654    def get_user(self, user):
655        """Get a single user
656
657        :param user: The value can be the ID of a user or a
658                     :class:`~openstack.identity.v3.user.User` instance.
659
660        :returns: One :class:`~openstack.identity.v3.user.User`
661        :raises: :class:`~openstack.exceptions.ResourceNotFound`
662                 when no resource can be found.
663        """
664        return self._get(_user.User, user)
665
666    def users(self, **query):
667        """Retrieve a generator of users
668
669        :param kwargs query: Optional query parameters to be sent to limit
670                                 the resources being returned.
671
672        :returns: A generator of user instances.
673        :rtype: :class:`~openstack.identity.v3.user.User`
674        """
675        # TODO(briancurtin): This is paginated but requires base list changes.
676        return self._list(_user.User, **query)
677
678    def update_user(self, user, **attrs):
679        """Update a user
680
681        :param user: Either the ID of a user or a
682                     :class:`~openstack.identity.v3.user.User` instance.
683        :attrs kwargs: The attributes to update on the user represented
684                       by ``value``.
685
686        :returns: The updated user
687        :rtype: :class:`~openstack.identity.v3.user.User`
688        """
689        return self._update(_user.User, user, **attrs)
690
691    def create_trust(self, **attrs):
692        """Create a new trust from attributes
693
694        :param dict attrs: Keyword arguments which will be used to create
695                           a :class:`~openstack.identity.v3.trust.Trust`,
696                           comprised of the properties on the Trust class.
697
698        :returns: The results of trust creation
699        :rtype: :class:`~openstack.identity.v3.trust.Trust`
700        """
701        return self._create(_trust.Trust, **attrs)
702
703    def delete_trust(self, trust, ignore_missing=True):
704        """Delete a trust
705
706        :param trust: The value can be either the ID of a trust or a
707               :class:`~openstack.identity.v3.trust.Trust` instance.
708        :param bool ignore_missing: When set to ``False``
709                    :class:`~openstack.exceptions.ResourceNotFound` will be
710                    raised when the credential does not exist.
711                    When set to ``True``, no exception will be set when
712                    attempting to delete a nonexistent credential.
713
714        :returns: ``None``
715        """
716        self._delete(_trust.Trust, trust, ignore_missing=ignore_missing)
717
718    def find_trust(self, name_or_id, ignore_missing=True):
719        """Find a single trust
720
721        :param name_or_id: The name or ID of a trust.
722        :param bool ignore_missing: When set to ``False``
723                    :class:`~openstack.exceptions.ResourceNotFound` will be
724                    raised when the resource does not exist.
725                    When set to ``True``, None will be returned when
726                    attempting to find a nonexistent resource.
727        :returns: One :class:`~openstack.identity.v3.trust.Trust` or None
728        """
729        return self._find(_trust.Trust, name_or_id,
730                          ignore_missing=ignore_missing)
731
732    def get_trust(self, trust):
733        """Get a single trust
734
735        :param trust: The value can be the ID of a trust or a
736                      :class:`~openstack.identity.v3.trust.Trust` instance.
737
738        :returns: One :class:`~openstack.identity.v3.trust.Trust`
739        :raises: :class:`~openstack.exceptions.ResourceNotFound`
740                 when no resource can be found.
741        """
742        return self._get(_trust.Trust, trust)
743
744    def trusts(self, **query):
745        """Retrieve a generator of trusts
746
747        :param kwargs query: Optional query parameters to be sent to limit
748                                 the resources being returned.
749
750        :returns: A generator of trust instances.
751        :rtype: :class:`~openstack.identity.v3.trust.Trust`
752        """
753        # TODO(briancurtin): This is paginated but requires base list changes.
754        return self._list(_trust.Trust, **query)
755
756    def create_region(self, **attrs):
757        """Create a new region from attributes
758
759        :param dict attrs: Keyword arguments which will be used to create
760                           a :class:`~openstack.identity.v3.region.Region`,
761                           comprised of the properties on the Region class.
762
763        :returns: The results of region creation.
764        :rtype: :class:`~openstack.identity.v3.region.Region`
765        """
766        return self._create(_region.Region, **attrs)
767
768    def delete_region(self, region, ignore_missing=True):
769        """Delete a region
770
771        :param region: The value can be either the ID of a region or a
772               :class:`~openstack.identity.v3.region.Region` instance.
773        :param bool ignore_missing: When set to ``False``
774                    :class:`~openstack.exceptions.ResourceNotFound` will be
775                    raised when the region does not exist.
776                    When set to ``True``, no exception will be thrown when
777                    attempting to delete a nonexistent region.
778
779        :returns: ``None``
780        """
781        self._delete(_region.Region, region, ignore_missing=ignore_missing)
782
783    def find_region(self, name_or_id, ignore_missing=True):
784        """Find a single region
785
786        :param name_or_id: The name or ID of a region.
787        :param bool ignore_missing: When set to ``False``
788                    :class:`~openstack.exceptions.ResourceNotFound` will be
789                    raised when the region does not exist.
790                    When set to ``True``, None will be returned when
791                    attempting to find a nonexistent region.
792        :returns: One :class:`~openstack.identity.v3.region.Region` or None
793        """
794        return self._find(_region.Region, name_or_id,
795                          ignore_missing=ignore_missing)
796
797    def get_region(self, region):
798        """Get a single region
799
800        :param region: The value can be the ID of a region or a
801                       :class:`~openstack.identity.v3.region.Region` instance.
802
803        :returns: One :class:`~openstack.identity.v3.region.Region`
804        :raises: :class:`~openstack.exceptions.ResourceNotFound`
805                 when no matching region can be found.
806        """
807        return self._get(_region.Region, region)
808
809    def regions(self, **query):
810        """Retrieve a generator of regions
811
812        :param kwargs query: Optional query parameters to be sent to limit
813                                 the regions being returned.
814
815        :returns: A generator of region instances.
816        :rtype: :class:`~openstack.identity.v3.region.Region`
817        """
818        # TODO(briancurtin): This is paginated but requires base list changes.
819        return self._list(_region.Region, **query)
820
821    def update_region(self, region, **attrs):
822        """Update a region
823
824        :param region: Either the ID of a region or a
825                      :class:`~openstack.identity.v3.region.Region` instance.
826        :attrs kwargs: The attributes to update on the region represented
827                       by ``value``.
828
829        :returns: The updated region.
830        :rtype: :class:`~openstack.identity.v3.region.Region`
831        """
832        return self._update(_region.Region, region, **attrs)
833
834    def create_role(self, **attrs):
835        """Create a new role from attributes
836
837        :param dict attrs: Keyword arguments which will be used to create
838                           a :class:`~openstack.identity.v3.role.Role`,
839                           comprised of the properties on the Role class.
840
841        :returns: The results of role creation.
842        :rtype: :class:`~openstack.identity.v3.role.Role`
843        """
844        return self._create(_role.Role, **attrs)
845
846    def delete_role(self, role, ignore_missing=True):
847        """Delete a role
848
849        :param role: The value can be either the ID of a role or a
850               :class:`~openstack.identity.v3.role.Role` instance.
851        :param bool ignore_missing: When set to ``False``
852                    :class:`~openstack.exceptions.ResourceNotFound` will be
853                    raised when the role does not exist.
854                    When set to ``True``, no exception will be thrown when
855                    attempting to delete a nonexistent role.
856
857        :returns: ``None``
858        """
859        self._delete(_role.Role, role, ignore_missing=ignore_missing)
860
861    def find_role(self, name_or_id, ignore_missing=True):
862        """Find a single role
863
864        :param name_or_id: The name or ID of a role.
865        :param bool ignore_missing: When set to ``False``
866                    :class:`~openstack.exceptions.ResourceNotFound` will be
867                    raised when the role does not exist.
868                    When set to ``True``, None will be returned when
869                    attempting to find a nonexistent role.
870        :returns: One :class:`~openstack.identity.v3.role.Role` or None
871        """
872        return self._find(_role.Role, name_or_id,
873                          ignore_missing=ignore_missing)
874
875    def get_role(self, role):
876        """Get a single role
877
878        :param role: The value can be the ID of a role or a
879                       :class:`~openstack.identity.v3.role.Role` instance.
880
881        :returns: One :class:`~openstack.identity.v3.role.Role`
882        :raises: :class:`~openstack.exceptions.ResourceNotFound`
883                 when no matching role can be found.
884        """
885        return self._get(_role.Role, role)
886
887    def roles(self, **query):
888        """Retrieve a generator of roles
889
890        :param kwargs query: Optional query parameters to be sent to limit
891                                 the resources being returned. The options
892                                 are: domain_id, name.
893        :return: A generator of role instances.
894        :rtype: :class:`~openstack.identity.v3.role.Role`
895        """
896        return self._list(_role.Role, **query)
897
898    def update_role(self, role, **attrs):
899        """Update a role
900
901        :param role: Either the ID of a role or a
902                      :class:`~openstack.identity.v3.role.Role` instance.
903        :param dict kwargs: The attributes to update on the role represented
904                       by ``value``. Only name can be updated
905
906        :returns: The updated role.
907        :rtype: :class:`~openstack.identity.v3.role.Role`
908        """
909        return self._update(_role.Role, role, **attrs)
910
911    def role_assignments_filter(self, domain=None, project=None, group=None,
912                                user=None):
913        """Retrieve a generator of roles assigned to user/group
914
915        :param domain: Either the ID of a domain or a
916                      :class:`~openstack.identity.v3.domain.Domain` instance.
917        :param project: Either the ID of a project or a
918                      :class:`~openstack.identity.v3.project.Project`
919                      instance.
920        :param group: Either the ID of a group or a
921                      :class:`~openstack.identity.v3.group.Group` instance.
922        :param user: Either the ID of a user or a
923                     :class:`~openstack.identity.v3.user.User` instance.
924        :return: A generator of role instances.
925        :rtype: :class:`~openstack.identity.v3.role.Role`
926        """
927        if domain and project:
928            raise exception.InvalidRequest(
929                'Only one of domain or project can be specified')
930
931        if domain is None and project is None:
932            raise exception.InvalidRequest(
933                'Either domain or project should be specified')
934
935        if group and user:
936            raise exception.InvalidRequest(
937                'Only one of group or user can be specified')
938
939        if group is None and user is None:
940            raise exception.InvalidRequest(
941                'Either group or user should be specified')
942
943        if domain:
944            domain = self._get_resource(_domain.Domain, domain)
945            if group:
946                group = self._get_resource(_group.Group, group)
947                return self._list(
948                    _role_domain_group_assignment.RoleDomainGroupAssignment,
949                    domain_id=domain.id, group_id=group.id)
950            else:
951                user = self._get_resource(_user.User, user)
952                return self._list(
953                    _role_domain_user_assignment.RoleDomainUserAssignment,
954                    domain_id=domain.id, user_id=user.id)
955        else:
956            project = self._get_resource(_project.Project, project)
957            if group:
958                group = self._get_resource(_group.Group, group)
959                return self._list(
960                    _role_project_group_assignment.RoleProjectGroupAssignment,
961                    project_id=project.id, group_id=group.id)
962            else:
963                user = self._get_resource(_user.User, user)
964                return self._list(
965                    _role_project_user_assignment.RoleProjectUserAssignment,
966                    project_id=project.id, user_id=user.id)
967
968    def role_assignments(self, **query):
969        """Retrieve a generator of role assignments
970
971        :param kwargs query: Optional query parameters to be sent to limit
972                                 the resources being returned. The options
973                                 are: group_id, role_id, scope_domain_id,
974                                 scope_project_id, user_id, include_names,
975                                 include_subtree.
976        :return:
977                :class:`~openstack.identity.v3.role_assignment.RoleAssignment`
978        """
979        return self._list(_role_assignment.RoleAssignment, **query)
980
981    def registered_limits(self, **query):
982        """Retrieve a generator of registered_limits
983
984        :param kwargs query: Optional query parameters to be sent to limit
985            the registered_limits being returned.
986
987        :returns: A generator of registered_limits instances.
988        :rtype: :class:
989            `~openstack.identity.v3.registered_limit.RegisteredLimit`
990        """
991        return self._list(_registered_limit.RegisteredLimit, **query)
992
993    def get_registered_limit(self, registered_limit):
994        """Get a single registered_limit
995
996        :param registered_limit: The value can be the ID of a registered_limit
997            or a :class:
998            `~openstack.identity.v3.registered_limit.RegisteredLimit` instance.
999
1000        :returns: One :class:
1001                  `~openstack.identity.v3.registered_limit.RegisteredLimit`
1002        :raises: :class:`~openstack.exceptions.ResourceNotFound`
1003                 when no resource can be found.
1004        """
1005        return self._get(_registered_limit.RegisteredLimit, registered_limit)
1006
1007    def create_registered_limit(self, **attrs):
1008        """Create a new registered_limit from attributes
1009
1010        :param dict attrs: Keyword arguments which will be used to create
1011            a :class:`~openstack.identity.v3.registered_limit.RegisteredLimit`,
1012            comprised of the properties on the RegisteredLimit class.
1013
1014        :returns: The results of registered_limit creation.
1015        :rtype: :class:
1016            `~openstack.identity.v3.registered_limit.RegisteredLimit`
1017        """
1018        return self._create(_registered_limit.RegisteredLimit, **attrs)
1019
1020    def update_registered_limit(self, registered_limit, **attrs):
1021        """Update a registered_limit
1022
1023        :param registered_limit: Either the ID of a registered_limit. or a
1024            :class:`~openstack.identity.v3.registered_limit.RegisteredLimit`
1025            instance.
1026        :param dict kwargs: The attributes to update on the registered_limit
1027            represented by ``value``.
1028
1029        :returns: The updated registered_limit.
1030        :rtype: :class:
1031            `~openstack.identity.v3.registered_limit.RegisteredLimit`
1032        """
1033        return self._update(_registered_limit.RegisteredLimit,
1034                            registered_limit, **attrs)
1035
1036    def delete_registered_limit(self, registered_limit, ignore_missing=True):
1037        """Delete a registered_limit
1038
1039        :param registered_limit: The value can be either the ID of a
1040            registered_limit or a
1041            :class:`~openstack.identity.v3.registered_limit.RegisteredLimit`
1042            instance.
1043        :param bool ignore_missing: When set to ``False``
1044            :class:`~openstack.exceptions.ResourceNotFound` will be raised when
1045            the registered_limit does not exist. When set to ``True``, no
1046            exception will be thrown when attempting to delete a nonexistent
1047            registered_limit.
1048
1049        :returns: ``None``
1050        """
1051        self._delete(_registered_limit.RegisteredLimit, registered_limit,
1052                     ignore_missing=ignore_missing)
1053
1054    def limits(self, **query):
1055        """Retrieve a generator of limits
1056
1057        :param kwargs query: Optional query parameters to be sent to limit
1058            the limits being returned.
1059
1060        :returns: A generator of limits instances.
1061        :rtype: :class:`~openstack.identity.v3.limit.Limit`
1062        """
1063        return self._list(_limit.Limit, **query)
1064
1065    def get_limit(self, limit):
1066        """Get a single limit
1067
1068        :param limit: The value can be the ID of a limit
1069            or a :class:`~openstack.identity.v3.limit.Limit` instance.
1070
1071        :returns: One :class:
1072                  `~openstack.identity.v3.limit.Limit`
1073        :raises: :class:`~openstack.exceptions.ResourceNotFound` when no
1074            resource can be found.
1075        """
1076        return self._get(_limit.Limit, limit)
1077
1078    def create_limit(self, **attrs):
1079        """Create a new limit from attributes
1080
1081        :param dict attrs: Keyword arguments which will be used to create
1082            a :class:`~openstack.identity.v3.limit.Limit`, comprised of the
1083            properties on the Limit class.
1084
1085        :returns: The results of limit creation.
1086        :rtype: :class:`~openstack.identity.v3.limit.Limit`
1087        """
1088        return self._create(_limit.Limit, **attrs)
1089
1090    def update_limit(self, limit, **attrs):
1091        """Update a limit
1092
1093        :param limit: Either the ID of a limit. or a
1094            :class:`~openstack.identity.v3.limit.Limit` instance.
1095        :param dict kwargs: The attributes to update on the limit represented
1096            by ``value``.
1097
1098        :returns: The updated limit.
1099        :rtype: :class:`~openstack.identity.v3.limit.Limit`
1100        """
1101        return self._update(_limit.Limit,
1102                            limit, **attrs)
1103
1104    def delete_limit(self, limit, ignore_missing=True):
1105        """Delete a limit
1106
1107        :param limit: The value can be either the ID of a limit or a
1108            :class:`~openstack.identity.v3.limit.Limit` instance.
1109        :param bool ignore_missing: When set to ``False``
1110            :class:`~openstack.exceptions.ResourceNotFound` will be raised when
1111            the limit does not exist. When set to ``True``, no exception will
1112            be thrown when attempting to delete a nonexistent limit.
1113
1114        :returns: ``None``
1115        """
1116        self._delete(limit.Limit, limit,
1117                     ignore_missing=ignore_missing)
1118
1119    def assign_project_role_to_user(self, project, user, role):
1120        """Assign role to user on a project
1121
1122        :param project: Either the ID of a project or a
1123                      :class:`~openstack.identity.v3.project.Project`
1124                      instance.
1125        :param user: Either the ID of a user or a
1126                     :class:`~openstack.identity.v3.user.User` instance.
1127        :param role: Either the ID of a role or a
1128                     :class:`~openstack.identity.v3.role.Role` instance.
1129        :return: ``None``
1130        """
1131        project = self._get_resource(_project.Project, project)
1132        user = self._get_resource(_user.User, user)
1133        role = self._get_resource(_role.Role, role)
1134        project.assign_role_to_user(self, user, role)
1135
1136    def unassign_project_role_from_user(self, project, user, role):
1137        """Unassign role from user on a project
1138
1139        :param project: Either the ID of a project or a
1140                      :class:`~openstack.identity.v3.project.Project`
1141                      instance.
1142        :param user: Either the ID of a user or a
1143                     :class:`~openstack.identity.v3.user.User` instance.
1144        :param role: Either the ID of a role or a
1145                     :class:`~openstack.identity.v3.role.Role` instance.
1146        :return: ``None``
1147        """
1148        project = self._get_resource(_project.Project, project)
1149        user = self._get_resource(_user.User, user)
1150        role = self._get_resource(_role.Role, role)
1151        project.unassign_role_from_user(self, user, role)
1152
1153    def validate_user_has_role(self, project, user, role):
1154        """Validates that a user has a role on a project
1155
1156        :param project: Either the ID of a project or a
1157                      :class:`~openstack.identity.v3.project.Project`
1158                      instance.
1159        :param user: Either the ID of a user or a
1160                     :class:`~openstack.identity.v3.user.User` instance.
1161        :param role: Either the ID of a role or a
1162                     :class:`~openstack.identity.v3.role.Role` instance.
1163        :returns: True if user has role in project
1164        """
1165        project = self._get_resource(_project.Project, project)
1166        user = self._get_resource(_user.User, user)
1167        role = self._get_resource(_role.Role, role)
1168        return project.validate_user_has_role(self, user, role)
1169
1170    def assign_project_role_to_group(self, project, group, role):
1171        """Assign role to group on a project
1172
1173        :param project: Either the ID of a project or a
1174                      :class:`~openstack.identity.v3.project.Project`
1175                      instance.
1176        :param group: Either the ID of a group or a
1177                     :class:`~openstack.identity.v3.group.Group` instance.
1178        :param role: Either the ID of a role or a
1179                     :class:`~openstack.identity.v3.role.Role` instance.
1180        :return: ``None``
1181        """
1182        project = self._get_resource(_project.Project, project)
1183        group = self._get_resource(_group.Group, group)
1184        role = self._get_resource(_role.Role, role)
1185        project.assign_role_to_group(self, group, role)
1186
1187    def unassign_project_role_from_group(self, project, group, role):
1188        """Unassign role from group on a project
1189
1190        :param project: Either the ID of a project or a
1191                      :class:`~openstack.identity.v3.project.Project`
1192                      instance.
1193        :param group: Either the ID of a group or a
1194                     :class:`~openstack.identity.v3.group.Group` instance.
1195        :param role: Either the ID of a role or a
1196                     :class:`~openstack.identity.v3.role.Role` instance.
1197        :return: ``None``
1198        """
1199        project = self._get_resource(_project.Project, project)
1200        group = self._get_resource(_group.Group, group)
1201        role = self._get_resource(_role.Role, role)
1202        project.unassign_role_from_group(self, group, role)
1203
1204    def validate_group_has_role(self, project, group, role):
1205        """Validates that a group has a role on a project
1206
1207        :param project: Either the ID of a project or a
1208                      :class:`~openstack.identity.v3.project.Project`
1209                      instance.
1210        :param group: Either the ID of a group or a
1211                     :class:`~openstack.identity.v3.group.Group` instance.
1212        :param role: Either the ID of a role or a
1213                     :class:`~openstack.identity.v3.role.Role` instance.
1214        :returns: True if group has role in project
1215        """
1216        project = self._get_resource(_project.Project, project)
1217        group = self._get_resource(_group.Group, group)
1218        role = self._get_resource(_role.Role, role)
1219        return project.validate_group_has_role(self, group, role)
1220
1221    def application_credentials(self, user, **query):
1222        """Retrieve a generator of application credentials
1223
1224        :param user: Either the ID of a user or a
1225                   :class:`~openstack.identity.v3.user.User` instance.
1226
1227        :param kwargs query: Optional query parameters to be sent to
1228            limit the resources being returned.
1229
1230        :returns: A generator of application credentials instances.
1231        :rtype: :class:`~openstack.identity.v3.application_credential.
1232             ApplicationCredential`
1233        """
1234        user = self._get_resource(_user.User, user)
1235        return self._list(_application_credential.ApplicationCredential,
1236                          user_id=user.id, **query)
1237
1238    def get_application_credential(self, user, application_credential):
1239        """Get a single application credential
1240
1241        :param user: Either the ID of a user or a
1242                   :class:`~openstack.identity.v3.user.User` instance.
1243
1244        :param application_credential: The value can be the ID of a
1245             application credential or a :class:
1246             `~openstack.identity.v3.application_credential.
1247             ApplicationCredential` instance.
1248
1249        :returns: One :class:`~openstack.identity.v3.application_credential.
1250             ApplicationCredential`
1251        :raises: :class:`~openstack.exceptions.ResourceNotFound` when no
1252             resource can be found.
1253        """
1254        user = self._get_resource(_user.User, user)
1255        return self._get(_application_credential.ApplicationCredential,
1256                         application_credential,
1257                         user_id=user.id)
1258
1259    def create_application_credential(self, user, name, **attrs):
1260        """Create a new application credential from attributes
1261
1262        :param user: Either the ID of a user or a
1263                   :class:`~openstack.identity.v3.user.User` instance.
1264        :param name: The name of the application credential which is
1265                    unique to the user.
1266        :param dict attrs: Keyword arguments which will be used to create
1267             a :class:`~openstack.identity.v3.application_credential.
1268             ApplicationCredential`, comprised of the properties on the
1269             ApplicationCredential class.
1270
1271
1272        :returns: The results of application credential creation.
1273        :rtype: :class:`~openstack.identity.v3.application_credential.
1274             ApplicationCredential`
1275        """
1276
1277        user = self._get_resource(_user.User, user)
1278        return self._create(_application_credential.ApplicationCredential,
1279                            name=name,
1280                            user_id=user.id, **attrs)
1281
1282    def find_application_credential(self, user, name_or_id,
1283                                    ignore_missing=True, **args):
1284        """Find a single application credential
1285
1286        :param user: Either the ID of a user or a
1287                   :class:`~openstack.identity.v3.user.User` instance.
1288        :param name_or_id: The name or ID of an application credential.
1289        :param bool ignore_missing: When set to ``False``
1290             :class:`~openstack.exceptions.ResourceNotFound` will be
1291             raised when the resource does not exist.
1292             When set to ``True``, None will be returned when
1293             attempting to find a nonexistent resource.
1294
1295        :returns: One :class:`~openstack.identity.v3.application_credential.
1296             ApplicationCredential` or None
1297        """
1298        user = self._get_resource(_user.User, user)
1299        return self._find(_application_credential.ApplicationCredential,
1300                          user_id=user.id, name_or_id=name_or_id,
1301                          ignore_missing=ignore_missing, **args)
1302
1303    def delete_application_credential(self, user, application_credential,
1304                                      ignore_missing=True):
1305        """Delete an application credential
1306
1307        :param user: Either the ID of a user or a
1308                   :class:`~openstack.identity.v3.user.User` instance.
1309        :param application credential: The value can be either the ID of a
1310             application credential or a :class: `~openstack.identity.v3.
1311             application_credential.ApplicationCredential` instance.
1312        :param bool ignore_missing: When set to ``False``
1313            :class:`~openstack.exceptions.ResourceNotFound` will be raised
1314             when the application credential does not exist. When set to
1315             ``True``, no exception will be thrown when attempting to delete
1316             a nonexistent application credential.
1317
1318        :returns: ``None``
1319        """
1320        user = self._get_resource(_user.User, user)
1321        self._delete(_application_credential.ApplicationCredential,
1322                     application_credential,
1323                     user_id=user.id,
1324                     ignore_missing=ignore_missing)
1325
1326    def create_federation_protocol(self, idp_id, **attrs):
1327        """Create a new federation protocol from attributes
1328
1329        :param idp_id: The ID of the identity provider or a
1330            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1331            representing the identity provider the protocol is to be
1332            attached to.
1333        :param dict attrs: Keyword arguments which will be used to create a
1334            :class:`~openstack.identity.v3.federation_protocol.
1335            FederationProtocol`, comprised of the properties on the
1336            FederationProtocol class.
1337
1338        :returns: The results of federation protocol creation
1339        :rtype: :class:`~openstack.identity.v3.federation_protocol.
1340            FederationProtocol`
1341        """
1342
1343        idp_cls = _identity_provider.IdentityProvider
1344        if isinstance(idp_id, idp_cls):
1345            idp_id = idp_id.id
1346        return self._create(_federation_protocol.FederationProtocol,
1347                            idp_id=idp_id, **attrs)
1348
1349    def delete_federation_protocol(self, idp_id, protocol,
1350                                   ignore_missing=True):
1351        """Delete a federation protocol
1352
1353        :param idp_id: The ID of the identity provider or a
1354            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1355            representing the identity provider the protocol is attached to.
1356            Can be None if protocol is a
1357            :class:`~openstack.identity.v3.federation_protocol.
1358            FederationProtocol` instance.
1359        :param protocol: The ID of a federation protocol or a
1360            :class:`~openstack.identity.v3.federation_protocol.
1361            FederationProtocol` instance.
1362        :param bool ignore_missing: When set to ``False``
1363            :class:`~openstack.exceptions.ResourceNotFound` will be raised
1364            when the federation protocol does not exist.  When set to
1365            ``True``, no exception will be set when attempting to delete a
1366            nonexistent federation protocol.
1367
1368        :returns: ``None``
1369        """
1370        cls = _federation_protocol.FederationProtocol
1371        if idp_id is None and isinstance(protocol, cls):
1372            idp_id = protocol.idp_id
1373        idp_cls = _identity_provider.IdentityProvider
1374        if isinstance(idp_id, idp_cls):
1375            idp_id = idp_id.id
1376        self._delete(cls, protocol,
1377                     ignore_missing=ignore_missing, idp_id=idp_id)
1378
1379    def find_federation_protocol(self, idp_id, protocol,
1380                                 ignore_missing=True):
1381        """Find a single federation protocol
1382
1383        :param idp_id: The ID of the identity provider or a
1384            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1385            representing the identity provider the protocol is attached to.
1386        :param protocol: The name or ID of a federation protocol.
1387        :param bool ignore_missing: When set to ``False``
1388            :class:`~openstack.exceptions.ResourceNotFound` will be raised
1389            when the resource does not exist.  When set to ``True``, None will
1390            be returned when attempting to find a nonexistent resource.
1391        :returns: One federation protocol or None
1392        :rtype: :class:`~openstack.identity.v3.federation_protocol.
1393            FederationProtocol`
1394        """
1395        idp_cls = _identity_provider.IdentityProvider
1396        if isinstance(idp_id, idp_cls):
1397            idp_id = idp_id.id
1398        return self._find(_federation_protocol.FederationProtocol, protocol,
1399                          ignore_missing=ignore_missing, idp_id=idp_id)
1400
1401    def get_federation_protocol(self, idp_id, protocol):
1402        """Get a single federation protocol
1403
1404        :param idp_id: The ID of the identity provider or a
1405            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1406            representing the identity provider the protocol is attached to.
1407            Can be None if protocol is a
1408            :class:`~openstack.identity.v3.federation_protocol.
1409        :param protocol: The value can be the ID of a federation protocol or a
1410            :class:`~openstack.identity.v3.federation_protocol.
1411            FederationProtocol`
1412            instance.
1413
1414        :returns: One federation protocol
1415        :rtype: :class:`~openstack.identity.v3.federation_protocol.
1416            FederationProtocol`
1417        :raises: :class:`~openstack.exceptions.ResourceNotFound`
1418            when no resource can be found.
1419        """
1420        cls = _federation_protocol.FederationProtocol
1421        if idp_id is None and isinstance(protocol, cls):
1422            idp_id = protocol.idp_id
1423        idp_cls = _identity_provider.IdentityProvider
1424        if isinstance(idp_id, idp_cls):
1425            idp_id = idp_id.id
1426        return self._get(cls, protocol, idp_id=idp_id)
1427
1428    def federation_protocols(self, idp_id, **query):
1429        """Retrieve a generator of federation protocols
1430
1431        :param idp_id: The ID of the identity provider or a
1432            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1433            representing the identity provider the protocol is attached to.
1434        :param kwargs query: Optional query parameters to be sent to limit
1435            the resources being returned.
1436
1437        :returns: A generator of federation protocol instances.
1438        :rtype: :class:`~openstack.identity.v3.federation_protocol.
1439            FederationProtocol`
1440        """
1441        idp_cls = _identity_provider.IdentityProvider
1442        if isinstance(idp_id, idp_cls):
1443            idp_id = idp_id.id
1444        return self._list(_federation_protocol.FederationProtocol,
1445                          idp_id=idp_id, **query)
1446
1447    def update_federation_protocol(self, idp_id, protocol, **attrs):
1448        """Update a federation protocol
1449
1450        :param idp_id: The ID of the identity provider or a
1451            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1452            representing the identity provider the protocol is attached to.
1453            Can be None if protocol is a
1454            :class:`~openstack.identity.v3.federation_protocol.
1455        :param protocol: Either the ID of a federation protocol or a
1456            :class:`~openstack.identity.v3.federation_protocol.
1457            FederationProtocol` instance.
1458        :attrs kwargs: The attributes to update on the federation protocol
1459            represented by ``value``.
1460
1461        :returns: The updated federation protocol
1462        :rtype: :class:`~openstack.identity.v3.federation_protocol.
1463            FederationProtocol`
1464        """
1465        cls = _federation_protocol.FederationProtocol
1466        if (idp_id is None) and (isinstance(protocol, cls)):
1467            idp_id = protocol.idp_id
1468        idp_cls = _identity_provider.IdentityProvider
1469        if isinstance(idp_id, idp_cls):
1470            idp_id = idp_id.id
1471        return self._update(cls, protocol, idp_id=idp_id, **attrs)
1472
1473    def create_mapping(self, **attrs):
1474        """Create a new mapping from attributes
1475
1476        :param dict attrs: Keyword arguments which will be used to create
1477                           a :class:`~openstack.identity.v3.mapping.Mapping`,
1478                           comprised of the properties on the Mapping class.
1479
1480        :returns: The results of mapping creation
1481        :rtype: :class:`~openstack.identity.v3.mapping.Mapping`
1482        """
1483        return self._create(_mapping.Mapping, **attrs)
1484
1485    def delete_mapping(self, mapping, ignore_missing=True):
1486        """Delete a mapping
1487
1488        :param mapping: The ID of a mapping or a
1489                        :class:`~openstack.identity.v3.mapping.Mapping`
1490                        instance.
1491        :param bool ignore_missing: When set to ``False``
1492                    :class:`~openstack.exceptions.ResourceNotFound` will be
1493                    raised when the mapping does not exist.
1494                    When set to ``True``, no exception will be set when
1495                    attempting to delete a nonexistent mapping.
1496
1497        :returns: ``None``
1498        """
1499        self._delete(_mapping.Mapping, mapping, ignore_missing=ignore_missing)
1500
1501    def find_mapping(self, name_or_id, ignore_missing=True):
1502        """Find a single mapping
1503
1504        :param name_or_id: The name or ID of a mapping.
1505        :param bool ignore_missing: When set to ``False``
1506                    :class:`~openstack.exceptions.ResourceNotFound` will be
1507                    raised when the resource does not exist.
1508                    When set to ``True``, None will be returned when
1509                    attempting to find a nonexistent resource.
1510        :returns: One :class:`~openstack.identity.v3.mapping.Mapping` or None
1511        """
1512        return self._find(_mapping.Mapping, name_or_id,
1513                          ignore_missing=ignore_missing)
1514
1515    def get_mapping(self, mapping):
1516        """Get a single mapping
1517
1518        :param mapping: The value can be the ID of a mapping or a
1519                        :class:`~openstack.identity.v3.mapping.Mapping`
1520                        instance.
1521
1522        :returns: One :class:`~openstack.identity.v3.mapping.Mapping`
1523        :raises: :class:`~openstack.exceptions.ResourceNotFound`
1524                 when no resource can be found.
1525        """
1526        return self._get(_mapping.Mapping, mapping)
1527
1528    def mappings(self, **query):
1529        """Retrieve a generator of mappings
1530
1531        :param kwargs query: Optional query parameters to be sent to limit
1532                                 the resources being returned.
1533
1534        :returns: A generator of mapping instances.
1535        :rtype: :class:`~openstack.identity.v3.mapping.Mapping`
1536        """
1537        return self._list(_mapping.Mapping, **query)
1538
1539    def update_mapping(self, mapping, **attrs):
1540        """Update a mapping
1541
1542        :param mapping: Either the ID of a mapping or a
1543                        :class:`~openstack.identity.v3.mapping.Mapping`
1544                        instance.
1545        :attrs kwargs: The attributes to update on the mapping represented
1546                       by ``value``.
1547
1548        :returns: The updated mapping
1549        :rtype: :class:`~openstack.identity.v3.mapping.Mapping`
1550        """
1551        return self._update(_mapping.Mapping, mapping, **attrs)
1552
1553    def create_identity_provider(self, **attrs):
1554        """Create a new identity provider from attributes
1555
1556        :param dict attrs: Keyword arguments which will be used to create a
1557            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1558            comprised of the properties on the IdentityProvider class.
1559
1560        :returns: The results of identity provider creation
1561        :rtype:
1562            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1563        """
1564        return self._create(_identity_provider.IdentityProvider, **attrs)
1565
1566    def delete_identity_provider(self, identity_provider, ignore_missing=True):
1567        """Delete an identity provider
1568
1569        :param mapping: The ID of an identity provoder or a
1570            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1571            instance.
1572        :param bool ignore_missing: When set to ``False``
1573            :class:`~openstack.exceptions.ResourceNotFound` will be
1574            raised when the identity provider does not exist.
1575            When set to ``True``, no exception will be set when
1576            attempting to delete a nonexistent identity provider.
1577
1578        :returns: ``None``
1579        """
1580        self._delete(_identity_provider.IdentityProvider, identity_provider,
1581                     ignore_missing=ignore_missing)
1582
1583    def find_identity_provider(self, name_or_id, ignore_missing=True):
1584        """Find a single identity provider
1585
1586        :param name_or_id: The name or ID of an identity provider
1587        :param bool ignore_missing: When set to ``False``
1588            :class:`~openstack.exceptions.ResourceNotFound` will be
1589            raised when the resource does not exist.
1590            When set to ``True``, None will be returned when
1591            attempting to find a nonexistent resource.
1592        :returns: The details of an identity provider or None.
1593        :rtype:
1594            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1595        """
1596        return self._find(_identity_provider.IdentityProvider, name_or_id,
1597                          ignore_missing=ignore_missing)
1598
1599    def get_identity_provider(self, identity_provider):
1600        """Get a single mapping
1601
1602        :param mapping: The value can be the ID of an identity provider or a
1603            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1604            instance.
1605
1606        :returns: The details of an identity provider.
1607        :rtype:
1608            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1609        :raises: :class:`~openstack.exceptions.ResourceNotFound`
1610            when no resource can be found.
1611        """
1612        return self._get(_identity_provider.IdentityProvider,
1613                         identity_provider)
1614
1615    def identity_providers(self, **query):
1616        """Retrieve a generator of identity providers
1617
1618        :param kwargs query: Optional query parameters to be sent to limit
1619            the resources being returned.
1620
1621        :returns: A generator of identity provider instances.
1622        :rtype:
1623            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1624        """
1625        return self._list(_identity_provider.IdentityProvider, **query)
1626
1627    def update_identity_provider(self, identity_provider, **attrs):
1628        """Update a mapping
1629
1630        :param mapping: Either the ID of an identity provider or a
1631            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1632            instance.
1633        :attrs kwargs: The attributes to update on the identity_provider
1634            represented by ``value``.
1635
1636        :returns: The updated identity provider.
1637        :rtype:
1638            :class:`~openstack.identity.v3.identity_provider.IdentityProvider`
1639        """
1640        return self._update(_identity_provider.IdentityProvider,
1641                            identity_provider, **attrs)
1642