1. Miroslav Shubernetskiy
  2. Tessera API docs

Commits

Miroslav Shubernetskiy  committed ffc0b61

initial commit. first version of the docs

  • Participants
  • Branches default

Comments (0)

Files changed (8)

File .hgignore

View file
  • Ignore whitespace
+# use glob syntax.
+syntax: glob
+
+*.png
+*.jpg
+*.pyc
+*.gif
+*.orig
+*~
+build/
+_build/
+dist/
+tmp/
+.idea/
+
+# switch to regexp syntax.
+syntax: regexp

File Makefile

View file
  • Ignore whitespace
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@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 "  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 "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/TesseraAPI.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/TesseraAPI.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/TesseraAPI"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/TesseraAPI"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."

File conf.py

View file
  • Ignore whitespace
+# -*- coding: utf-8 -*-
+#
+# Tessera API documentation build configuration file, created by
+# sphinx-quickstart on Tue Mar 20 17:23:19 2012.
+#
+# 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 sys, os
+
+# 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('.'))
+
+# -- 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.viewcode']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'Tessera API'
+copyright = u'2012, Miroslav Shubernetskiy'
+
+# 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.0'
+# The full version, including alpha/beta/rc tags.
+release = 'alpha'
+
+# 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'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# 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 = True
+
+# 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'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'haiku'
+
+# 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'
+
+# 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_domain_indices = 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, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = 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 = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'TesseraAPIdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'TesseraAPI.tex', u'Tessera API Documentation',
+   u'Miroslav Shubernetskiy', '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
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'tesseraapi', u'Tessera API Documentation',
+     [u'Miroslav Shubernetskiy'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- 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', 'TesseraAPI', u'Tessera API Documentation',
+   u'Miroslav Shubernetskiy', 'TesseraAPI', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'

File credits.rst

View file
  • Ignore whitespace
+Credits
+=======
+
+This api is part of the Tessera project which is done as part of the Senior Design Project Fall 2011 - Spring 2012 with
+Professor Wolberg. The api is designed to be used within Artaic and is custom fitted to meet their needs.
+
+Developers
+----------
+
+* Miroslav Shubernetskiy - Server side code which includes the api
+* Prof. George Wolberg - Client C++ application which consumes the api
+
+
+Libraries Used
+--------------
+
+The following libraries have been used. All are open source libraries.
+
+:Django:
+    for web framework including it's ORM `<https://www.djangoproject.com/>`_
+:Tastypie:
+    for api `<http://django-tastypie.readthedocs.org/en/latest/index.html>`_
+:lxml:
+    for serializing to xml in the api `<http://lxml.de/>`_
+:pyyaml:
+    for serializing to yaml in the api `<http://pyyaml.org/>`_
+:PIL:
+    for rendering mosaic images as well doing image processing `<http://www.pythonware.com/products/pil/>`_
+:colormath:
+    for doing color conversions `<http://code.google.com/p/python-colormath/>`_
+

File index.rst

View file
  • Ignore whitespace
+Tessera API's documentation!
+============================
+
+This is documentation for Tessera API. The current URL for the actual api is `<http://tessera.miki725.com/api/v1/>`_.
+
+
+Table of Content
+----------------
+
+.. toctree::
+   :maxdepth: 2
+
+   intro
+   resources
+   interact
+   credits
+
+
+
+Indices and tables
+------------------
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+

File interact.rst

View file
  • Ignore whitespace
+Interacting with API
+====================
+
+This pages explains how to use resources and how doing so consumer can interact with the API.
+
+
+Representing Resources
+----------------------
+
+The resources in the API are represented using different markup languages. For example, when client wants to make
+``/GET http://example.com/api/tile/1/`` request, the api will return data using one of the supported markup
+languages. Currently the following markup languages are supported:
+
+==========  ================
+M.Langyage  MIME Type
+==========  ================
+JSON        application/json
+XML         application/xml
+YAML        text/yaml
+==========  ================
+
+There are a couple of methods consumer can select which markup language the api should use for it's output.
+
+:HTTP Header:
+    The api fully supports the HTTP's ``Accept`` header. The consumer can specify in this header the MIME type
+    of the markup language for the data to be serialized into. The MIME has to be one of the supported MIME
+    types listed in the above table.
+
+    Here is an example of valid request requesting api to use XML::
+
+        /GET http://example.com/api/tile/1/
+        Accept: application/xml
+
+    which would return something similar to::
+
+        <?xml version='1.0' encoding='utf-8'?>
+        <object>
+            ...
+            <resource_uri>/api/v1/tile/1/</resource_uri>
+        </object>
+
+:Query String:
+    Sometimes using HTTP Header is inconvenient such as trying to get the output of the api in the web browser.
+    In these scenarios, the api allows consumer to overwrite [if existent] the value of the ``Accept`` header
+    within the querystring. The ``format=value`` has to be provided in the query string where ``value`` can be
+    any of the supported markup language's names.
+
+    The following is a request requesting api to use YAML::
+
+        /GET http://example.com/api/tile/1/?format=yaml
+
+    which would return something similar to::
+
+        { ..., resource_uri: !!python/unicode '/api/v1/tile/1/'}
+
+
+Schemas
+-------
+
+At :doc:`resources`, you can find a list of all available resources in the api as well as the list of attributes
+for each of the resources and their short description. There is also a programmatic way of getting the schema of
+each of the resources. The URL for getting the schema is just a matter of appending ``schema/`` to the end of the
+resource type URL. For example, the URL for the grout resource is ``http://example.com/api/grout/``, and therefore
+the following requests gets the schema of the grout::
+
+    /GET http://example.com/api/grout/schema/
+    Accept: application/json
+
+which would return something similar to::
+
+    {
+        allowed_detail_http_methods: [ "get" ],
+        allowed_list_http_methods: [ "get" ],
+        default_format: "application/json",
+        default_limit: 20,
+        fields: {
+            ... ,
+            resource_uri: {
+                blank: false,
+                default: "No default provided.",
+                help_text: "Unicode string data. Ex: "Hello World"",
+                nullable: false,
+                readonly: true,
+                type: "string",
+                unique: false
+            }
+        },
+        filtering: {
+            color: 1,
+            manufacturer: 2,
+            modified: 1,
+            name: 1
+        }
+    }
+
+The important pieces of the schema for any resource are:
+
+:allowed_detail_httml_methods, allowed_list_http_methods:
+    These fields specify which HTTP methods can be used with the specified resource. If the resource is read-only,
+    then the only allowed methods would be ``GET``.
+:fields:
+    This is an object which contains attributes for each of the available fields for the resource. Each of the field
+    objects contains information about it's ``type``, if it can be left ``null``, empty, and some helper text to
+    explain the type of the field.
+:filtering:
+    This is an object which specifies which fields of the resource can be used to filter the set of resources.
+    If the value for the field is ``1``, only direct value comparison filtering can be applied. If however the value
+    is ``2``, then nested filtering can be done. For more information about filtering please refer to `Filtering`_.
+
+
+Single Resource
+---------------
+
+If consumer needs to get a single resource, he needs to know the id or primary key of that resource. Then
+appending the ``<id>/`` to the resource type URL results in the URL which returns just that one resource.
+For example the following URL returns a single object for tile with ``id=1``::
+
+    /GET http://example.com/api/tile/1/
+    Accept: application/json
+
+
+List of Resources
+-----------------
+
+If the consumer needs to get the list of resources, the api provides a couple of methods to do so.
+
+:List of All Resources:
+    This is probably the easiest way to get the list of resources of a specific resource type. The default URL
+    mapping to get list of all resources of a specified type is the resource URL itself. For example,
+    tilesize resource URL is ``http://example.com/api/tilesize/``, and therefore the following request
+    returns the list of all tilesizes::
+
+        /GET http://example.com/api/tilesize/
+        Accept: application/json
+
+:Filtered List:
+    If consumer needs to filter the list of all resources by a certain criteria, api provides a standard way of
+    doing criteria based queries. Please refer to `Filtering`_ section for more information.
+
+In all cases, when api returns a list of resources, it returns the following object schema::
+
+    {
+        "meta":    { ... },
+        "objects": [
+            { ... },
+              ...
+            { ... }
+         ]
+    }
+
+
+This object two main attributes:
+
+:meta:
+
+    Meta information contains useful information about the total number of entries in the list as well as the pagination
+    information if the whole list of resources is broken into multiple sections. The pagination information is given by
+    having the ``limit`` and ``offset`` attributes. They specify from what index in the list and how many resources are
+    returned. So if the returned list has ``100`` resources, the limit is ``20``, and offset is ``44``, then the
+    resources in the range ``[44,63]`` are returned. In addition if the the returned list is paginated, the
+    ``next`` or ``previous`` attributes are going to contain the full URL for getting the next or previous segment of
+    resources from the whole list.
+
+    The following is a sample meta object for tile resource::
+
+        {
+            limit: 20,
+            next: "/api/v1/tile/?offset=20&limit=20",
+            offset: 0,
+            previous: null,
+            total_count: 100
+        }
+
+
+:objects:
+
+    This is an object which has the list of resources serialized according to the schema of the resource type
+    as described in `Schemas`_.
+
+
+Filtering
+---------
+
+If the consumer needs to get a filtered list of resources, api provides dome methods for filtering by applying
+condition parameters for some of the fields in the resource. There are however two types of fields in the resource,
+regular value fields and foreign key fields.
+
+Filtering Values
+++++++++++++++++
+
+If the field is just a regular field, some comparison operators can be applied to the field in order to filter
+the list of resources. The following comparison operators are available:
+
+:exact:
+    The field has to be exact value as provided::
+:iexact:
+    Case-insensitive variant of ``exact``
+:contains:
+    The field value has to contain the provided string
+:icontains:
+    Case-insensitive variant of ``contains``
+:in:
+    The field value has to be one of the given values in comma separated list
+:gt:
+    Greater then
+:gte:
+    Greater then or equal to
+:lt:
+    Less then
+:lte:
+    Less then or equal to
+:startswith:
+    The field value has to start with the given string
+:istartswith:
+    Case-insensitive variant of ``startswith``
+:endswith:
+    The field value has to end with the given string
+:iendswith:
+    Case-insensitive variant of ``endsswith``
+:range:
+    The value has to be between the given comma separated values
+:year:
+    The date has to be the given year
+:month:
+    The date has to be the given month
+:day:
+    The date has to be the given dat
+:week_day:
+    The date has to be the given day of the week. The range is 1 (Sunday) to 7 (Saturday).
+:isnull:
+    If the field value should be null. The boolean is given as string - ``true`` or ``false``
+:regex:
+    The field value has to match the given regex expression
+:iregex:
+    Case-insensitive variant of ``regex``
+
+All of these filters are applied by adding query string to the resource URL.
+It is added using the following syntax (please note some regex operators are used like ``*`` (0 or more))::
+
+    http://... /resource-name/?<field-name>__<filter-name>=value[,value]*(&<field-name>__<filter-name>=value[,value]*)*
+
+
+Here are some examples of adding them::
+
+    http://example.com/api/tile/?color__exact=141,139,142
+    http://example.com/api/tile/?modified__gte=2012-4-1
+    http://example.com/api/tilefinish/?name__iexact=blackened
+    http://example.com/api/tilefinish/?name__startswith=b
+    http://example.com/api/tile/?rotate__exact=true&modified__gte=2012-4-1
+
+
+Filtering Foreign Resources
++++++++++++++++++++++++++++
+
+Some fields sometimes are foreign key fields. The api provides a way to filter even the list of resources by the
+values in the foreign key relations. In order to do that, the filter is applied exactly as in regular fields,
+except it is different how the field is referenced. This method also supports multi-level nested foreign key
+values. The following is the recipe::
+
+    ... [<fk-field-name>__]+<field-name>__<filter-name>= ...
+
+In the following example, the api returns the list of all tiles where the size of the tiles is between 0.2 and 0.7
+usind the ``range`` filter::
+
+    http://example.com/api/tile/?line__size__nominal__range=0.2,0.7
+
+
+Sets of Resources
+-----------------
+
+If the consumer already knows the ids of the resources he needs to get, the consumer can make a request to get the
+set of resources with those primary key values. The URL to do so is just adding ``set/pk_0;pk_1;pk_2;...;pk_n/``,
+where ``pk_i`` are the ids of the resources separated by a semi-colon, to the resource type URL. For example, if
+consumer wants to get the tiles which have ids 10, 15, and 20, the following request would return them::
+
+    /GET http://example.com/api/tile/set/10;15;20/
+    Accept: application/json
+
+
+
+

File intro.rst

View file
  • Ignore whitespace
+Introduction
+============
+
+This is an introduction for this api's documentation. It covers the explanation why the api is useful,
+the core principle of REST as well as the terms and notations used in this documentation.
+
+Why have API?
+-------------
+
+The mosaic software is designed to be used by both clients and the manufacturer. Hence it will have
+two versions, one for each type of user. The main difference between the two versions is that the
+client version operates on a strict subset of the whole data. For example, client version
+never should get pricing information per tile or the availability. That data is only for the
+manufacturer version. In addition, since the client version is done as an offline stand-alone
+application, it has to be able to dynamically get latest necessary information from the manufacturer
+database for proper operation. The API provides an easy to implement and an abstract way of
+communication with the database without sacrificing security. This way the data on the server and the
+client's version of the application are decoupled as much as possible.
+
+
+About REST
+----------
+
+REST stands for Representational state transfer. As the name suggests, the main idea behind REST is the
+use of resources. Resource is a very generic term but in its essence it is any single piece of information the
+consumer might want to refer to. For example - tile and mosaic are resources because the they are single entities of
+information to which the user might want to refer to. In REST, each resource is referenced by its own URL. So tile
+and mosaic resources will have their own URLs. The URL is essentially a mapping from URL to the actual resource in
+the system (e.g. entry in the database). An example URLs are::
+
+    http://example.com/api/tile/1/
+    http://example.com/api/mosaic/1/
+
+When client, wishes to do something with the resource, the URL does not specify which action to do with the URL's
+mapped resource. To specify actions, REST apis use standard HTTP request methods. For example, if client wants to
+delete a certain resource, he will generate HTTP request with ``/DELETE`` request method to the resource's URL.
+The following is the HTTP request to delete mosaic with ``id=1``::
+
+    /DELETE http://example.com/api/mosaic/1/
+
+.. note::
+    Going to any url in a web browser, the browser will always make HTTP requests using ``GET`` method.
+
+
+Terms
+-----
+
+The following are the terms used throughout the api documentation:
+
+:System:
+    The server where the api runs. This can also refer to the database where information for the api
+    is stored.
+:Consumer:
+    The user or application accessing the api. Sometimes as referred to as "he."
+
+
+Notation
+--------
+
+:HTTP Request:
+    The HTTP requests are represented using the following format::
+
+        /METHOD URL
+        HEADER_NAME: VALUE
+        DATA
+
+    Some of the examples using this notation are
+
+    ::
+
+        /GET http://example.com
+
+    ::
+
+        /POST http://example.com
+        Content-Type: application/json
+        {
+            "pk": 1"
+        }
+
+
+Assumptions
+-----------
+
+This api makes the following assumptions about the reader:
+
+* Familiarity with JSON. JSON is used as primary markup language throught the documentation.
+  More information about JSON can be found `here <http://www.json.org/>`_.
+* Some familiarity with HTTP protocol. Specifically some knowledge about HTTP headers and status codes.
+

File resources.rst

View file
  • Ignore whitespace
+Resources
+=========
+
+The following are the available resource in the api.
+
+.. note::
+    All resources have a common attribute ``modified`` which is a string containing the last date and time
+    the resource was modified.
+
+Tile
+----
+
+Tile resource stores information relative to each individual tile. Some tiles groups with common
+information such as material, finish and size are combined into a single resource TileLine to
+which each tile is referenced. This resource is read-only.
+
+Attributes
+
+:name: The English associated name to the tile
+:average: The RGB average of the tile separated by comma
+:averagecenter: The RGB center weighted average of the tile separated by comma
+:median: The RGB of the median of the tile separated by comma
+:rotate: If the tile is allowed to be rotated
+:line: Reference to the TileLine resource
+
+TileLine
+--------
+
+TileLine resource stores common information to a set of tiles in order to be able to aggregate them.
+This resource is read-only.
+
+Attributes
+
+:material: Reference to the TileMaterial resource
+:finish: Reference to the TileFinish resource
+:size: Reference to the TileSize resource
+
+TileMaterial
+------------
+
+TileMaterial resource specifies the material from which the tile is made out of.
+This resource is read-only.
+
+Attributes
+
+:name: The full name of the material of the tile
+:code: The abbreviation of the tile material as used by the manufacturer
+
+TileFinish
+----------
+
+TileFinish Resource specifies the finish which is applied to the tile.
+This resource is read-only.
+
+Attributes
+
+:name: The full name of the finish which is applied to the tile
+:code: The abbreviation of the tile finish as used by the manufacturer
+
+TileLine
+--------
+
+TileLine resources specifies information about the size of the tile.
+This resource is read-only.
+
+Attributes
+
+:nominal: The nominal size of the tile. This is the advertising size of the tile.
+:actual: The actual size of the tile.
+:name: The name of the tile. Usually is a string of a fraction of the nominal tile size.
+:grout: The size of the grout for the tile size
+
+Grout
+-----
+
+Grout resource specifies the information about the available grouts for the production.
+This resource is read-only.
+
+Attributes
+
+:color: Comma separated RGB color of the grout
+:manufacturer: Reference to the GroutManufacturer resource
+:name: The English name given to the grout color
+
+GroutManufacturer
+-----------------
+
+GroutManufacturer specifies the manufacturer of the grout.
+This resource is read-only.
+
+Attributes
+
+:name: The name of the manufacturer
+
+