"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/api/os_ep_filter.py" between
keystone-16.0.1.tar.gz and keystone-17.0.0.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Ussuri" series (latest release).

os_ep_filter.py  (keystone-16.0.1):os_ep_filter.py  (keystone-17.0.0)
skipping to change at line 16 skipping to change at line 16
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
# This file handles all flask-restful resources for /OS-EP-FILTER # This file handles all flask-restful resources for /OS-EP-FILTER
import flask_restful import flask_restful
from six.moves import http_client import http.client
from keystone.api._shared import json_home_relations from keystone.api._shared import json_home_relations
from keystone.api import endpoints as _endpoints_api from keystone.api import endpoints as _endpoints_api
from keystone.catalog import schema from keystone.catalog import schema
from keystone.common import json_home from keystone.common import json_home
from keystone.common import provider_api from keystone.common import provider_api
from keystone.common import rbac_enforcer from keystone.common import rbac_enforcer
from keystone.common import validation from keystone.common import validation
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _
skipping to change at line 90 skipping to change at line 90
ep_group = self.request_body_json.get('endpoint_group', {}) ep_group = self.request_body_json.get('endpoint_group', {})
validation.lazy_validate(schema.endpoint_group_create, ep_group) validation.lazy_validate(schema.endpoint_group_create, ep_group)
if not ep_group.get('filters'): if not ep_group.get('filters'):
# TODO(morgan): Make this not require substitution. Substitution is # TODO(morgan): Make this not require substitution. Substitution is
# done here due to String Freeze in the Rocky release. # done here due to String Freeze in the Rocky release.
msg = _('%s field is required and cannot be empty') % 'filters' msg = _('%s field is required and cannot be empty') % 'filters'
raise exception.ValidationError(message=msg) raise exception.ValidationError(message=msg)
self._require_valid_filter(ep_group) self._require_valid_filter(ep_group)
ep_group = self._assign_unique_id(ep_group) ep_group = self._assign_unique_id(ep_group)
return self.wrap_member(PROVIDERS.catalog_api.create_endpoint_group( return self.wrap_member(PROVIDERS.catalog_api.create_endpoint_group(
ep_group['id'], ep_group)), http_client.CREATED ep_group['id'], ep_group)), http.client.CREATED
def patch(self, endpoint_group_id): def patch(self, endpoint_group_id):
ENFORCER.enforce_call(action='identity:update_endpoint_group') ENFORCER.enforce_call(action='identity:update_endpoint_group')
ep_group = self.request_body_json.get('endpoint_group', {}) ep_group = self.request_body_json.get('endpoint_group', {})
validation.lazy_validate(schema.endpoint_group_update, ep_group) validation.lazy_validate(schema.endpoint_group_update, ep_group)
if 'filters' in ep_group: if 'filters' in ep_group:
self._require_valid_filter(ep_group) self._require_valid_filter(ep_group)
self._require_matching_id(ep_group) self._require_matching_id(ep_group)
return self.wrap_member(PROVIDERS.catalog_api.update_endpoint_group( return self.wrap_member(PROVIDERS.catalog_api.update_endpoint_group(
endpoint_group_id, ep_group)) endpoint_group_id, ep_group))
def delete(self, endpoint_group_id): def delete(self, endpoint_group_id):
ENFORCER.enforce_call(action='identity:delete_endpoint_group') ENFORCER.enforce_call(action='identity:delete_endpoint_group')
return (PROVIDERS.catalog_api.delete_endpoint_group(endpoint_group_id), return (PROVIDERS.catalog_api.delete_endpoint_group(endpoint_group_id),
http_client.NO_CONTENT) http.client.NO_CONTENT)
class EPFilterEndpointProjectsResource(flask_restful.Resource): class EPFilterEndpointProjectsResource(flask_restful.Resource):
def get(self, endpoint_id): def get(self, endpoint_id):
""""Return a list of projects associated with the endpoint.""" """"Return a list of projects associated with the endpoint."""
ENFORCER.enforce_call(action='identity:list_projects_for_endpoint') ENFORCER.enforce_call(action='identity:list_projects_for_endpoint')
PROVIDERS.catalog_api.get_endpoint(endpoint_id) PROVIDERS.catalog_api.get_endpoint(endpoint_id)
refs = PROVIDERS.catalog_api.list_projects_for_endpoint(endpoint_id) refs = PROVIDERS.catalog_api.list_projects_for_endpoint(endpoint_id)
projects = [PROVIDERS.resource_api.get_project(ref['project_id']) projects = [PROVIDERS.resource_api.get_project(ref['project_id'])
for ref in refs] for ref in refs]
return ks_flask.ResourceBase.wrap_collection( return ks_flask.ResourceBase.wrap_collection(
projects, collection_name='projects') projects, collection_name='projects')
class EPFilterProjectsEndpointsResource(flask_restful.Resource): class EPFilterProjectsEndpointsResource(flask_restful.Resource):
def get(self, project_id, endpoint_id): def get(self, project_id, endpoint_id):
ENFORCER.enforce_call(action='identity:check_endpoint_in_project') ENFORCER.enforce_call(action='identity:check_endpoint_in_project')
PROVIDERS.catalog_api.get_endpoint(endpoint_id) PROVIDERS.catalog_api.get_endpoint(endpoint_id)
PROVIDERS.resource_api.get_project(project_id) PROVIDERS.resource_api.get_project(project_id)
PROVIDERS.catalog_api.check_endpoint_in_project( PROVIDERS.catalog_api.check_endpoint_in_project(
endpoint_id, project_id) endpoint_id, project_id)
return None, http_client.NO_CONTENT return None, http.client.NO_CONTENT
def put(self, project_id, endpoint_id): def put(self, project_id, endpoint_id):
ENFORCER.enforce_call(action='identity:add_endpoint_to_project') ENFORCER.enforce_call(action='identity:add_endpoint_to_project')
PROVIDERS.catalog_api.get_endpoint(endpoint_id) PROVIDERS.catalog_api.get_endpoint(endpoint_id)
PROVIDERS.resource_api.get_project(project_id) PROVIDERS.resource_api.get_project(project_id)
PROVIDERS.catalog_api.add_endpoint_to_project(endpoint_id, project_id) PROVIDERS.catalog_api.add_endpoint_to_project(endpoint_id, project_id)
return None, http_client.NO_CONTENT return None, http.client.NO_CONTENT
def delete(self, project_id, endpoint_id): def delete(self, project_id, endpoint_id):
ENFORCER.enforce_call(action='identity:remove_endpoint_from_project') ENFORCER.enforce_call(action='identity:remove_endpoint_from_project')
return (PROVIDERS.catalog_api.remove_endpoint_from_project( return (PROVIDERS.catalog_api.remove_endpoint_from_project(
endpoint_id, project_id), http_client.NO_CONTENT) endpoint_id, project_id), http.client.NO_CONTENT)
class EPFilterProjectEndpointsListResource(flask_restful.Resource): class EPFilterProjectEndpointsListResource(flask_restful.Resource):
def get(self, project_id): def get(self, project_id):
ENFORCER.enforce_call(action='identity:list_endpoints_for_project') ENFORCER.enforce_call(action='identity:list_endpoints_for_project')
PROVIDERS.resource_api.get_project(project_id) PROVIDERS.resource_api.get_project(project_id)
filtered_endpoints = PROVIDERS.catalog_api.list_endpoints_for_project( filtered_endpoints = PROVIDERS.catalog_api.list_endpoints_for_project(
project_id) project_id)
return ks_flask.ResourceBase.wrap_collection( return ks_flask.ResourceBase.wrap_collection(
[_filter_endpoint(v) for v in filtered_endpoints.values()], [_filter_endpoint(v) for v in filtered_endpoints.values()],
skipping to change at line 212 skipping to change at line 212
ref = PROVIDERS.catalog_api.get_endpoint_group_in_project( ref = PROVIDERS.catalog_api.get_endpoint_group_in_project(
endpoint_group_id, project_id) endpoint_group_id, project_id)
return self.wrap_member(ref) return self.wrap_member(ref)
def put(self, endpoint_group_id, project_id): def put(self, endpoint_group_id, project_id):
ENFORCER.enforce_call(action='identity:add_endpoint_group_to_project') ENFORCER.enforce_call(action='identity:add_endpoint_group_to_project')
PROVIDERS.resource_api.get_project(project_id) PROVIDERS.resource_api.get_project(project_id)
PROVIDERS.catalog_api.get_endpoint_group(endpoint_group_id) PROVIDERS.catalog_api.get_endpoint_group(endpoint_group_id)
PROVIDERS.catalog_api.add_endpoint_group_to_project( PROVIDERS.catalog_api.add_endpoint_group_to_project(
endpoint_group_id, project_id) endpoint_group_id, project_id)
return None, http_client.NO_CONTENT return None, http.client.NO_CONTENT
def delete(self, endpoint_group_id, project_id): def delete(self, endpoint_group_id, project_id):
ENFORCER.enforce_call( ENFORCER.enforce_call(
action='identity:remove_endpoint_group_from_project') action='identity:remove_endpoint_group_from_project')
PROVIDERS.resource_api.get_project(project_id) PROVIDERS.resource_api.get_project(project_id)
PROVIDERS.catalog_api.get_endpoint_group(endpoint_group_id) PROVIDERS.catalog_api.get_endpoint_group(endpoint_group_id)
PROVIDERS.catalog_api.remove_endpoint_group_from_project( PROVIDERS.catalog_api.remove_endpoint_group_from_project(
endpoint_group_id, project_id) endpoint_group_id, project_id)
return None, http_client.NO_CONTENT return None, http.client.NO_CONTENT
class EPFilterAPI(ks_flask.APIBase): class EPFilterAPI(ks_flask.APIBase):
_name = 'OS-EP-FILTER' _name = 'OS-EP-FILTER'
_import_name = __name__ _import_name = __name__
_api_url_prefix = '/OS-EP-FILTER' _api_url_prefix = '/OS-EP-FILTER'
resources = [EndpointGroupsResource] resources = [EndpointGroupsResource]
resource_mapping = [ resource_mapping = [
ks_flask.construct_resource_map( ks_flask.construct_resource_map(
resource=EPFilterEndpointProjectsResource, resource=EPFilterEndpointProjectsResource,
url='/endpoints/<string:endpoint_id>/projects', url='/endpoints/<string:endpoint_id>/projects',
 End of changes. 8 change blocks. 
8 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)