Coverage for manila/policies/message.py: 100%
11 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
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.
13from oslo_log import versionutils
14from oslo_policy import policy
16from manila.policies import base
19BASE_POLICY_NAME = 'message:%s'
21DEPRECATED_REASON = """
22The messages API now supports scope and default roles.
23"""
25deprecated_message_get = policy.DeprecatedRule(
26 name=BASE_POLICY_NAME % 'get',
27 check_str=base.RULE_DEFAULT,
28 deprecated_reason=DEPRECATED_REASON,
29 deprecated_since=versionutils.deprecated.WALLABY
30)
31deprecated_message_get_all = policy.DeprecatedRule(
32 name=BASE_POLICY_NAME % 'get_all',
33 check_str=base.RULE_DEFAULT,
34 deprecated_reason=DEPRECATED_REASON,
35 deprecated_since=versionutils.deprecated.WALLABY
36)
37deprecated_message_delete = policy.DeprecatedRule(
38 name=BASE_POLICY_NAME % 'delete',
39 check_str=base.RULE_DEFAULT,
40 deprecated_reason=DEPRECATED_REASON,
41 deprecated_since=versionutils.deprecated.WALLABY
42)
45message_policies = [
46 policy.DocumentedRuleDefault(
47 name=BASE_POLICY_NAME % 'get',
48 check_str=base.ADMIN_OR_PROJECT_READER,
49 scope_types=['project'],
50 description="Get details of a given message.",
51 operations=[
52 {
53 'method': 'GET',
54 'path': '/messages/{message_id}'
55 }
56 ],
57 deprecated_rule=deprecated_message_get
58 ),
59 policy.DocumentedRuleDefault(
60 name=BASE_POLICY_NAME % 'get_all',
61 check_str=base.ADMIN_OR_PROJECT_READER,
62 scope_types=['project'],
63 description="Get all messages.",
64 operations=[
65 {
66 'method': 'GET',
67 'path': '/messages'
68 },
69 {
70 'method': 'GET',
71 'path': '/messages?{query}'
72 }
73 ],
74 deprecated_rule=deprecated_message_get_all
75 ),
76 policy.DocumentedRuleDefault(
77 name=BASE_POLICY_NAME % 'delete',
78 check_str=base.ADMIN_OR_PROJECT_MEMBER,
79 scope_types=['project'],
80 description="Delete a message.",
81 operations=[
82 {
83 'method': 'DELETE',
84 'path': '/messages/{message_id}'
85 }
86 ],
87 deprecated_rule=deprecated_message_delete
88 ),
89]
92def list_rules():
93 return message_policies