Coverage for manila/api/schemas/messages.py: 100%

13 statements  

« 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. 

12import copy 

13 

14from oslo_config import cfg 

15 

16from manila.api.validation import parameter_types 

17from manila.api.validation import response_types 

18 

19CONF = cfg.CONF 

20 

21 

22show_request_query = { 

23 'type': 'object', 

24 'properties': {}, 

25 'required': [], 

26 # TODO(jonathan): Exclude additional query string parameters in a future 

27 # microversion 

28 'additionalProperties': True, 

29} 

30 

31index_request_query = { 

32 'type': 'object', 

33 'properties': { 

34 'limit': parameter_types.single_param( 

35 parameter_types.non_negative_integer 

36 ), 

37 # NOTE(stephenfin): This is parsed by 'common.get_pagination_params' 

38 # but we ignore it. We may wish to uncomment this when that is no 

39 # longer the case 

40 # 'marker': parameter_types.multi_params({ 

41 # 'type': ['string'], 

42 # }), 

43 'offset': parameter_types.single_param( 

44 parameter_types.non_negative_integer 

45 ), 

46 'sort_key': parameter_types.single_param({ 

47 'type': 'string', 

48 'default': 'created_at', 

49 # TODO(stephenfin): These are the allowed (a.k.a. legal) filter 

50 # keys, but we currently ignore invalid keys. We should add this in 

51 # a future microversion. 

52 # 'enum': [ 

53 # 'id', 

54 # 'project_id', 

55 # 'request_id', 

56 # 'resource_type', 

57 # 'action_id', 

58 # 'detail_id', 

59 # 'resource_id', 

60 # 'message_level', 

61 # 'expires_at', 

62 # 'created_at', 

63 # ], 

64 }), 

65 'sort_dir': parameter_types.single_param({ 

66 'type': 'string', 

67 'default': 'desc', 

68 # TODO(stephenfin): This should be an enum, but we currently treat 

69 # anything != 'desc' as 'asc'. We should make this stricter in a 

70 # future microversion. 

71 # 'enum': ['asc', 'desc'], 

72 }), 

73 'action_id': parameter_types.single_param({ 

74 'type': 'string', 

75 }), 

76 'detail_id': parameter_types.single_param({ 

77 'type': 'string', 

78 }), 

79 # TODO(jonathan) add enum when more message level the 'ERROR' 

80 'message_level': parameter_types.single_param({ 

81 'type': 'string', 

82 }), 

83 'request_id': parameter_types.single_param({ 

84 'type': 'string', 

85 }), 

86 'resource_id': parameter_types.single_param({ 

87 'type': 'string', 

88 }), 

89 'resource_type': parameter_types.multi_params({ 

90 'type': 'string', 

91 }), 

92 }, 

93 'required': [], 

94 # TODO(jonathan): Exclude additional query string parameters in a future 

95 # microversion 

96 'additionalProperties': True, 

97} 

98 

99index_request_query_v252 = copy.deepcopy(index_request_query) 

100index_request_query_v252['properties'].update({ 

101 'created_since': parameter_types.single_param({ 

102 'type': 'string', 

103 'format': 'date-time', 

104 }), 

105 'created_before': parameter_types.single_param({ 

106 'type': 'string', 

107 'format': 'date-time', 

108 }), 

109}) 

110 

111 

112_messages_response = { 

113 'type': 'object', 

114 'properties': { 

115 'action_id': {'type': 'string'}, 

116 'created_at': {'type': 'string', 'format': 'date-time'}, 

117 'detail_id': {'type': 'string'}, 

118 'expires_at': {'type': 'string', 'format': 'date-time'}, 

119 'id': {'type': 'string', 'format': 'uuid'}, 

120 'links': response_types.links, 

121 'message_level': { 

122 'type': 'string', 

123 'enum': ['ERROR'], 

124 }, 

125 'project_id': {'type': 'string'}, 

126 'request_id': {'type': 'string'}, 

127 'resource_id': {'type': 'string', 'format': 'uuid'}, 

128 'resource_type': {'type': 'string'}, 

129 'user_message': {'type': 'string'}, 

130 }, 

131 'required': [ 

132 'action_id', 

133 'created_at', 

134 'detail_id', 

135 'expires_at', 

136 'id', 

137 'links', 

138 'message_level', 

139 'project_id', 

140 'request_id', 

141 'resource_id', 

142 'resource_type', 

143 'user_message', 

144 ], 

145 'additionalProperties': False, 

146} 

147 

148index_response_body = { 

149 'type': 'object', 

150 'properties': { 

151 'messages': { 

152 'type': 'array', 

153 'items': _messages_response, 

154 }, 

155 'messages_links': response_types.collection_links, 

156 }, 

157 'required': ['messages'], 

158 'additionalProperties': False, 

159} 

160 

161show_response_body = { 

162 'type': 'object', 

163 'properties': { 

164 'message': _messages_response, 

165 }, 

166 'required': ['message'], 

167 'additionalProperties': False, 

168} 

169 

170delete_response_body = { 

171 'type': 'null', 

172}