Merge "Move json_home "extension" rel functions"

This commit is contained in:
Zuul 2018-08-25 00:22:55 +00:00 committed by Gerrit Code Review
commit 177c0e6101
7 changed files with 75 additions and 44 deletions

View File

@ -0,0 +1,59 @@
# 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.
# NOTE(morgan): This module contains json_home partial functions for
# what were called "extensions" before. As keystone does not have extensions
# any longer, once Keystone is converted to flask fully, there should be no
# reason to add more elements to this module.
import functools
from keystone.common import json_home
# OS-EP-FILTER "extension"
os_ep_filter_resource_rel_func = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-EP-FILTER', extension_version='1.0')
os_ep_filter_parameter_rel_func = functools.partial(
json_home.build_v3_extension_parameter_relation,
extension_name='OS-EP-FILTER', extension_version='1.0')
# OS-OAUTH1 "extension"
os_oauth1_resource_rel_func = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-OAUTH1', extension_version='1.0')
os_oauth1_parameter_rel_func = functools.partial(
json_home.build_v3_extension_parameter_relation,
extension_name='OS-OAUTH1', extension_version='1.0')
# OS-REVOKE "extension"
os_revoke_resource_rel_func = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-REVOKE', extension_version='1.0')
# OS-SIMPLE-CERT "extension"
os_simple_cert_resource_rel_func = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-SIMPLE-CERT', extension_version='1.0')
# OS-TRUST "extension"
os_trust_resource_rel_func = functools.partial(
json_home.build_v3_extension_resource_relation, extension_name='OS-TRUST',
extension_version='1.0')
os_trust_parameter_rel_func = functools.partial(
json_home.build_v3_extension_parameter_relation, extension_name='OS-TRUST',
extension_version='1.0')
# OS-ENDPOINT-POLICY "extension"
os_endpoint_policy_resource_rel_func = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-ENDPOINT-POLICY', extension_version='1.0')

View File

@ -13,9 +13,9 @@
# This file handles all flask-restful resources for /v3/services
import flask_restful
import functools
from six.moves import http_client
from keystone.api._shared import json_home_relations
from keystone.catalog import schema
from keystone.common import json_home
from keystone.common import provider_api
@ -29,11 +29,7 @@ from keystone.server import flask as ks_flask
ENFORCER = rbac_enforcer.RBACEnforcer
PROVIDERS = provider_api.ProviderAPIs
# TODO(morgan) move the partial functions to a common place so that they
# can be referenced by multiple APIs, such as endpoints and endpoint_policy.
_build_resource_relation = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-ENDPOINT-POLICY', extension_version='1.0')
_resource_rel_func = json_home_relations.os_endpoint_policy_resource_rel_func
def _filter_endpoint(ref):
@ -141,7 +137,7 @@ class EndpointAPI(ks_flask.APIBase):
url='/endpoints/<string:endpoint_id>/OS-ENDPOINT-POLICY/policy',
resource_kwargs={},
rel='endpoint_policy',
resource_relation_func=_build_resource_relation,
resource_relation_func=_resource_rel_func,
path_vars={'endpoint_id': json_home.Parameters.ENDPOINT_ID})
]

View File

@ -13,9 +13,9 @@
# This file handles all flask-restful resources for /OS-EP-FILTER
import flask_restful
import functools
from six.moves import http_client
from keystone.api._shared import json_home_relations
from keystone.api import endpoints as _endpoints_api
from keystone.catalog import schema
from keystone.common import json_home
@ -30,13 +30,8 @@ from keystone.server import flask as ks_flask
ENFORCER = rbac_enforcer.RBACEnforcer
PROVIDERS = provider_api.ProviderAPIs
_build_resource_relation = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-EP-FILTER', extension_version='1.0')
_build_parameter_relation = functools.partial(
json_home.build_v3_extension_parameter_relation,
extension_name='OS-EP-FILTER', extension_version='1.0')
_build_resource_relation = json_home_relations.os_ep_filter_resource_rel_func
_build_parameter_relation = json_home_relations.os_ep_filter_parameter_rel_func
_ENDPOINT_GROUP_PARAMETER_RELATION = _build_parameter_relation(
parameter_name='endpoint_group_id')

