2013-09-20 04:30:41 +08:00
|
|
|
# Copyright 2011 OpenStack Foundation
|
2012-09-11 12:32:01 -05:00
|
|
|
# Copyright 2011 Nebula, Inc.
|
|
|
|
# All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
from keystoneclient import base
|
|
|
|
|
|
|
|
|
|
|
|
class Domain(base.Resource):
|
|
|
|
"""Represents an Identity domain.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
* id: a uuid that identifies the domain
|
2016-08-19 18:47:43 +05:30
|
|
|
* name: the name of the domain
|
|
|
|
* description: a description of the domain
|
|
|
|
* enabled: determines whether the domain is enabled
|
2012-09-11 12:32:01 -05:00
|
|
|
|
|
|
|
"""
|
2016-05-03 18:08:31 +00:00
|
|
|
|
2012-09-11 12:32:01 -05:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class DomainManager(base.CrudManager):
|
|
|
|
"""Manager class for manipulating Identity domains."""
|
2016-05-03 18:08:31 +00:00
|
|
|
|
2012-09-11 12:32:01 -05:00
|
|
|
resource_class = Domain
|
|
|
|
collection_key = 'domains'
|
|
|
|
key = 'domain'
|
|
|
|
|
2014-01-07 16:41:17 -05:00
|
|
|
def create(self, name, description=None, enabled=True, **kwargs):
|
2016-06-20 16:53:08 +05:30
|
|
|
"""Create a domain.
|
|
|
|
|
|
|
|
:param str name: the name of the domain.
|
|
|
|
:param str description: a description of the domain.
|
|
|
|
:param bool enabled: whether the domain is enabled.
|
|
|
|
:param kwargs: any other attribute provided will be passed to the
|
|
|
|
server.
|
|
|
|
|
|
|
|
:returns: the created domain returned from server.
|
|
|
|
:rtype: :class:`keystoneclient.v3.domains.Domain`
|
|
|
|
|
|
|
|
"""
|
2012-09-11 12:32:01 -05:00
|
|
|
return super(DomainManager, self).create(
|
|
|
|
name=name,
|
|
|
|
description=description,
|
2014-01-07 16:41:17 -05:00
|
|
|
enabled=enabled,
|
|
|
|
**kwargs)
|
2012-09-11 12:32:01 -05:00
|
|
|
|
|
|
|
def get(self, domain):
|
2016-06-20 16:53:08 +05:30
|
|
|
"""Retrieve a domain.
|
|
|
|
|
|
|
|
:param domain: the domain to be retrieved from the server.
|
|
|
|
:type domain: str or :class:`keystoneclient.v3.domains.Domain`
|
|
|
|
|
|
|
|
:returns: the specified domain returned from server.
|
|
|
|
:rtype: :class:`keystoneclient.v3.domains.Domain`
|
|
|
|
|
|
|
|
"""
|
2012-09-11 12:32:01 -05:00
|
|
|
return super(DomainManager, self).get(
|
|
|
|
domain_id=base.getid(domain))
|
|
|
|
|
2014-01-07 16:41:17 -05:00
|
|
|
def list(self, **kwargs):
|
|
|
|
"""List domains.
|
2013-01-29 16:08:28 -06:00
|
|
|
|
2016-06-20 16:53:08 +05:30
|
|
|
:param kwargs: allows filter criteria to be passed where
|
2014-01-07 16:41:17 -05:00
|
|
|
supported by the server.
|
2016-06-20 16:53:08 +05:30
|
|
|
|
|
|
|
:returns: a list of domains.
|
|
|
|
:rtype: list of :class:`keystoneclient.v3.domains.Domain`.
|
|
|
|
|
2014-01-07 16:41:17 -05:00
|
|
|
"""
|
2014-02-17 11:39:54 +00:00
|
|
|
# Ref bug #1267530 we have to pass 0 for False to get the expected
|
|
|
|
# results on all keystone versions
|
|
|
|
if kwargs.get('enabled') is False:
|
|
|
|
kwargs['enabled'] = 0
|
2014-01-07 16:41:17 -05:00
|
|
|
return super(DomainManager, self).list(**kwargs)
|
|
|
|
|
|
|
|
def update(self, domain, name=None,
|
2014-12-30 17:14:48 +08:00
|
|
|
description=None, enabled=None, **kwargs):
|
2016-06-20 16:53:08 +05:30
|
|
|
"""Update a domain.
|
|
|
|
|
|
|
|
:param domain: the domain to be updated on the server.
|
|
|
|
:type domain: str or :class:`keystoneclient.v3.domains.Domain`
|
|
|
|
:param str name: the new name of the domain.
|
|
|
|
:param str description: the new description of the domain.
|
|
|
|
:param bool enabled: whether the domain is enabled.
|
|
|
|
:param kwargs: any other attribute provided will be passed to the
|
|
|
|
server.
|
|
|
|
|
|
|
|
:returns: the updated domain returned from server.
|
|
|
|
:rtype: :class:`keystoneclient.v3.domains.Domain`
|
|
|
|
|
|
|
|
"""
|
2012-09-11 12:32:01 -05:00
|
|
|
return super(DomainManager, self).update(
|
|
|
|
domain_id=base.getid(domain),
|
|
|
|
name=name,
|
|
|
|
description=description,
|
2014-01-07 16:41:17 -05:00
|
|
|
enabled=enabled,
|
|
|
|
**kwargs)
|
2012-09-11 12:32:01 -05:00
|
|
|
|
|
|
|
def delete(self, domain):
|
2023-02-17 09:06:59 -06:00
|
|
|
"""Delete a domain.
|
2016-06-20 16:53:08 +05:30
|
|
|
|
|
|
|
:param domain: the domain to be deleted on the server.
|
|
|
|
:type domain: str or :class:`keystoneclient.v3.domains.Domain`
|
|
|
|
|
2016-08-17 15:32:14 +01:00
|
|
|
:returns: Response object with 204 status.
|
|
|
|
:rtype: :class:`requests.models.Response`
|
2016-06-20 16:53:08 +05:30
|
|
|
|
|
|
|
"""
|
2012-09-11 12:32:01 -05:00
|
|
|
return super(DomainManager, self).delete(
|
|
|
|
domain_id=base.getid(domain))
|