"Fossies" - the Fresh Open Source Software Archive

Member "barbican-12.0.0/barbican/common/policies/orders.py" (14 Apr 2021, 2374 Bytes) of package /linux/misc/openstack/barbican-12.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.

    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 from oslo_policy import policy
   14 
   15 _MEMBER = "role:member"
   16 
   17 rules = [
   18     policy.DocumentedRuleDefault(
   19         name='orders:get',
   20         check_str=f'rule:all_but_audit or {_MEMBER}',
   21         scope_types=['project'],
   22         description='Gets list of all orders associated with a project.',
   23         operations=[
   24             {
   25                 'path': '/v1/orders',
   26                 'method': 'GET'
   27             }
   28         ]
   29     ),
   30     policy.DocumentedRuleDefault(
   31         name='orders:post',
   32         check_str=f'rule:admin_or_creator or {_MEMBER}',
   33         scope_types=['project'],
   34         description='Creates an order.',
   35         operations=[
   36             {
   37                 'path': '/v1/orders',
   38                 'method': 'POST'
   39             }
   40         ]
   41     ),
   42     policy.DocumentedRuleDefault(
   43         name='orders:put',
   44         check_str=f'rule:admin_or_creator or {_MEMBER}',
   45         scope_types=['project'],
   46         description='Unsupported method for the orders API.',
   47         operations=[
   48             {
   49                 'path': '/v1/orders',
   50                 'method': 'PUT'
   51             }
   52         ]
   53     ),
   54     policy.DocumentedRuleDefault(
   55         name='order:get',
   56         check_str=f'rule:all_users or {_MEMBER}',
   57         scope_types=['project'],
   58         description='Retrieves an orders metadata.',
   59         operations=[
   60             {
   61                 'path': '/v1/orders/{order-id}',
   62                 'method': 'GET'
   63             }
   64         ]
   65     ),
   66     policy.DocumentedRuleDefault(
   67         name='order:delete',
   68         check_str=f'rule:admin or {_MEMBER}',
   69         scope_types=['project'],
   70         description='Deletes an order.',
   71         operations=[
   72             {
   73                 'path': '/v1/orders/{order-id}',
   74                 'method': 'DELETE'
   75             }
   76         ],
   77     )
   78 ]
   79 
   80 
   81 def list_rules():
   82     return rules