Add basic structure of api-ref and api-ref for types

This patch setup the basic structure for api-ref and
adds api-ref for types(instance_types).

Partially-Implements: blueprint adopt-api-ref

Change-Id: I228891a2aff4b77d2acadc20627c67a55be6a706
This commit is contained in:
Kevin_Zheng 2016-09-13 16:01:40 +08:00
parent f04718d711
commit 687acd7c5e
14 changed files with 830 additions and 2 deletions

234
api-ref/source/conf.py Normal file
View File

@ -0,0 +1,234 @@
# -*- coding: utf-8 -*-
#
# 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.
#
# nimble documentation build configuration file, created by
# sphinx-quickstart on Sat May 1 15:17:47 2010.
#
# This file is execfile()d with the current directory set to
# its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import subprocess
import sys
import warnings
import openstackdocstheme # noqa
import os_api_ref # noqa
extensions = [
'os_api_ref',
]
html_theme = 'openstackdocs'
html_theme_path = [openstackdocstheme.get_html_theme_path()]
html_theme_options = {
"sidebar_mode": "toc",
}
html_context = {'bug_project': 'nimble', 'bug_tag': 'api-ref'}
# End temporary block
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../../'))
sys.path.insert(0, os.path.abspath('../'))
sys.path.insert(0, os.path.abspath('./'))
# -- General configuration ----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#
# source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Baremetal-Compute API Reference'
copyright = u'2010-present, OpenStack Foundation'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
from nimble.version import version_info
# The full version, including alpha/beta/rc tags.
release = version_info.release_string()
# The short X.Y version.
version = version_info.version_string()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# The reST default role (used for this markup: `text`) to use
# for all documents.
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = False
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for man page output ----------------------------------------------
# Grouping the document tree for man pages.
# List of tuples 'sourcefile', 'target', u'title', u'Authors name', 'manual'
# -- Options for HTML output --------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
# html_theme_path = ["."]
# html_theme = '_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
# html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
# html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y'
git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
"-n1"]
try:
html_last_updated_fmt = subprocess.Popen(
git_cmd, stdout=subprocess.PIPE).communicate()[0].decode()
except Exception:
warnings.warn('Cannot get last updated time from git repository. '
'Not setting "html_last_updated_fmt".')
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
# If false, no module index is generated.
# html_use_modindex = True
# If false, no index is generated.
# html_use_index = True
# If true, the index is split into individual pages for each letter.
# html_split_index = False
# If true, links to the reST sources are added to the pages.
# html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'nimbledoc'
# -- Options for LaTeX output -------------------------------------------------
# The paper size ('letter' or 'a4').
# latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
# latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index', 'Nimble.tex', u'OpenStack Baremetal-Compute API Documentation',
u'OpenStack Foundation', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False
# Additional stuff for the LaTeX preamble.
# latex_preamble = ''
# Documents to append as an appendix to all manuals.
# latex_appendices = []
# If false, no module index is generated.
# latex_use_modindex = True

10
api-ref/source/index.rst Normal file
View File

@ -0,0 +1,10 @@
:tocdepth: 2
======================
Baremetal Compute API
======================
.. rest_expand_all::
.. include:: urls.inc
.. include:: types.inc

View File

