keystone  18.0.0
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 "Victoria" series (maintained release).
  Fossies Dox: keystone-18.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

services.py
Go to the documentation of this file.
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 
13 # This file handles all flask-restful resources for /v3/services
14 
15 import http.client
16 
17 from keystone.catalog import schema
18 from keystone.common import provider_api
19 from keystone.common import rbac_enforcer
20 from keystone.common import validation
21 from keystone.server import flask as ks_flask
22 
23 
24 ENFORCER = rbac_enforcer.RBACEnforcer
25 PROVIDERS = provider_api.ProviderAPIs
26 
27 
28 class ServicesResource(ks_flask.ResourceBase):
29  collection_key = 'services'
30  member_key = 'service'
31 
32  def _get_service(self, service_id):
33  ENFORCER.enforce_call(action='identity:get_service')
34  return self.wrap_member(PROVIDERS.catalog_api.get_service(service_id))
35 
36  def _list_service(self):
37  filters = ['type', 'name']
38  ENFORCER.enforce_call(action='identity:list_services', filters=filters)
39  hints = self.build_driver_hints(filters)
40  refs = PROVIDERS.catalog_api.list_services(hints=hints)
41  return self.wrap_collection(refs, hints=hints)
42 
43  def get(self, service_id=None):
44  if service_id is not None:
45  return self._get_service(service_id)
46  return self._list_service()
47 
48  def post(self):
49  ENFORCER.enforce_call(action='identity:create_service')
50  service = self.request_body_json.get('service')
51  validation.lazy_validate(schema.service_create, service)
52  service = self._assign_unique_id(self._normalize_dict(service))
53  ref = PROVIDERS.catalog_api.create_service(
54  service['id'], service, initiator=self.audit_initiator)
55  return self.wrap_member(ref), http.client.CREATED
56 
57  def patch(self, service_id):
58  ENFORCER.enforce_call(action='identity:update_service')
59  service = self.request_body_json.get('service')
60  validation.lazy_validate(schema.service_update, service)
61  self._require_matching_id(service)
62  ref = PROVIDERS.catalog_api.update_service(
63  service_id, service, initiator=self.audit_initiator)
64  return self.wrap_member(ref)
65 
66  def delete(self, service_id):
67  ENFORCER.enforce_call(action='identity:delete_service')
68  return PROVIDERS.catalog_api.delete_service(
69  service_id, initiator=self.audit_initiator), http.client.NO_CONTENT
70 
71 
72 class ServiceAPI(ks_flask.APIBase):
73  _name = 'services'
74  _import_name = __name__
75  resources = [ServicesResource]
76  resource_mapping = []
77 
78 
79 APIs = (ServiceAPI,)
keystone.api.services.ServicesResource._get_service
def _get_service(self, service_id)
Definition: services.py:32
keystone.api.services.ServicesResource.patch
def patch(self, service_id)
Definition: services.py:57
keystone.catalog
Definition: __init__.py:1
keystone.api.services.ServicesResource
Definition: services.py:28
keystone.api.services.ServicesResource.post
def post(self)
Definition: services.py:48
keystone.api.services.ServiceAPI
Definition: services.py:72
keystone.server
Definition: __init__.py:1
keystone.api.services.ServicesResource.delete
def delete(self, service_id)
Definition: services.py:66
keystone.common
Definition: __init__.py:1
keystone.api.services.ServicesResource._list_service
def _list_service(self)
Definition: services.py:36
keystone.api.services.ServicesResource.get
def get(self, service_id=None)
Definition: services.py:43