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)  

os_revoke.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/OS-REVOKE/events
14 
15 import flask
16 import flask_restful
17 from oslo_utils import timeutils
18 
19 from keystone.api._shared import json_home_relations
20 from keystone.common import provider_api
21 from keystone.common import rbac_enforcer
22 from keystone import exception
23 from keystone.i18n import _
24 from keystone.server import flask as ks_flask
25 
26 
27 PROVIDERS = provider_api.ProviderAPIs
28 ENFORCER = rbac_enforcer.RBACEnforcer
29 
30 
31 _build_resource_relation = json_home_relations.os_revoke_resource_rel_func
32 
33 
34 class OSRevokeResource(flask_restful.Resource):
35  def get(self):
36  ENFORCER.enforce_call(action='identity:list_revoke_events')
37  since = flask.request.args.get('since')
38  last_fetch = None
39  if since:
40  try:
41  last_fetch = timeutils.normalize_time(
42  timeutils.parse_isotime(since))
43  except ValueError:
45  message=_('invalidate date format %s') % since)
46  # FIXME(notmorgan): The revocation events cannot have resource options
47  # added to them or lazy-loaded relationships as long as to_dict
48  # is called outside of an active session context. This API is unused
49  # and should be deprecated in the near future. Fix this before adding
50  # resource_options or any lazy-loaded relationships to the revocation
51  # events themselves.
52  events = PROVIDERS.revoke_api.list_events(last_fetch=last_fetch)
53  # Build the links by hand as the standard controller calls require ids
54  response = {'events': [event.to_dict() for event in events],
55  'links': {
56  'next': None,
57  'self': ks_flask.base_url(path='/OS-REVOKE/events'),
58  'previous': None}
59  }
60  return response
61 
62 
63 class OSRevokeAPI(ks_flask.APIBase):
64  _name = 'events'
65  _import_name = __name__
66  _api_url_prefix = '/OS-REVOKE'
67  resources = []
68  resource_mapping = [
69  ks_flask.construct_resource_map(
70  resource=OSRevokeResource,
71  url='/events',
72  resource_kwargs={},
73  rel='events',
74  resource_relation_func=_build_resource_relation
75  )
76  ]
77 
78 
79 APIs = (OSRevokeAPI,)
keystone.api.os_revoke.OSRevokeResource
Definition: os_revoke.py:34
keystone.exception.ValidationError
Definition: exception.py:98
keystone.api.os_revoke.OSRevokeAPI
Definition: os_revoke.py:63
keystone.server
Definition: __init__.py:1
keystone.i18n._
_
Definition: i18n.py:29
keystone.common
Definition: __init__.py:1
keystone.i18n
Definition: i18n.py:1
keystone.api._shared
Definition: __init__.py:1
keystone.api.os_revoke.OSRevokeResource.get
def get(self)
Definition: os_revoke.py:35