@ -0,0 +1,144 @@
# variables in header
openstack-request-id:
description: >
A unique ID for tracking the request. The request ID associated with the request
appears in the log lines for that request. By default, the middleware configuration
ensures that the request ID appears in the log files.
in: header
required: true
type: string
# variables in path
api_version:
in: path
required: true
type: string
description: >
The API version as returned in the links from the ``GET /`` call.
spec_key_path:
description: |
The key of the extra spec.
in: path
required: true
type: string
type_uuid_path:
description: |
The UUID of the type.
in: path
required: true
type: string
# variables in query
user_id:
description: |
Filters the response by a user, by ID.
in: query
required: false
type: string
# variables in body
created_at:
description: |
The date and time when the resource was created. The date and time
stamp format is `ISO 8601 <https://en.wikipedia.org/wiki/ISO_8601>`_
::
CCYY-MM-DDThh:mm:ss±hh:mm
For example, ``2015-08-27T09:49:58-05:00``. The ``±hh:mm``
value, if included, is the time zone as an offset from UTC. In
the previous example, the offset value is ``-05:00``.
in: body
required: true
type: string
links:
description: |
Links to the resources in question.
in: body
required: true
type: array
type_description:
description: |
The description of the type.
in: body
required: true
type: string
type_extra_specs:
description: |
Extra spec key and value pairs associate with the type.
in: body
required: true
type: object
type_id_body:
description: |
The ID of the type.
in: body
required: true
type: string
type_id_body_not_required:
description: |
The ID of the type.
in: body
required: false
type: string
type_is_public:
description: |
Whether the type is public (available to all projects) or scoped
to a set of projects. Default is True if not specified.
in: body
required: true
type: boolean
type_is_public_not_required:
description: |
Whether the type is public (available to all projects) or scoped
to a set of projects. Default is True if not specified.
in: body
required: true
type: boolean
type_name:
description: |
The name of the type.
in: body
required: true
type: string
type_uuid:
description: |
The UUID of the type.
in: body
required: true
type: string
type_uuid_not_required:
description: |
The UUID of the type.
in: body
required: false
type: string
typeRef:
description: |
The type reference, as a UUID or full URL, for the type for your server instance.
in: body
required: true
type: string
types:
description: |
An array of type objects.
in: body
required: true
type: array
updated_at:
description: |
The date and time when the resource was updated. The date and time
stamp format is `ISO 8601 <https://en.wikipedia.org/wiki/ISO_8601>`_
::
CCYY-MM-DDThh:mm:ss±hh:mm
For example, ``2015-08-27T09:49:58-05:00``. The ``±hh:mm``
value, if included, is the time zone as an offset from UTC. In
the previous example, the offset value is ``-05:00``.
in: body
required: true
type: string

296
api-ref/source/types.inc Normal file
View File

