manila/doc/source/contributor/user_messages.rst
Tom Barron 90060722a9 doc migration: new directory layout
This patch introduces a new directory layout
in doc/source in conformance with the OpenStack
manuals project migration spec [1], moves the
existing content in manila/doc/source into the
new directories, and adjusts index files accordingly.

This is the first step in the migration process
as outlined in the spec.

[1] https://specs.openstack.org/openstack/docs-specs/specs/pike/os-manuals-migration.html

Partial-Bug: #1706181
Needed-By: I7924d94b82e7c8d9716bad7a219fc38c57970773
Depends-On: Ifc80fc56648cef74c85464321d1850e8c68449a0
Depends-On: Ia750cb049c0f53a234ea70ce1f2bbbb7a2aa9454
Change-Id: Ieea33262101a1d2459492c1c8aaac5fe042279f6
2017-08-24 09:16:25 -04:00

1.9 KiB

User Messages

User messages are a way to inform users about the state of asynchronous operations. One example would be notifying the user of why a share provisioning request failed. These messages can be requested via the /messages API. All user visible messages must be defined in the permitted messages module in order to prevent sharing sensitive information with users.

Example message generation:

from manila import context
from manila.message import api as message_api
from manila.message import message_field

self.message_api = message_api.API()

context = context.RequestContext()
project_id = '6c430ede-9476-4128-8838-8d3929ced223'
share_id = 'f292cc0c-54a7-4b3b-8174-d2ff82d87008'

self.message_api.create(
    context,
    message_field.Actions.CREATE,
    project_id,
    resource_type=message_field.Resource.SHARE,
    resource_id=SHARE_id,
    detail=message_field.Detail.NO_VALID_HOST)

Will produce the following:

GET /v2/6c430ede-9476-4128-8838-8d3929ced223/messages
{
  "messages": [
    {
     "id": "5429fffa-5c76-4d68-a671-37a8e24f37cf",
     "action_id": "001",
     "detail_id": "002",
     "user_message": "create: No storage could be allocated for this share "
                     "request. Trying again with a different size "
                     "or share type may succeed."",
     "message_level": "ERROR",
     "resource_type": "SHARE",
     "resource_id": "f292cc0c-54a7-4b3b-8174-d2ff82d87008",
     "created_at": 2015-08-27T09:49:58-05:00,
     "expires_at": 2015-09-26T09:49:58-05:00,
     "request_id": "req-936666d2-4c8f-4e41-9ac9-237b43f8b848",
    }
  ]
}

The Message API Module

manila.message.api

The Permitted Messages Module

manila.message.message_field