From dd7a15c0ff0f48cc6ba8e7f7464f270e0d5fc5a9 Mon Sep 17 00:00:00 2001 From: Goutham Pacha Ravi Date: Fri, 21 Dec 2018 17:11:32 -0800 Subject: [PATCH] [doc] Fix api sections in the contributor doc Weed out outdated/unnecessary info and add link to api ref. Change-Id: Ia45c8ad6e2a697d5b76232e17e4df34539d81c12 --- .../contributor/addmethod.openstackapi.rst | 59 +++++++++----- doc/source/contributor/api.rst | 76 ------------------- doc/source/contributor/index.rst | 3 +- 3 files changed, 39 insertions(+), 99 deletions(-) delete mode 100644 doc/source/contributor/api.rst diff --git a/doc/source/contributor/addmethod.openstackapi.rst b/doc/source/contributor/addmethod.openstackapi.rst index fa47f56fc9..4d09651405 100644 --- a/doc/source/contributor/addmethod.openstackapi.rst +++ b/doc/source/contributor/addmethod.openstackapi.rst @@ -14,43 +14,60 @@ License for the specific language governing permissions and limitations under the License. -Adding a Method to the OpenStack API -==================================== +Adding a Method to the OpenStack Manila API +=========================================== -The interface is a mostly RESTful API. REST stands for Representational State Transfer and provides an architecture "style" for distributed systems using HTTP for transport. Figure out a way to express your request and response in terms of resources that are being created, modified, read, or destroyed. +The interface to manila is a RESTful API. REST stands for Representational +State Transfer and provides an architecture "style" for distributed systems +using HTTP for transport. Figure out a way to express your request and +response in terms of resources that are being created, modified, read, or +destroyed. Manila's API aims to conform to the `guidelines `_ set by OpenStack API SIG. Routing ------- -To map URLs to controllers+actions, OpenStack uses the Routes package, a clone of Rails routes for Python implementations. See http://routes.groovie.org/ for more information. +To map URLs to controllers+actions, manila uses the Routes package. See +the `routes package documentation `_ +for more information. -URLs are mapped to "action" methods on "controller" classes in ``manila/api/v1/router.py``. +URLs are mapped to "action" methods on "controller" classes in +``manila/api//router.py``. -See http://routes.groovie.org/manual.html for all syntax, but you'll probably just need these two: - - mapper.connect() lets you map a single URL to a single action on a controller. - - mapper.resource() connects many standard URLs to actions on a controller. +These are two methods of the routes package that are used to perform the +mapping and the routing: + +- mapper.connect() lets you map a single URL to a single action on a + controller. +- mapper.resource() connects many standard URLs to actions on a controller. Controllers and actions ----------------------- -Controllers live in ``manila/api/v1`` and ``manila/api/contrib``. +Controllers live in ``manila/api/v1`` and ``manila/api/v2``. See ``manila/api/v1/shares.py`` for an example. -Action methods take parameters that are sucked out of the URL by mapper.connect() or .resource(). The first two parameters are self and the WebOb request, from which you can get the req.environ, req.body, req.headers, etc. +Action methods take parameters that are sucked out of the URL by +mapper.connect() or .resource(). The first two parameters are self and the +WebOb request, from which you can get the req.environ, req.body, +req.headers, etc. -Serialization -------------- - -Actions return a dictionary, and wsgi.Controller serializes that to JSON or XML based on the request's content-type. - -If you define a new controller, you'll need to define a ``_serialization_metadata`` attribute on the class, to tell wsgi.Controller how to convert your dictionary to XML. It needs to know the singular form of any list tag (e.g. ```` list contains ```` tags) and which dictionary keys are to be XML attributes as opposed to subtags (e.g. ```` instead of ``4``). - -See `manila/api/v1/shares.py` for an example. +Actions return a dictionary, and wsgi.Controller serializes that to JSON. Faults ------ -If you need to return a non-200, you should -return faults.Fault(webob.exc.HTTPNotFound()) -replacing the exception as appropriate. +If you need to return a non-200, you should return faults.Fault(webob.exc +.HTTPNotFound()) replacing the exception as appropriate. + +Evolving the API +---------------- + +The ``v1`` version of the manila API has been deprecated. The ``v2`` version +of the API supports micro versions. So all changes to the v2 API strive to +maintain stability at any given API micro version, so consumers can safely +rely on a specific micro version of the API never to change the request and +response semantics. Read more about :doc:`API Microversions +` to understand how stability and backwards +compatibility are maintained. diff --git a/doc/source/contributor/api.rst b/doc/source/contributor/api.rst deleted file mode 100644 index d51b645023..0000000000 --- a/doc/source/contributor/api.rst +++ /dev/null @@ -1,76 +0,0 @@ -.. - Copyright 2010-2011 United States Government as represented by the - Administrator of the National Aeronautics and Space Administration. - All Rights Reserved. - - 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. - -API Endpoint -============ - -Manila has a system for managing multiple APIs on different subdomains. -Currently there is support for the OpenStack API. - -Common Components ------------------ - -The :mod:`manila.api` Module -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. automodule:: manila.api - :noindex: - :members: - :undoc-members: - :show-inheritance: - - -The :mod:`manila.api.v1` Module -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. automodule:: manila.api - :noindex: - :members: - :undoc-members: - :show-inheritance: - - -The :mod:`manila.api.contrib` Module -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. automodule:: manila.api - :noindex: - :members: - :undoc-members: - :show-inheritance: - - -OpenStack API -------------- - -The :mod:`openstack` Module -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. automodule:: manila.api.openstack - :noindex: - :members: - :undoc-members: - :show-inheritance: - - -Tests ------ - -The :mod:`api` Module -~~~~~~~~~~~~~~~~~~~~~ - -.. automodule:: manila.tests.api - :noindex: - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/contributor/index.rst b/doc/source/contributor/index.rst index 8abfc85fc9..0b6c73a7ec 100644 --- a/doc/source/contributor/index.rst +++ b/doc/source/contributor/index.rst @@ -64,7 +64,7 @@ API Reference .. toctree:: :maxdepth: 3 - api + Manila API v2 Reference api_microversion_dev api_microversion_history experimental_apis @@ -80,7 +80,6 @@ Module Reference share share_hooks auth - api scheduler fakes manila