@ -0,0 +1,296 @@
.. -*- rst -*-
======
Type
======
Show and manage Types.
Types are a way to describe the basic dimensions of a instance to be
created including how much ``cpu``, ``ram``, and ``disk space`` are
allocated to an instance built with this type.
List Types
==========
.. rest_method:: GET /types
Lists all types accessible to your project.
Normal response codes: 200
Error response codes: unauthorized(401), forbidden(403)
Request
-------
Response
--------
.. rest_parameters:: parameters.yaml
- types: types
- id: type_id_body
- name: type_name
- links: links
- description: type_description
- uuid: type_uuid
- created_at: created_at
- updated_at: updated_at
- is_public: type_is_public
- extra_specs: type_extra_specs
**Example List types**
.. literalinclude:: ../../doc/api_samples/types/types-list-resp.json
:language: javascript
Create Type
===========
.. rest_method:: POST /types
Creates a type.
Creating a type is typically only available to administrators of a
cloud because this has implications for scheduling efficiently in the cloud.
Normal response codes: 200
Error response codes: badRequest(400), unauthorized(401), forbidden(403),
conflict(409)
Request
-------
.. rest_parameters:: parameters.yaml
- name: type_name
- description: type_description
- id: type_id_body_not_required
- is_public: type_is_public_not_required
- uuid: type_uuid_not_required
**Example Create Type**
.. literalinclude:: ../../doc/api_samples/types/type-create-post-req.json
:language: javascript
Response
--------
.. rest_parameters:: parameters.yaml
- id: type_id_body
- name: type_name
- links: links
- description: type_description
- uuid: type_uuid
- created_at: created_at
- updated_at: updated_at
- is_public: type_is_public
- extra_specs: type_extra_specs
**Example Create type**
.. literalinclude:: ../../doc/api_samples/types/type-create-post-resp.json
:language: javascript
Show Type Details
===================
.. rest_method:: GET /types/{type_uuid}
Shows details for a type.
Normal response codes: 200
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404)
Request
-------
.. rest_parameters:: parameters.yaml
- type_uuid: type_uuid_path
Response
--------
.. rest_parameters:: parameters.yaml
- id: type_id_body
- name: type_name
- links: links
- description: type_description
- uuid: type_uuid
- created_at: created_at
- updated_at: updated_at
- is_public: type_is_public
- extra_specs: type_extra_specs
**Example Show type Details**
.. literalinclude:: ../../doc/api_samples/types/type-get-resp.json
:language: javascript
Delete Type
=============
.. rest_method:: DELETE /types/{type_uuid}
Deletes a type.
This is typically an admin only action. Deleting a type that is in use by
existing instances is not recommended as it can cause incorrect data to
be returned to the user under some operations.
Normal response codes: 202
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404)
Request
-------
.. rest_parameters:: parameters.yaml
- type_uuid: type_uuid_path
Response
--------
No body content is returned on a successful DELETE.
List Extra Specs
================
.. rest_method:: GET /types/{type_uuid}/extraspecs
Lists all extra specs related to the given type.
Normal response codes: 200
Error response codes: unauthorized(401), forbidden(403)
Request
-------
.. rest_parameters:: parameters.yaml
- type_uuid: type_uuid_path
Response
--------
.. rest_parameters:: parameters.yaml
- extra_specs: type_extra_specs
**Example List Extra Specs**
.. literalinclude:: ../../doc/api_samples/types/type-extra-specs-list-resp.json
:language: javascript
Create Extra Spec
=================
.. rest_method:: POST /types/{type_uuid}/extraspecs
Create extra specs to the given type.
Normal response codes: 200
Error response codes: unauthorized(401), forbidden(403)
Request
-------
.. rest_parameters:: parameters.yaml
- type_uuid: type_uuid_path
- extra_specs: type_extra_specs
**Example Create Extra Specs**
.. literalinclude:: ../../doc/api_samples/types/type-extra-specs-post-req.json
:language: javascript
Response
--------
.. rest_parameters:: parameters.yaml
- extra_specs: type_extra_specs
**Example Create Extra Specs**
.. literalinclude:: ../../doc/api_samples/types/type-extra-specs-list-resp.json
:language: javascript
Update Extra Spec
=================
.. rest_method:: PUT /types/{type_uuid}/extraspecs
Updates extra specs to the given type.
Normal response codes: 200
Error response codes: unauthorized(401), forbidden(403)
Request
-------
.. rest_parameters:: parameters.yaml
- type_uuid: type_uuid_path
- extra_specs: type_extra_specs
**Example Update Extra Specs**
.. literalinclude:: ../../doc/api_samples/types/type-extra-specs-post-req.json
:language: javascript
Response
--------
.. rest_parameters:: parameters.yaml
- extra_specs: type_extra_specs
**Example Update Extra Specs**
.. literalinclude:: ../../doc/api_samples/types/type-extra-specs-list-resp.json
:language: javascript
Delete Extra Spec
=================
.. rest_method:: DELETE /types/{type_uuid}/extraspecs/key
Deletes an extra spec related to the specific type.
Normal response codes: 202
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404)
Request
-------
.. rest_parameters:: parameters.yaml
- type_id: type_uuid_path
- key: spec_key_path
Response
--------
No body content is returned on a successful DELETE.

27
api-ref/source/urls.inc Normal file
View File

