Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit 82ad387b4db3ce1c6d87c85bcf778ac4a30279b4
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Wed Sep 2 16:50:15 2015 +0200
[frontend][API] sphinx doc for API_2, initial commit
---------------------------------------------------------------
frontend/copr-frontend.spec | 2 +
{backend/docs => frontend/docs/api_2}/Makefile | 34 +++-
frontend/docs/api_2/source/Resources/project.rst | 230 ++++++++++++++++++++
.../docs => frontend/docs/api_2}/source/conf.py | 106 ++++-----
frontend/docs/api_2/source/index.rst | 63 ++++++
5 files changed, 372 insertions(+), 63 deletions(-)
diff --git a/frontend/copr-frontend.spec b/frontend/copr-frontend.spec
index 3377f4a..01b9aec 100644
--- a/frontend/copr-frontend.spec
+++ b/frontend/copr-frontend.spec
@@ -89,6 +89,8 @@ BuildRequires: python-markdown
BuildRequires: pytz
BuildRequires: python-flask-restful
BuildRequires: python-marshmallow >= 2.0.0
+BuildRequires: python-sphinx
+BuildRequires: python-sphinxcontrib-httpdomain
%description
COPR is lightweight build system. It allows you to create new project in WebUI,
diff --git a/backend/docs/Makefile b/frontend/docs/api_2/Makefile
similarity index 79%
copy from backend/docs/Makefile
copy to frontend/docs/api_2/Makefile
index 87a774f..baf991e 100644
--- a/backend/docs/Makefile
+++ b/frontend/docs/api_2/Makefile
@@ -7,6 +7,11 @@ SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx
installed, then set the SPHINXBUILD environment variable to point to the full path of the
'$(SPHINXBUILD)' executable. Alternatively you can add the directory with the
executable to your PATH. If you don't have Sphinx installed, grab it from
http://sphinx-doc.org/)
+endif
+
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
@@ -29,17 +34,20 @@ help:
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or
PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated
items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if
enabled)"
clean:
- -rm -rf $(BUILDDIR)/*
+ rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@@ -77,17 +85,17 @@ qthelp:
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with
the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
- @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/copr-backend.qhcp"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/CoprApi2.qhcp"
@echo "To view the help file:"
- @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/copr-backend.qhc"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/CoprApi2.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
- @echo "# mkdir -p $$HOME/.local/share/devhelp/copr-backend"
- @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/copr-backend"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/CoprApi2"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/CoprApi2"
@echo "# devhelp"
epub:
@@ -108,6 +116,12 @@ latexpdf:
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@@ -151,3 +165,13 @@ doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/frontend/docs/api_2/source/Resources/project.rst
b/frontend/docs/api_2/source/Resources/project.rst
new file mode 100644
index 0000000..2a9f31c
--- /dev/null
+++ b/frontend/docs/api_2/source/Resources/project.rst
@@ -0,0 +1,230 @@
+Project
+=======
+
+Project resource represents copr projects and operations with them.
+
+Structure of the project entity
+-------------------------------
+
+**An example**:
+
+.. code-block:: javascript
+
+ {
+ "description": "A recent stable release of Ruby with Rails 3.2.8
and ... ",
+ "disable_createrepo": false,
+ "repos": [
+
"http://copr-be.cloud.fedoraproject.org/results/msuchy/scl-utils/epel-6-$basearch/",
+
"http://copr-be.cloud.fedoraproject.org/results/rhscl/httpd24/epel-6-$basearch/",
+ ],
+ "contact": null,
+ "owner": "rhscl",
+ "build_enable_net": true,
+ "instructions": "",
+ "homepage": null,
+ "id": 479,
+ "name": "ruby193"
+ }
+
+
+Project fields
+~~~~~~~~~~~~~~
+================== ==================== ========= ===============
+Field Type Can edit? Description
+================== ==================== ========= ===============
+id number no unique identifier
+owner string no login of the project owner
+name string no name of the project, MUST be specified
during a project creation
+description string yes project description
+instructions string yes installation instructions
+homepage string(URL) yes project homepage
+contact string(URL or email) yes contact with the project maintainer
+disable_createrepo bool yes disables automatic repository metadata
generation
+build_enable_net bool yes set default value for new builds
option ``enable_net``
+================== ==================== ========= ===============
+
+
+.. http:get:: /api_2/projects
+
+ Returns a list of Copr projects according to the given query parameters
+
+ **Example request**:
+
+ .. sourcecode:: http
+
+ GET /api_2/projects HTTP/1.1
+ Host:
copr.fedoraproject.org
+ Accept: application/json
+
+ **Response**:
+
+ .. sourcecode:: http
+
+ HTTP/1.1 200 OK
+ Content-Type: application/json
+
+ {
+ "_links": {
+ "self": {
+ "href": "/api_2/projects"
+ }
+ },
+ "projects": [
+ {
+ "project": {
+ "description": "Lightweight buildsystem - upstream
releases. Usually build few days before it land in Fedora.",
+ "disable_createrepo": false,
+ "repos": [],
+ "contact": null,
+ "owner": "msuchy",
+ "build_enable_net": false,
+ "instructions": "See
https://fedorahosted.org/copr/ for
more details.",
+ "homepage": null,
+ "id": 1,
+ "name": "copr"
+ },
+ "_links": { }
+ },
+ ]
+ }
+
+ :query search_query: filter project using full-text search
+ :query owner: select only projects owned by this user
+ :query name: select only projects with this name
+ :query offset: offset number, default value is 0
+ :query limit: limit number, default value is 100
+
+ :statuscode 200: no error
+
+.. http:post:: /api_2/projects
+
+ **REQUIRE AUTH**
+
+ Creates new Copr project.
+
+ Additionally to described before `Project fields`_ the user could specify field
``chroots`` which contains list of chroots to be enabled.
+ Available chroots could be obtained from MockChrootResource_
+
+ **Example request**:
+
+ .. sourcecode:: http
+
+ POST /api_2/projects HTTP/1.1
+ Host:
copr.fedoraproject.org
+ Authorization: Basic base64=encoded=string
+ Accept: application/json
+
+ {
+ "disable_createrepo": false,
+ "build_enable_net": true,
+ "name": "foobar",
+ "chroots": [
+ "fedora-22-x86_64",
+ "fedora-22-i386",
+ ]
+ }
+
+
+ **Response**:
+
+ .. sourcecode:: http
+
+ HTTP/1.1 201 CREATED
+ Location: /api_2/projects/<new project id>
+
+ :resheader Location: contains URL to the newly created project entity
+
+ :statuscode 201: project was successfully created
+ :statuscode 400: given data for project creation doesn't satisfy some
requirements
+ :statuscode 401: the user already has project with the same name
+ :statuscode 403: authorization failed
+
+
+.. http:get:: /api_2/projects/(int:project_id)
+
+ Returns details about Copr project
+
+ :param project_id: a unique identifier of the Copr project.
+
+ :query bool show_builds: embed Build_ entities owned by this project into the result,
default is False
+ :query bool show_chroots: embed ProjectChroot_ sub-resources into the result, default
is False
+
+ :statuscode 200: no error
+ :statuscode 404: project not found
+
+ **Example request**
+
+ .. sourcecode:: http
+
+ GET /api_2/projects/2482 HTTP/1.1
+ Host:
copr.fedoraproject.org
+ Accept: application/json
+
+ **Response**
+
+ .. sourcecode:: http
+ HTTP/1.1 200 OK
+ Content-Type: application/json
+
+ {
+ "project": {
+ "description": "A simple KDE respin",
+ "disable_createrepo": false,
+ "repos": [],
+ "contact": null,
+ "owner": "jmiahman",
+ "build_enable_net": true,
+ "instructions": "",
+ "homepage": null,
+ "id": 2482,
+ "name": "Synergy-Linux"
+ },
+ "project_chroots": [
+ {
+ "chroot": {
+ "comps": null,
+ "comps_len": 0,
+ "buildroot_pkgs": [],
+ "name": "fedora-19-x86_64",
+ "comps_name": null
+ }
+ "_links": {}
+ },
+ { }
+ ],
+ "project_builds": [
+ {
+ "_links": { },
+ "build": {
+ "enable_net": true,
+ "submitted_on": 1422379448,
+ "repos": [],
+ "results":
"https://copr-be.cloud.fedoraproject.org/results/jmiahman/Synergy-Linux/",
+ "started_on": 1422379466,
+ "source_type": 1,
+ "state": "succeeded",
+ "source_json": "{\"url\":
\"http://dl.kororaproject.org/pub/korora/releases/21/source/korora-welcome-21.6-1.fc21.src.rpm\"}",
+ "ended_on": 1422379584,
+ "timeout": 21600,
+ "pkg_version": "21.6-1.fc21",
+ "id": 69493
+ }
+ },
+ { }
+ ],
+ "_links": {
+ "self": {
+ "href":
"/api_2/projects/2482?show_builds=True&show_chroots=True"
+ },
+ "chroots": {
+ "href": "/api_2/projects/2482/chroots"
+ },
+ "builds": {
+ "href": "/api_2/builds?project_id=2482"
+ }
+ }
+ }
+
+
+
+
diff --git a/backend/docs/source/conf.py b/frontend/docs/api_2/source/conf.py
similarity index 80%
copy from backend/docs/source/conf.py
copy to frontend/docs/api_2/source/conf.py
index fbfe196..9c4d89d 100644
--- a/backend/docs/source/conf.py
+++ b/frontend/docs/api_2/source/conf.py
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
#
-# copr-backend documentation build configuration file, created by
-# sphinx-quickstart on Tue Dec 2 15:51:01 2014.
+# Copr Api 2 documentation build configuration file, created by
+# sphinx-quickstart on Wed Sep 2 14:50:00 2015.
#
-# This file is execfile()d with the current directory set to its containing dir.
+# 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.
@@ -13,43 +14,27 @@
import sys
import os
-from subprocess import call
-
-TO_INSTALL = [
- # "redis",
- "retask",
- "ansible",
-]
-
-
-on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
-if on_rtd:
- for pkg in TO_INSTALL:
- print(call(["pip", "install", "--upgrade", pkg]))
-
- print(call("python ../../../python/setup.py install".split()))
-
-# else:
-# # html_theme = 'nature'
-# pass
# 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.append(os.path.abspath('../../../python/'))
+#sys.path.insert(0, os.path.abspath('.'))
-
-# -- General configuration -----------------------------------------------------
+# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage',
- 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
-# extensions += ['sphinxarg.ext']
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+ 'sphinx.ext.intersphinx',
+ 'sphinx.ext.ifconfig',
+ 'sphinx.ext.viewcode',
+ 'sphinxcontrib.httpdomain',
+]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -64,17 +49,17 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
-project = u'copr-backend'
-copyright = u'2014, Copr dev team'
+project = u'Copr Api 2'
+copyright = u'2015,
https://fedorahosted.org/copr/'
# 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.
#
# The short X.Y version.
-version = '0.61'
+version = '0.1'
# The full version, including alpha/beta/rc tags.
-release = version
+release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -90,7 +75,8 @@ release = version
# directories to ignore when looking for source files.
exclude_patterns = []
-# The reST default role (used for this markup: `text`) to use for all documents.
+# 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.
@@ -110,8 +96,11 @@ pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
+# If true, keep warnings as "system message" paragraphs in the built
documents.
+#keep_warnings = False
+
-# -- Options for HTML output ---------------------------------------------------
+# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
@@ -146,6 +135,11 @@ html_theme = 'default'
# so a file named "default.css" will overwrite the builtin
"default.css".
html_static_path = ['_static']
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
# 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'
@@ -188,10 +182,10 @@ html_static_path = ['_static']
#html_file_suffix = None
# Output file base name for HTML help builder.
-htmlhelp_basename = 'copr-backenddoc'
+htmlhelp_basename = 'CoprApi2doc'
-# -- Options for LaTeX output --------------------------------------------------
+# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
@@ -205,10 +199,11 @@ latex_elements = {
}
# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
latex_documents = [
- ('index', 'copr-backend.tex', u'copr-backend Documentation',
- u'Copr dev team', 'manual'),
+ ('index', 'CoprApi2.tex', u'Copr Api 2 Documentation',
+
u'https://fedorahosted.org/copr/';, 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -232,27 +227,27 @@ latex_documents = [
#latex_domain_indices = True
-# -- Options for manual page output --------------------------------------------
+# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
- ('index', 'copr-backend', u'copr-backend Documentation',
- [u'Copr dev team'], 1)
+ ('index', 'coprapi2', u'Copr Api 2 Documentation',
+ [
u'https://fedorahosted.org/copr/'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
-# -- Options for Texinfo output ------------------------------------------------
+# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('index', 'copr-backend', u'copr-backend Documentation',
- u'Copr dev team', 'copr-backend', 'One line description of
project.',
+ ('index', 'CoprApi2', u'Copr Api 2 Documentation',
+
u'https://fedorahosted.org/copr/';, 'CoprApi2', 'One line
description of project.',
'Miscellaneous'),
]
@@ -265,14 +260,9 @@ texinfo_documents = [
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
-# ---
-# enabling __init__ for automodule
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
-autodoc_member_order = "bysource"
-autodoc_default_flags = [
- 'members',
- 'undoc-members',
- 'private-members',
- # 'special-members',
- # 'inherited-members'
-]
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': None}
diff --git a/frontend/docs/api_2/source/index.rst b/frontend/docs/api_2/source/index.rst
new file mode 100644
index 0000000..093433d
--- /dev/null
+++ b/frontend/docs/api_2/source/index.rst
@@ -0,0 +1,63 @@
+.. Copr Api 2 documentation master file, created by
+ sphinx-quickstart on Wed Sep 2 14:50:00 2015.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to Copr Api 2's documentation!
+======================================
+
+Welcome to the documentation of the new REST-like API for the Copr build service.
+Almost all API calls is done using ``application/json`` ContentType.
+
+Endpoint of the the API is ``/api_2``, public data is available without authorization.
+
+To create new projects, submit builds and do other modification requests you will need to
provide API token using
+BasicAuth_ . Token can be obtained and renewed at the CoprAPI_ page.
+
+This API implements HETEOAS_ in the very simple form: each entity is accompanied with set
of relative links
+to other related entities. HETEOAS makes API self discoverable, so you shouldn't
learn how to access sub-resources.
+Here is a short example with the content of API root:
+
+**GET /api_2**
+
+.. code-block:: javascript
+
+ {
+ "_links": {
+ "mock_chroots": {
+ "href": "/api_2/mock_chroots"
+ },
+ "self": {
+ "href": "/api_2/"
+ },
+ "projects": {
+ "href": "/api_2/projects"
+ },
+ "builds": {
+ "href": "/api_2/builds"
+ }
+ }
+
+Errors
+______
+todo:
+
+
+Resources
+---------
+.. toctree::
+ :maxdepth: 1
+
+ Resources/project
+
+
+.. Indices and tables
+ ==================
+ * :ref:`genindex`
+ * :ref:`modindex`
+ * :ref:`search`
+
+.. _BasicAuth:
https://en.wikipedia.org/wiki/Basic_access_authentication
+.. _CoprAPI:
https://copr.fedoraproject.org/api
+.. _HETEOAS:
https://en.wikipedia.org/wiki/HATEOAS
+