From 0b5cf0017175680fe0b027ab759e5aae3cba5d26 Mon Sep 17 00:00:00 2001 From: Joe Heck Date: Sun, 24 Jun 2012 11:59:21 -0700 Subject: documenting models fixes bug 928441, moved models into keystone.common.models and roughly documented required and optional fields for various backends. rebased off master. Change-Id: I711fe462c09836904a0ee238444c9f04b64a8ade --- keystone/common/models.py | 127 ++++++++++++++++++++++++++++++++ keystone/identity/backends/ldap/core.py | 2 +- keystone/identity/models.py | 77 ------------------- 3 files changed, 128 insertions(+), 78 deletions(-) create mode 100644 keystone/common/models.py delete mode 100644 keystone/identity/models.py diff --git a/keystone/common/models.py b/keystone/common/models.py new file mode 100644 index 00000000..2710c12e --- /dev/null +++ b/keystone/common/models.py @@ -0,0 +1,127 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright (C) 2011 OpenStack LLC. +# +# 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. + +"""Base model for keystone internal services + +Unless marked otherwise, all fields are strings. + +""" + + +class Model(dict): + """Base model class.""" + + @property + def known_keys(cls): + return cls.required_keys + cls.optional_keys + + +class Token(Model): + """Token object. + + Required keys: + id + expires (datetime) + + Optional keys: + user + tenant + metadata + """ + + required_keys = ('id', 'expires') + optional_keys = ('extra',) + + +class Service(Model): + """Service object. + + Required keys: + id + type + name + + Optional keys: + """ + + required_keys = ('id', 'type', 'name') + optional_keys = tuple() + + +class Endpoint(Model): + """Endpoint object + + Required keys: + id + region + service_id + + Optional keys: + internalurl + publicurl + adminurl + """ + + required_keys = ('id', 'region', 'service_id') + optional_keys = ('interalurl', 'publicurl', 'adminurl') + + +class User(Model): + """User object. + + Required keys: + id + name + + Optional keys: + password + description + email + enabled (bool, default True) + """ + + required_keys = ('id', 'name') + optional_keys = ('password', 'description', 'email', 'enabled') + + +class Tenant(Model): + """Tenant object. + + Required keys: + id + name + + Optional Keys: + description + enabled (bool, default True) + + """ + + required_keys = ('id', 'name') + optional_keys = ('description', 'enabled') + + +class Role(Model): + """Role object. + + Required keys: + id + name + + """ + + required_keys = ('id', 'name') + optional_keys = tuple() diff --git a/keystone/identity/backends/ldap/core.py b/keystone/identity/backends/ldap/core.py index 9a44f65e..f1a69c90 100644 --- a/keystone/identity/backends/ldap/core.py +++ b/keystone/identity/backends/ldap/core.py @@ -26,7 +26,7 @@ from keystone.common import utils from keystone import config from keystone import exception from keystone import identity -from keystone.identity import models +from keystone.common import models CONF = config.CONF diff --git a/keystone/identity/models.py b/keystone/identity/models.py deleted file mode 100644 index bee66368..00000000 --- a/keystone/identity/models.py +++ /dev/null @@ -1,77 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Copyright (C) 2011 OpenStack LLC. -# -# 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. - -"""Model descriptions. - -Unless marked otherwise, all fields are strings. - -""" - - -class Model(dict): - """Base model class.""" - - @property - def known_keys(cls): - return cls.required_keys + cls.optional_keys - - -class User(Model): - """User object. - - Required keys: - id - name - - Optional keys: - password - description - email - enabled (bool, default True) - """ - - required_keys = ('id', 'name') - optional_keys = ('password', 'description', 'email', 'enabled') - - -class Tenant(Model): - """Tenant object. - - Required keys: - id - name - - Optional Keys: - description - enabled (bool, default True) - - """ - - required_keys = ('id', 'name') - optional_keys = ('description', 'enabled') - - -class Role(Model): - """Role object. - - Required keys: - id - name - - """ - - required_keys = ('id', 'name') - optional_keys = tuple() -- cgit