@ -0,0 +1,27 @@
.. -*- rst -*-
==============
Service URLs
==============
All API calls through the rest of this document require authentication
with the OpenStack Identity service. They also required a base
``service url`` that is extracted from the Identity token of type
``baremetal-compute``. This will be the root url that every call below
will be added to build a full path.
For instance, if the ``service url`` is
``http://mycompute.pvt/nimble/v1`` then the full API call for
``/instances`` is ``http://mycompute.pvt/nimble/v1/instances``.
Depending on the deployment the baremetal compute service url might
be http or https, a custom port, a custom path, and include your
tenant id. The only way to know the urls for your deployment is by
using the service catalog. The baremetal compute servic URL should
never be hard coded in applications, even if they are only expected
to work at a single site. It should always be discovered from the
Identity token.
As such, for the rest of this document we will be using short hand
where ``GET /instances`` really means ``GET
{your_service_url}/instances``.

View File

@ -0,0 +1,6 @@
{
"name": "test_type",
"description": "this is a test type",
"is_public": true,
"id": 1
}

View File

@ -0,0 +1,20 @@
{
"description": "this is a test type",
"links": [
{
"href": "http://10.3.150.17:6688/v1/types/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"rel": "self"
},
{
"href": "http://10.3.150.17:6688/types/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"rel": "bookmark"
}
],
"created_at": "2016-09-27T02:37:21.966342+00:00",
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"updated_at": null,
"extra_specs": {},
"is_public": true,
"id": 5,
"name": "test_type"
}

View File

@ -0,0 +1,6 @@
{
"extra_specs":{
"key_1": "value_1",
"key_2": "value_2"
}
}

View File

@ -0,0 +1,5 @@
{
"extra_specs":{
"key_2":"value_2"
}
}

View File

@ -0,0 +1,5 @@
{
"extra_specs":{
"key_2":"value_2"
}
}

View File

@ -0,0 +1,20 @@
{
"description": "this is a test type",
"links": [
{
"href": "http://10.3.150.17:6688/v1/types/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"rel": "self"
},
{
"href": "http://10.3.150.17:6688/types/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"rel": "bookmark"
}
],
"created_at": "2016-09-27T02:37:21.966342+00:00",
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"updated_at": null,
"extra_specs": {},
"is_public": true,
"id": 5,
"name": "test_type"
}

View File

@ -0,0 +1,46 @@
{
"types": [
{
"description": "this is a test type1",
"links": [
{
"href": "http://10.3.150.17:6688/v1/types/2ce3df6b-f571-42e8-b6a8-8f7fa1c019ce",
"rel": "self"
},
{
"href": "http://10.3.150.17:6688/types/2ce3df6b-f571-42e8-b6a8-8f7fa1c019ce",
"rel": "bookmark"
}
],
"created_at": "2016-09-22T03:21:57+00:00",
"uuid": "2ce3df6b-f571-42e8-b6a8-8f7fa1c019ce",
"updated_at": null,
"extra_specs": {
"key": "value"
},
"is_public": true,
"id": 3,
"name": "new_test1"
},
{
"description": "this is a test type2",
"links": [
{
"href": "http://10.3.150.17:6688/v1/types/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"rel": "self"
},
{
"href": "http://10.3.150.17:6688/types/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"rel": "bookmark"
}
],
"created_at": "2016-09-27T02:37:21+00:00",
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"updated_at": null,
"extra_specs": {},
"is_public": true,
"id": 5,
"name": "new_test2"
}
]
}

View File

@ -13,6 +13,7 @@ testrepository>=0.0.18 # Apache-2.0/BSD
testresources>=0.2.4 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
# releasenotes
sphinxcontrib-pecanwsme>=0.8 # Apache-2.0
sphinxcontrib-seqdiag # BSD
reno>=1.8.0 # Apache2
os-api-ref>=1.0.0 # Apache-2.0

View File

@ -61,6 +61,14 @@ envdir = {toxworkdir}/venv
commands =
oslo-config-generator --config-file=tools/config/nimble-config-generator.conf
[testenv:api-ref]
# This environment is called from CI scripts to test and publish
# the API Ref to developer.openstack.org.
whitelist_externals = bash
commands =
bash -c 'rm -rf api-ref/build'
sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
[flake8]
# E123, E125 skipped as they are invalid PEP-8.