View File

@ -12,8 +12,6 @@
# This file handles all flask-restful resources for /v3/OS-OAUTH1/
import functools
import flask
import flask_restful
from oslo_log import log
@ -22,9 +20,9 @@ from six.moves import http_client
from six.moves.urllib import parse as urlparse
from werkzeug import exceptions
from keystone.api._shared import json_home_relations
from keystone.common import authorization
from keystone.common import context
from keystone.common import json_home
from keystone.common import provider_api
from keystone.common import rbac_enforcer
from keystone.common import validation
@ -44,13 +42,8 @@ ENFORCER = rbac_enforcer.RBACEnforcer
CONF = keystone.conf.CONF
_build_resource_relation = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-OAUTH1', extension_version='1.0')
_build_parameter_relation = functools.partial(
json_home.build_v3_extension_parameter_relation,
extension_name='OS-OAUTH1', extension_version='1.0')
_build_resource_relation = json_home_relations.os_oauth1_resource_rel_func
_build_parameter_relation = json_home_relations.os_oauth1_parameter_rel_func
_ACCESS_TOKEN_ID_PARAMETER_RELATION = _build_parameter_relation(
parameter_name='access_token_id')

View File

@ -12,13 +12,11 @@
# This file handles all flask-restful resources for /v3/OS-REVOKE/events
import functools
import flask
import flask_restful
from oslo_utils import timeutils
from keystone.common import json_home
from keystone.api._shared import json_home_relations
from keystone.common import provider_api
from keystone.common import rbac_enforcer
from keystone import exception
@ -30,9 +28,7 @@ PROVIDERS = provider_api.ProviderAPIs
ENFORCER = rbac_enforcer.RBACEnforcer
_build_resource_relation = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-REVOKE', extension_version='1.0')
_build_resource_relation = json_home_relations.os_revoke_resource_rel_func
class OSRevokeResource(flask_restful.Resource):

View File

@ -14,10 +14,9 @@
import flask
import flask_restful
import functools
from six.moves import http_client
from keystone.common import json_home
from keystone.api._shared import json_home_relations
import keystone.conf
from keystone import exception
from keystone.server import flask as ks_flask
@ -26,9 +25,7 @@ from keystone.server import flask as ks_flask
CONF = keystone.conf.CONF
_build_resource_relation = functools.partial(
json_home.build_v3_extension_resource_relation,
extension_name='OS-SIMPLE-CERT', extension_version='1.0')
_build_resource_relation = json_home_relations.os_simple_cert_resource_rel_func
def _get_certificate(name):

View File

@ -15,12 +15,11 @@
# TODO(morgan): Deprecate /v3/OS-TRUST/trusts path in favour of /v3/trusts.
# /v3/OS-TRUST should remain indefinitely.
import functools
import flask
import flask_restful
from six.moves import http_client
from keystone.api._shared import json_home_relations
from keystone.common import context
from keystone.common import json_home
from keystone.common import provider_api
@ -36,12 +35,8 @@ from keystone.trust import schema
ENFORCER = rbac_enforcer.RBACEnforcer
PROVIDERS = provider_api.ProviderAPIs
_build_resource_relation = functools.partial(
json_home.build_v3_extension_resource_relation, extension_name='OS-TRUST',
extension_version='1.0')
_build_parameter_relation = functools.partial(
json_home.build_v3_extension_parameter_relation, extension_name='OS-TRUST',
extension_version='1.0')
_build_resource_relation = json_home_relations.os_trust_resource_rel_func
_build_parameter_relation = json_home_relations.os_trust_parameter_rel_func
TRUST_ID_PARAMETER_RELATION = _build_parameter_relation(
parameter_name='trust_id')