"Fossies" - the Fresh Open Source Software Archive

Member "keystone-17.0.0/keystone/limit/backends/base.py" (13 May 2020, 5766 Bytes) of package /linux/misc/openstack/keystone-17.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "base.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 16.0.1_vs_17.0.0.

    1 # Copyright 2017 SUSE Linux Gmbh
    2 # Copyright 2017 Huawei
    3 #
    4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    5 # not use this file except in compliance with the License. You may obtain
    6 # a copy of the License at
    7 #
    8 #      http://www.apache.org/licenses/LICENSE-2.0
    9 #
   10 # Unless required by applicable law or agreed to in writing, software
   11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   13 # License for the specific language governing permissions and limitations
   14 # under the License.
   15 
   16 import abc
   17 
   18 import keystone.conf
   19 from keystone import exception
   20 
   21 
   22 CONF = keystone.conf.CONF
   23 
   24 
   25 class UnifiedLimitDriverBase(object, metaclass=abc.ABCMeta):
   26 
   27     def _get_list_limit(self):
   28         return CONF.unified_limit.list_limit or CONF.list_limit
   29 
   30     @abc.abstractmethod
   31     def create_registered_limits(self, registered_limits):
   32         """Create new registered limits.
   33 
   34         :param registered_limits: a list of dictionaries representing limits to
   35                                   create.
   36 
   37         :returns: all the newly created registered limits.
   38         :raises keystone.exception.Conflict: If a duplicate registered limit
   39             exists.
   40 
   41         """
   42         raise exception.NotImplemented()  # pragma: no cover
   43 
   44     @abc.abstractmethod
   45     def update_registered_limit(self, registered_limit_id, registered_limit):
   46         """Update existing registered limits.
   47 
   48         :param registered_limit_id: the id of the registered limit.
   49         :param registered_limit: a dict containing the registered limit
   50                                  attributes to update.
   51         :returns: the updated registered limit.
   52         :raises keystone.exception.RegisteredLimitNotFound: If registered limit
   53             doesn't exist.
   54         :raises keystone.exception.Conflict: If update to a duplicate
   55             registered limit.
   56 
   57         """
   58         raise exception.NotImplemented()  # pragma: no cover
   59 
   60     @abc.abstractmethod
   61     def list_registered_limits(self, hints):
   62         """List all registered limits.
   63 
   64         :param hints: contains the list of filters yet to be satisfied.
   65                       Any filters satisfied here will be removed so that
   66                       the caller will know if any filters remain.
   67 
   68         :returns: a list of dictionaries or an empty registered limit.
   69 
   70         """
   71         raise exception.NotImplemented()  # pragma: no cover
   72 
   73     @abc.abstractmethod
   74     def get_registered_limit(self, registered_limit_id):
   75         """Get a registered limit.
   76 
   77         :param registered_limit_id: the registered limit id to get.
   78 
   79         :returns: a dictionary representing a registered limit reference.
   80         :raises keystone.exception.RegisteredLimitNotFound: If registered limit
   81             doesn't exist.
   82 
   83         """
   84         raise exception.NotImplemented()  # pragma: no cover
   85 
   86     @abc.abstractmethod
   87     def delete_registered_limit(self, registered_limit_id):
   88         """Delete an existing registered limit.
   89 
   90         :param registered_limit_id: the registered limit id to delete.
   91 
   92         :raises keystone.exception.RegisteredLimitNotFound: If registered limit
   93             doesn't exist.
   94 
   95         """
   96         raise exception.NotImplemented()  # pragma: no cover
   97 
   98     @abc.abstractmethod
   99     def create_limits(self, limits):
  100         """Create new limits.
  101 
  102         :param limits: a list of dictionaries representing limits to create.
  103 
  104         :returns: all the newly created limits.
  105         :raises keystone.exception.Conflict: If a duplicate limit exists.
  106         :raises keystone.exception.NoLimitReference: If no reference registered
  107             limit exists.
  108 
  109         """
  110         raise exception.NotImplemented()  # pragma: no cover
  111 
  112     @abc.abstractmethod
  113     def update_limit(self, limit_id, limit):
  114         """Update existing limits.
  115 
  116         :param limit_id: the id of the limit.
  117         :param limit: a dict containing the limit attributes to update.
  118 
  119         :returns: the updated limit.
  120         :raises keystone.exception.LimitNotFound: If limit doesn't
  121             exist.
  122         :raises keystone.exception.Conflict: If update to a duplicate limit.
  123 
  124         """
  125         raise exception.NotImplemented()  # pragma: no cover
  126 
  127     @abc.abstractmethod
  128     def list_limits(self, hints):
  129         """List all limits.
  130 
  131         :param hints: contains the list of filters yet to be satisfied.
  132                       Any filters satisfied here will be removed so that
  133                       the caller will know if any filters remain.
  134 
  135         :returns: a list of dictionaries or an empty list.
  136 
  137         """
  138         raise exception.NotImplemented()  # pragma: no cover
  139 
  140     @abc.abstractmethod
  141     def get_limit(self, limit_id):
  142         """Get a limit.
  143 
  144         :param limit_id: the limit id to get.
  145 
  146         :returns: a dictionary representing a limit reference.
  147         :raises keystone.exception.LimitNotFound: If limit doesn't
  148             exist.
  149 
  150         """
  151         raise exception.NotImplemented()  # pragma: no cover
  152 
  153     @abc.abstractmethod
  154     def delete_limit(self, limit_id):
  155         """Delete an existing limit.
  156 
  157         :param limit_id: the limit id to delete.
  158 
  159         :raises keystone.exception.LimitNotFound: If limit doesn't
  160             exist.
  161 
  162         """
  163         raise exception.NotImplemented()  # pragma: no cover
  164 
  165     @abc.abstractmethod
  166     def delete_limits_for_project(self, project_id):
  167         """Delete the existing limits which belong to the specified project.
  168 
  169         :param project_id: the limits' project id.
  170 
  171         :returns: a dictionary representing the deleted limits id. Used for
  172             cache invalidating.
  173 
  174         """
  175         raise exception.NotImplemented()  # pragma: no cover