Alex Meade 53cfde43b8 User messages API for error cases
This patch implements basic user messages with the following APIs.
GET /messages
GET /messages/<message_id>
DELETE /messages/<message_id>

Implements : blueprint summarymessage

Co-Authored-By: Alex Meade <mr.alex.meade@gmail.com>
Co-Authored-By: Sheel Rana <ranasheel2000@gmail.com>

Change-Id: Id8a4a700c1159be24b15056f401a2ea77804d0a0
2016-04-29 18:41:10 +00:00

43 lines
1.4 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import datetime
import iso8601
from cinder.message import defined_messages
from cinder.tests.unit import fake_constants
FAKE_UUID = fake_constants.object_id
def stub_message(id, **kwargs):
message = {
'id': id,
'event_id': defined_messages.UNABLE_TO_ALLOCATE,
'message_level': "ERROR",
'request_id': FAKE_UUID,
'updated_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
tzinfo=iso8601.iso8601.Utc()),
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
tzinfo=iso8601.iso8601.Utc()),
'expires_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
tzinfo=iso8601.iso8601.Utc()),
}
message.update(kwargs)
return message
def stub_message_get(self, context, message_id):
return stub_message(message_id)