Squashed 'modules/libjuju/' content from commit c50c361

git-subtree-dir: modules/libjuju
git-subtree-split: c50c361a8b9a3bbf1a33f5659e492b481f065cd2
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..2869eb4
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,230 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+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
+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
+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 "  applehelp  to make an Apple Help Book"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  epub3      to make an epub3"
+	@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)"
+	@echo "  coverage   to run coverage check of the documentation (if enabled)"
+	@echo "  dummy      to check syntax errors of document sources"
+
+.PHONY: clean
+clean:
+	rm -rf $(BUILDDIR)/*
+
+.PHONY: html
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+.PHONY: dirhtml
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+.PHONY: singlehtml
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+.PHONY: pickle
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+.PHONY: json
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+.PHONY: htmlhelp
+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."
+
+.PHONY: qthelp
+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/libjuju.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/libjuju.qhc"
+
+.PHONY: applehelp
+applehelp:
+	$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
+	@echo
+	@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
+	@echo "N.B. You won't be able to view it unless you put it in" \
+	      "~/Library/Documentation/Help or install it in your application" \
+	      "bundle."
+
+.PHONY: devhelp
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/libjuju"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/libjuju"
+	@echo "# devhelp"
+
+.PHONY: epub
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+.PHONY: epub3
+epub3:
+	$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
+	@echo
+	@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
+
+.PHONY: latex
+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)."
+
+.PHONY: latexpdf
+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."
+
+.PHONY: latexpdfja
+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."
+
+.PHONY: text
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+.PHONY: man
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+.PHONY: texinfo
+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)."
+
+.PHONY: info
+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."
+
+.PHONY: gettext
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+.PHONY: changes
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+.PHONY: linkcheck
+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."
+
+.PHONY: doctest
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+
+.PHONY: coverage
+coverage:
+	$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
+	@echo "Testing of coverage in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/coverage/python.txt."
+
+.PHONY: xml
+xml:
+	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+	@echo
+	@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+.PHONY: pseudoxml
+pseudoxml:
+	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+	@echo
+	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
+
+.PHONY: dummy
+dummy:
+	$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
+	@echo
+	@echo "Build finished. Dummy builder generates no files."
diff --git a/docs/_extensions/automembersummary.py b/docs/_extensions/automembersummary.py
new file mode 100644
index 0000000..898da62
--- /dev/null
+++ b/docs/_extensions/automembersummary.py
@@ -0,0 +1,114 @@
+# Copyright 2014-2015 Canonical Limited.
+#
+# This file is part of charm-helpers.
+#
+# charm-helpers is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# charm-helpers is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with charm-helpers.  If not, see <http://www.gnu.org/licenses/>.
+
+
+import importlib
+import inspect
+import textwrap
+
+from docutils import nodes
+from docutils.statemachine import ViewList
+from sphinx.errors import SphinxError
+from sphinx.util.compat import Directive
+from sphinx.util.nodes import nested_parse_with_titles
+
+
+class AutoMemberSummary(Directive):
+    required_arguments = 1
+
+    def run(self):
+        module_name = self.arguments[0]
+
+        try:
+            module = importlib.import_module(module_name)
+        except ImportError:
+            raise SphinxError("Unable to generate reference docs for %s, "
+                              "could not import" % (module_name))
+
+        divider = '+{:-<80}+'.format('')
+        row = '| {:<78} |'.format
+        lines = []
+        for member_name, member in inspect.getmembers(module):
+            if not self._filter(module_name, member_name, member):
+                continue
+            summary = textwrap.wrap(self._get_summary(member), 78) or ['']
+            link = '`{} <#{}>`_'.format(member_name,
+                                        '.'.join([module_name,
+                                                  member_name]))
+            methods = ['* `{} <#{}>`_'.format(n,
+                                              '.'.join([module_name,
+                                                        member_name,
+                                                        n]))
+                       for n, m in inspect.getmembers(member)
+                       if not n.startswith('_') and inspect.isfunction(m)]
+
+            lines.append(divider)
+            lines.append(row(link))
+            lines.append(divider)
+            for line in summary:
+                lines.append(row(line))
+            if methods:
+                lines.append(row(''))
+                lines.append(row('Methods:'))
+                lines.append(row(''))
+                for i, method in enumerate(methods):
+                    lines.append(row(method))
+        lines.append(divider)
+        content = '\n'.join(lines)
+
+        result = self._parse(content, '<automembersummary>')
+        return result
+
+    def _get_summary(self, member):
+        doc = (member.__doc__ or '').splitlines()
+
+        # strip any leading blank lines
+        while doc and not doc[0].strip():
+            doc.pop(0)
+
+        # strip anything after the first blank line
+        for i, piece in enumerate(doc):
+            if not piece.strip():
+                doc = doc[:i]
+                break
+
+        return " ".join(doc).strip()
+
+    def _filter(self, module_name, member_name, member):
+        if member_name.startswith('_'):
+            return False
+        if hasattr(member, '__module__'):
+            # skip imported classes & functions
+            return member.__module__.startswith(module_name)
+        elif hasattr(member, '__name__'):
+            # skip imported modules
+            return member.__name__.startswith(module_name)
+        else:
+            return False  # skip instances
+        return True
+
+    def _parse(self, rst_text, annotation):
+        result = ViewList()
+        for line in rst_text.split("\n"):
+            result.append(line, annotation)
+        node = nodes.paragraph()
+        node.document = self.state.document
+        nested_parse_with_titles(self.state, result, node)
+        return node.children
+
+
+def setup(app):
+    app.add_directive('automembersummary', AutoMemberSummary)
diff --git a/docs/_static/custom.css b/docs/_static/custom.css
new file mode 100644
index 0000000..333cd74
--- /dev/null
+++ b/docs/_static/custom.css
@@ -0,0 +1,5 @@
+.wy-table-responsive table td,
+.wy-table-responsive table th
+{
+    white-space: normal !important;
+}
diff --git a/docs/api/juju.action.rst b/docs/api/juju.action.rst
new file mode 100644
index 0000000..cc86af2
--- /dev/null
+++ b/docs/api/juju.action.rst
@@ -0,0 +1,13 @@
+juju.action
+===========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.action
+
+.. rubric:: Reference
+
+.. automodule:: juju.action
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.annotation.rst b/docs/api/juju.annotation.rst
new file mode 100644
index 0000000..ec31344
--- /dev/null
+++ b/docs/api/juju.annotation.rst
@@ -0,0 +1,13 @@
+juju.annotation
+===============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.annotation
+
+.. rubric:: Reference
+
+.. automodule:: juju.annotation
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.application.rst b/docs/api/juju.application.rst
new file mode 100644
index 0000000..dba9177
--- /dev/null
+++ b/docs/api/juju.application.rst
@@ -0,0 +1,13 @@
+juju.application
+================
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.application
+
+.. rubric:: Reference
+
+.. automodule:: juju.application
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.client.rst b/docs/api/juju.client.rst
new file mode 100644
index 0000000..6a699c0
--- /dev/null
+++ b/docs/api/juju.client.rst
@@ -0,0 +1,120 @@
+juju\.client package
+====================
+
+These packages are for internal use in communicating with the low-level
+API.  You should use the object oriented API instead.  They are documented
+here for developer reference.
+
+
+juju\.client\.client module
+---------------------------
+
+.. automodule:: juju.client.client
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\._definitions module
+---------------------------------
+
+.. automodule:: juju.client._definitions
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\._client module
+----------------------------
+
+.. automodule:: juju.client._client
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\._client1 module
+-----------------------------
+
+.. automodule:: juju.client._client1
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\._client2 module
+-----------------------------
+
+.. automodule:: juju.client._client2
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\._client3 module
+-----------------------------
+
+.. automodule:: juju.client._client3
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\._client4 module
+-----------------------------
+
+.. automodule:: juju.client._client4
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\._client5 module
+-----------------------------
+
+.. automodule:: juju.client._client5
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\.codegen module
+----------------------------
+
+.. automodule:: juju.client.codegen
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\.connection module
+-------------------------------
+
+.. automodule:: juju.client.connection
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\.facade module
+---------------------------
+
+.. automodule:: juju.client.facade
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\.overrides module
+------------------------------
+
+.. automodule:: juju.client.overrides
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+juju\.client\.runner module
+---------------------------
+
+.. automodule:: juju.client.runner
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+
+Module contents
+---------------
+
+.. automodule:: juju.client
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.cloud.rst b/docs/api/juju.cloud.rst
new file mode 100644
index 0000000..39021e0
--- /dev/null
+++ b/docs/api/juju.cloud.rst
@@ -0,0 +1,13 @@
+juju.cloud
+==========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.cloud
+
+.. rubric:: Reference
+
+.. automodule:: juju.cloud
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.constraints.rst b/docs/api/juju.constraints.rst
new file mode 100644
index 0000000..5fcbd31
--- /dev/null
+++ b/docs/api/juju.constraints.rst
@@ -0,0 +1,13 @@
+juju.constraints
+================
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.constraints
+
+.. rubric:: Reference
+
+.. automodule:: juju.constraints
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.controller.rst b/docs/api/juju.controller.rst
new file mode 100644
index 0000000..4484fd5
--- /dev/null
+++ b/docs/api/juju.controller.rst
@@ -0,0 +1,13 @@
+juju.controller
+===============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.controller
+
+.. rubric:: Reference
+
+.. automodule:: juju.controller
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.delta.rst b/docs/api/juju.delta.rst
new file mode 100644
index 0000000..9924f8c
--- /dev/null
+++ b/docs/api/juju.delta.rst
@@ -0,0 +1,13 @@
+juju.delta
+==========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.delta
+
+.. rubric:: Reference
+
+.. automodule:: juju.delta
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.errors.rst b/docs/api/juju.errors.rst
new file mode 100644
index 0000000..7c77574
--- /dev/null
+++ b/docs/api/juju.errors.rst
@@ -0,0 +1,13 @@
+juju.errors
+===========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.errors
+
+.. rubric:: Reference
+
+.. automodule:: juju.errors
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.exceptions.rst b/docs/api/juju.exceptions.rst
new file mode 100644
index 0000000..85be2fb
--- /dev/null
+++ b/docs/api/juju.exceptions.rst
@@ -0,0 +1,13 @@
+juju.exceptions
+===============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.exceptions
+
+.. rubric:: Reference
+
+.. automodule:: juju.exceptions
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.juju.rst b/docs/api/juju.juju.rst
new file mode 100644
index 0000000..68698c3
--- /dev/null
+++ b/docs/api/juju.juju.rst
@@ -0,0 +1,13 @@
+juju.juju
+=========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.juju
+
+.. rubric:: Reference
+
+.. automodule:: juju.juju
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.loop.rst b/docs/api/juju.loop.rst
new file mode 100644
index 0000000..4f175e9
--- /dev/null
+++ b/docs/api/juju.loop.rst
@@ -0,0 +1,13 @@
+juju.loop
+=========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.loop
+
+.. rubric:: Reference
+
+.. automodule:: juju.loop
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.machine.rst b/docs/api/juju.machine.rst
new file mode 100644
index 0000000..edb5b6c
--- /dev/null
+++ b/docs/api/juju.machine.rst
@@ -0,0 +1,13 @@
+juju.machine
+============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.machine
+
+.. rubric:: Reference
+
+.. automodule:: juju.machine
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.model.rst b/docs/api/juju.model.rst
new file mode 100644
index 0000000..dfb735d
--- /dev/null
+++ b/docs/api/juju.model.rst
@@ -0,0 +1,13 @@
+juju.model
+==========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.model
+
+.. rubric:: Reference
+
+.. automodule:: juju.model
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.placement.rst b/docs/api/juju.placement.rst
new file mode 100644
index 0000000..67cde0c
--- /dev/null
+++ b/docs/api/juju.placement.rst
@@ -0,0 +1,13 @@
+juju.placement
+==============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.placement
+
+.. rubric:: Reference
+
+.. automodule:: juju.placement
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.relation.rst b/docs/api/juju.relation.rst
new file mode 100644
index 0000000..90e3130
--- /dev/null
+++ b/docs/api/juju.relation.rst
@@ -0,0 +1,13 @@
+juju.relation
+=============
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.relation
+
+.. rubric:: Reference
+
+.. automodule:: juju.relation
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.tag.rst b/docs/api/juju.tag.rst
new file mode 100644
index 0000000..9b3a29f
--- /dev/null
+++ b/docs/api/juju.tag.rst
@@ -0,0 +1,13 @@
+juju.tag
+========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.tag
+
+.. rubric:: Reference
+
+.. automodule:: juju.tag
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.unit.rst b/docs/api/juju.unit.rst
new file mode 100644
index 0000000..4a7d167
--- /dev/null
+++ b/docs/api/juju.unit.rst
@@ -0,0 +1,13 @@
+juju.unit
+=========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.unit
+
+.. rubric:: Reference
+
+.. automodule:: juju.unit
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/juju.utils.rst b/docs/api/juju.utils.rst
new file mode 100644
index 0000000..9220a1b
--- /dev/null
+++ b/docs/api/juju.utils.rst
@@ -0,0 +1,13 @@
+juju.utils
+==========
+
+.. rubric:: Summary
+
+.. automembersummary:: juju.utils
+
+.. rubric:: Reference
+
+.. automodule:: juju.utils
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/api/modules.rst b/docs/api/modules.rst
new file mode 100644
index 0000000..bf06f26
--- /dev/null
+++ b/docs/api/modules.rst
@@ -0,0 +1,31 @@
+juju
+====
+
+It is recommended that you start with :doc:`juju.model` or :doc:`juju.controller`.
+If you need helpers to manage the asyncio loop, try :doc:`juju.loop`.
+
+.. toctree::
+
+    juju.action
+    juju.annotation
+    juju.application
+    juju.cloud
+    juju.constraints
+    juju.controller
+    juju.delta
+    juju.errors
+    juju.exceptions
+    juju.juju
+    juju.loop
+    juju.machine
+    juju.model
+    juju.placement
+    juju.relation
+    juju.tag
+    juju.unit
+    juju.utils
+
+.. automodule:: juju
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/changelog.rst b/docs/changelog.rst
new file mode 100644
index 0000000..9da0cdc
--- /dev/null
+++ b/docs/changelog.rst
@@ -0,0 +1,130 @@
+Change Log
+----------
+
+0.6.0
+^^^^^
+Thu June 29 2017
+
+* Implement scp functionality (#149)
+* Add Unit.public_address property (#153)
+* Adds support for getting/setting config on a model (#152)
+
+0.5.3
+^^^^^
+Thu June 22 2017
+
+* Improve handling of closed connections (#148)
+* Configurable and larger max message size (#146)
+
+0.5.2
+^^^^^
+Wed June 14 2017
+
+* Fix deploying non-stable channels and explicit revs (#144)
+
+0.5.1
+^^^^^
+Tue June 13 2017
+
+* Update schema for Juju 2.3 alpha1 (#142)
+* Improve API doc navigation and coverage (#141)
+* Add type info to Model.add_machine docs (#138)
+
+0.5.0
+^^^^^
+Thu June 8 2017
+
+* Add machine status properties (#133)
+* Add model context manager (#128)
+* Implement Application.upgrade_charm method (#132)
+
+0.4.3
+^^^^^
+Thu June 1 2017
+
+* Accept new / unknown API fields gracefully (#131)
+* Add support for new agent-version field in ModelInfo (#131)
+* Replace pip with pip3 in install instructions (#129)
+* Strip local:-prefix from local charm urls (#121)
+
+0.4.2
+^^^^^
+Wed May 10 2017
+
+* Support (and prefer) per-controller macaroon files (#125)
+
+0.4.1
+^^^^^
+Wed Apr 27 2017
+
+* Remove VERSION_MAP and rely on facade list from controller (#118)
+* Refactor connection task management to avoid cancels (#117)
+* Refactored login code to better handle redirects (#116)
+
+0.4.0
+^^^^^
+Wed Apr 19 2017
+
+* Feature/api version support (#109)
+* Expanding controller.py with basic user functions, get_models and
+  destroy (#89)
+* Added Monitor class to Connection. (#105)
+* Support placement lists (#103)
+* Include resources from store when deploying (#102)
+* Allow underscore to dash translation when accessing model
+  attributes (#101)
+* Added controller to ssh fix. (#100)
+* Regen schema to pick up missing APIs
+* Improve error handling
+* Fix issue where we do not check to make sure that we are receiving the
+  correct response.
+* Retry calls to charmstore and increase timeout to 5s
+* Make connect_model and deploy a bit more friendly
+* Fix model name not including user
+* Implement Model.get_status
+* Add integration tests.
+
+0.3.0
+^^^^^
+Mon Feb 27 2017
+
+* Fix docstrings for placement directives.
+* Implement Model.add_machine()
+* Bug fix - "to" parameter to Model.deploy() was broken
+* Add docs and examples for adding machines and containers and deploying
+  charms to them.
+* Make Machine.destroy() block the current coroutine, returning only after
+  the machine is actually removed from the remote model. This is more
+  consistent with the way the other apis work (e.g. Model.deploy(),
+  Application.add_unit(), etc).
+* Raise NotImplementedError in all unimplemented method stubs instead of
+  silently passing.
+
+0.2.0
+^^^^^
+Thu Feb 16 2017
+
+* Add default ssh key to newly created model.
+* Add loop helpers and simplify examples/deploy.py
+* Add support for deploying local charms, and bundles containing local charm paths.
+* Add ability to get cloud name for controller.
+* Bug fix - fix wrong api used in Model.destroy_unit()
+* Add error detection in bundle deploy.
+
+0.1.2
+^^^^^
+Thu Dec 22 2016
+
+* Bug fix - Include docs in package
+
+0.1.1
+^^^^^
+Thu Dec 22 2016
+
+* Bug fix - Include VERSION file in package
+
+0.1.0
+^^^^^
+Wed Dec 21 2016
+
+* Initial Release
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..a95ec04
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,303 @@
+# -*- coding: utf-8 -*-
+#
+# libjuju documentation build configuration file, created by
+# sphinx-quickstart on Thu May 19 11:21:38 2016.
+#
+# 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
+import os
+
+from pathlib import Path
+
+here = Path(__file__).absolute().parent
+version = (here.parent / 'VERSION').read_text().strip()
+
+# 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.
+sys.path.append(os.path.abspath('_extensions/'))
+extensions = [
+    'sphinx.ext.autodoc',
+    'sphinx.ext.autosummary',
+    'sphinx.ext.intersphinx',
+    'sphinx.ext.todo',
+    'sphinx.ext.viewcode',
+    'sphinxcontrib.asyncio',
+    'automembersummary',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+# source_suffix = ['.rst', '.md']
+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'juju'
+copyright = u'2016, Canonical Ltd.'
+author = u'Canonical'
+
+# 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 = version
+# The full version, including alpha/beta/rc tags.
+release = version
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+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.
+# This patterns also effect to html_static_path and html_extra_path
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+# 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 = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+# If true, `todo` and `todoList` produce output, else they produce nothing.
+todo_include_todos = True
+
+
+# -- 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 = 'sphinx_rtd_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.
+# "<project> v<release> documentation" by default.
+#html_title = u'libjuju v0.0.0'
+
+# 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 (relative to this directory) to use as a 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']
+
+# 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 None, a 'Last updated on:' timestamp is inserted at every page
+# bottom, using the given strftime format.
+# The empty string is equivalent to '%b %d, %Y'.
+#html_last_updated_fmt = None
+
+# 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
+
+# Language to be used for generating the HTML full-text search index.
+# Sphinx supports the following languages:
+#   'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
+#   'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
+#html_search_language = 'en'
+
+# A dictionary with options for the search language support, empty by default.
+# 'ja' uses this config value.
+# 'zh' user can custom change `jieba` dictionary path.
+#html_search_options = {'type': 'default'}
+
+# The name of a javascript file (relative to the configuration directory) that
+# implements a search results scorer. If empty, the default will be used.
+#html_search_scorer = 'scorer.js'
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'libjujudoc'
+
+# -- 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': '',
+
+# Latex figure (float) alignment
+#'figure_align': 'htbp',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+#  author, documentclass [howto, manual, or own class]).
+latex_documents = [
+    (master_doc, 'libjuju.tex', u'libjuju Documentation',
+     u'Canonical', '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 = [
+    (master_doc, 'libjuju', u'libjuju Documentation',
+     [author], 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 = [
+    (master_doc, 'libjuju', u'libjuju Documentation',
+     author, 'libjuju', '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'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+
+def setup(app):
+    app.add_stylesheet('custom.css')
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..b4b075f
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,32 @@
+.. libjuju documentation master file, created by
+   sphinx-quickstart on Thu May 19 11:21:38 2016.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+
+.. include:: readme.rst
+
+
+Table of Contents
+-----------------
+
+.. toctree::
+   :glob:
+   :maxdepth: 3
+
+   narrative/index
+   API Docs <api/modules>
+   Internal API Docs <api/juju.client>
+   upstream-updates/index
+
+
+.. include:: changelog.rst
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/docs/narrative/application.rst b/docs/narrative/application.rst
new file mode 100644
index 0000000..1565e5f
--- /dev/null
+++ b/docs/narrative/application.rst
@@ -0,0 +1,136 @@
+Applications
+============
+For api docs, see :class:`juju.application.Application`.
+
+
+Deploying
+---------
+To deploy a new application, connect a model and then call its
+:meth:`~juju.model.Model.deploy` method. An
+:class:`~juju.application.Application` instance is returned.
+
+.. code:: python
+
+  from juju.model import Model
+
+  model = Model()
+  await model.connect_current()
+
+  mysql_app = await model.deploy(
+      # If a revision number is not included in the charm url,
+      # the latest revision from the Charm Store will be used.
+      'cs:mysql-55',
+      application_name='mysql',
+      series='trusty',
+      channel='stable',
+      config={
+          'tuning-level': 'safest',
+      },
+      constraints={
+          'mem': 256 * MB,
+      },
+  )
+
+
+Deploying a Local Charm
+-----------------------
+To deploy a local charm, pass the charm directory path to
+`Model.deploy()`.
+
+.. code:: python
+
+  from juju.model import Model
+
+  model = Model()
+  await model.connect_current()
+
+  # Deploy a local charm using a path to the charm directory
+  await model.deploy(
+      '/home/tvansteenburgh/src/charms/ubuntu',
+      application_name='ubuntu',
+      series='trusty',
+  )
+
+
+Adding Units
+------------
+To add units to a deployed application, use the
+:meth:`juju.application.Application.add_units` method. A list of the newly
+added units (:class:`~juju.unit.Unit` objects) is returned.
+
+.. code:: python
+
+  ubuntu_app = await model.deploy(
+      'ubuntu',
+      application_name='ubuntu',
+      series='trusty',
+      channel='stable',
+  )
+
+  unit_a, unit_b = await ubuntu_app.add_units(count=2)
+
+
+Updating Config and Constraints
+-------------------------------
+Example showing how to update configuration and constraints on a deployed
+application. The `mysql_app` object is an instance of
+:class:`juju.application.Application`.
+
+.. code:: python
+
+  MB = 1024 * 1024
+
+  # Update and check app config
+  await mysql_app.set_config({'tuning-level': 'fast'})
+  config = await mysql_app.get_config()
+
+  assert(config['tuning-level']['value'] == 'fast')
+
+  # update and check app constraints
+  await mysql_app.set_constraints({'mem': 512 * MB})
+  constraints = await mysql_app.get_constraints()
+
+  assert(constraints['mem'] == 512 * MB)
+
+
+Adding and Removing Relations
+-----------------------------
+The :meth:`juju.application.Application.add_relation` method returns a
+:class:`juju.relation.Relation` instance.
+
+.. code:: python
+
+  from juju.model import Model
+
+  model = Model()
+  await model.connect_current()
+
+  # Deploy mysql-master application
+  mysql_master = await model.deploy(
+      'cs:mysql-55',
+      application_name='mysql-master',
+      series='trusty',
+      channel='stable',
+  )
+
+  # Deploy mysql-slave application
+  mysql_slave = await model.deploy(
+      'cs:mysql-55',
+      application_name='mysql-slave',
+      series='trusty',
+      channel='stable',
+  )
+
+  # Add the master-slave relation
+  relation = await mysql_master.add_relation(
+      # Name of the relation on the local (mysql-master) side
+      'master',
+      # Name of the app:relation on the remote side
+      'mysql-slave:slave',
+  )
+
+  # Remove the relation
+  await mysql_master.remove_relation(
+      'master',
+      'mysql-slave:slave',
+  )
diff --git a/docs/narrative/controller.rst b/docs/narrative/controller.rst
new file mode 100644
index 0000000..2da0e7b
--- /dev/null
+++ b/docs/narrative/controller.rst
@@ -0,0 +1,100 @@
+Controllers
+===========
+A Juju controller provides websocket endpoints for itself and each of its
+models. In order to do anything useful, the juju lib must connect to one of
+these endpoints.
+
+Connecting to the controller endpoint is useful if you want to programmatically
+create a new model. If the model you want to use already exists, you can
+connect directly to it (see :doc:`model`).
+
+For api docs, see :class:`juju.controller.Controller`.
+
+
+Connecting to the Current Controller
+------------------------------------
+Connect to the currently active Juju controller (the one returned by
+`juju switch`). This only works if you have the Juju CLI client installed.
+
+.. code:: python
+
+  from juju.controller import Controller
+
+  controller = Controller()
+  await controller.connect_current()
+
+
+Connecting to a Named Controller
+--------------------------------
+Connect to a controller by name.
+
+.. code:: python
+
+  from juju.controller import Controller
+
+  controller = Controller()
+  await controller.connect_controller('mycontroller')
+
+
+Connecting with Username/Password Authentication
+------------------------------------------------
+The most flexible, but also most verbose, way to connect is using the API
+endpoint url and credentials directly. This method does NOT require the Juju
+CLI client to be installed.
+
+.. code:: python
+
+  from juju.controller import Controller
+
+  controller = Controller()
+
+  controller_endpoint = '10.0.4.171:17070'
+  username = 'admin'
+  password = 'f53f08cfc32a2e257fe5393271d89d62'
+
+  # Left out for brevity, but if you have a cert string you should pass it in.
+  # You can copy the cert from the output of The `juju show-controller`
+  # command.
+  cacert = None
+
+  await controller.connect(
+      controller_endpoint,
+      username,
+      password,
+      cacert,
+  )
+
+
+Connecting with Macaroon Authentication
+---------------------------------------
+To connect to a shared controller, you'll need
+to use macaroon authentication. The simplest example is shown below, and uses
+already-discharged macaroons from the local filesystem. This will work if you
+have the Juju CLI installed.
+
+.. note::
+
+  The library does not yet contain support for fetching and discharging
+  macaroons. Until it does, if you want to use macaroon auth, you'll need
+  to supply already-discharged macaroons yourself.
+
+.. code:: python
+
+  from juju.client.connection import get_macaroons()
+  from juju.controller import Controller
+
+  controller = Controller()
+
+  controller_endpoint = '10.0.4.171:17070'
+  username = None
+  password = None
+  cacert = None
+  macaroons = get_macaroons()
+
+  await controller.connect(
+      controller_endpoint,
+      username,
+      password,
+      cacert,
+      macaroons,
+  )
diff --git a/docs/narrative/index.rst b/docs/narrative/index.rst
new file mode 100644
index 0000000..eb77e4c
--- /dev/null
+++ b/docs/narrative/index.rst
@@ -0,0 +1,11 @@
+Narrative Docs
+==============
+
+.. toctree::
+   :glob:
+   :maxdepth: 2
+
+   controller
+   model
+   application
+   unit
diff --git a/docs/narrative/model.rst b/docs/narrative/model.rst
new file mode 100644
index 0000000..57dbc81
--- /dev/null
+++ b/docs/narrative/model.rst
@@ -0,0 +1,306 @@
+Models
+======
+A Juju controller provides websocket endpoints for each of its
+models. In order to do anything useful with a model, the juju lib must
+connect to one of these endpoints. There are several ways to do this.
+
+For api docs, see :class:`juju.model.Model`.
+
+
+Connecting to the Current Model
+-------------------------------
+Connect to the currently active Juju model (the one returned by
+`juju switch`). This only works if you have the Juju CLI client installed.
+
+.. code:: python
+
+  from juju.model import Model
+
+  model = Model()
+  await model.connect_current()
+
+
+Connecting to a Named Model
+---------------------------
+Connect to a model by name, using the same format as that returned from the
+`juju switch` command. The accepted format is '[controller:][user/]model'.
+This only works if you have the Juju CLI client installed.
+
+.. code:: python
+
+  # $ juju switch
+  # juju-2.0.1:admin/libjuju
+
+  from juju.model import Model
+
+  model = Model()
+  await model.connect_model('juju-2.0.1:admin/libjuju')
+
+
+Connecting with Username/Password Authentication
+------------------------------------------------
+The most flexible, but also most verbose, way to connect is using the API
+endpoint url and credentials directly. This method does NOT require the Juju
+CLI client to be installed.
+
+.. code:: python
+
+  from juju.model import Model
+
+  model = Model()
+
+  controller_endpoint = '10.0.4.171:17070'
+  model_uuid = 'e8399ac7-078c-4817-8e5e-32316d55b083'
+  username = 'admin'
+  password = 'f53f08cfc32a2e257fe5393271d89d62'
+
+  # Left out for brevity, but if you have a cert string you should pass it in.
+  # You can copy the cert from the output of The `juju show-controller`
+  # command.
+  cacert = None
+
+  await model.connect(
+      controller_endpoint,
+      model_uuid,
+      username,
+      password,
+      cacert,
+  )
+
+
+Connecting with Macaroon Authentication
+---------------------------------------
+To connect to a shared model, or a model an a shared controller, you'll need
+to use macaroon authentication. The simplest example is shown below, and uses
+already-discharged macaroons from the local filesystem. This will work if you
+have the Juju CLI installed.
+
+.. note::
+
+  The library does not yet contain support for fetching and discharging
+  macaroons. Until it does, if you want to use macaroon auth, you'll need
+  to supply already-discharged macaroons yourself.
+
+.. code:: python
+
+  from juju.client.connection import get_macaroons()
+  from juju.model import Model
+
+  model = Model()
+
+  controller_endpoint = '10.0.4.171:17070'
+  model_uuid = 'e8399ac7-078c-4817-8e5e-32316d55b083'
+  username = None
+  password = None
+  cacert = None
+  macaroons = get_macaroons()
+
+  await model.connect(
+      controller_endpoint,
+      model_uuid,
+      username,
+      password,
+      cacert,
+      macaroons,
+  )
+
+
+Creating and Destroying a Model
+-------------------------------
+Example of creating a new model and then destroying it. See
+:meth:`juju.controller.Controller.add_model` and
+:meth:`juju.controller.Controller.destroy_model` for more info.
+
+.. code:: python
+
+  from juju.controller import Controller
+
+  controller = Controller()
+  await controller.connect_current()
+
+  # Create our new model
+  model = await controller.add_model(
+      'mymodel',  # name of your new model
+  )
+
+  # Do stuff with our model...
+
+  # Destroy the model
+  await model.disconnect()
+  await controller.destroy_model(model.info.uuid)
+  model = None
+
+
+Adding Machines and Containers
+------------------------------
+To add a machine or container, connect to a model and then call its
+:meth:`~juju.model.Model.add_machine` method. A
+:class:`~juju.machine.Machine` instance is returned. The machine id
+can be used to deploy a charm to a specific machine or container.
+
+.. code:: python
+
+  from juju.model import Model
+
+  MB = 1
+  GB = 1024
+
+
+  model = Model()
+  await model.connect_current()
+
+  # add a new default machine
+  machine1 = await model.add_machine()
+
+  # add a machine with constraints, disks, and series specified
+  machine2 = await model.add_machine(
+      constraints={
+          'mem': 256 * MB,
+      },
+      disks=[{
+          'pool': 'rootfs',
+          'size': 10 * GB,
+          'count': 1,
+      }],
+      series='xenial',
+  )
+
+  # add a lxd container to machine2
+  machine3 = await model.add_machine(
+      'lxd:{}'.format(machine2.id))
+
+  # deploy charm to the lxd container
+  application = await model.deploy(
+      'ubuntu-10',
+      application_name='ubuntu',
+      series='xenial',
+      channel='stable',
+      to=machine3.id
+  )
+
+  # remove application
+  await application.remove()
+
+  # destroy machines - note that machine3 must be destroyed before machine2
+  # since it's a container on machine2
+  await machine3.destroy(force=True)
+  await machine2.destroy(force=True)
+  await machine1.destroy(force=True)
+
+
+Reacting to Changes in a Model
+------------------------------
+To watch for and respond to changes in a model, register an observer with the
+model. The easiest way to do this is by creating a
+:class:`juju.model.ModelObserver` subclass.
+
+.. code:: python
+
+  from juju.model import Model, ModelObserver
+
+  class MyModelObserver(ModelObserver):
+      async def on_change(self, delta, old, new, model):
+          # The raw change data (dict) from the websocket.
+          print(delta.data)
+
+          # The entity type (str) affected by this change.
+          # One of ('action', 'application', 'annotation', 'machine',
+          # 'unit', 'relation')
+          print(delta.entity)
+
+          # The type (str) of change.
+          # One of ('add', 'change', 'remove')
+          print(delta.type)
+
+          # The 'old' and 'new' parameters are juju.model.ModelEntity
+          # instances which represent an entity in the model both before
+          # this change was applied (old) and after (new).
+
+          # If an entity is being added to the model, the 'old' param
+          # will be None.
+          if delta.type == 'add':
+              assert(old is None)
+
+          # If an entity is being removed from the model, the 'new' param
+          # will be None.
+          if delta.type == 'remove':
+              assert(new is None)
+
+          # The 'old' and 'new' parameters, when not None, will be instances
+          # of a juju.model.ModelEntity subclass. The type of the subclass
+          # depends on the value of 'delta.entity', for example:
+          #
+          # delta.entity     type
+          # ------------     ----
+          # 'action'      -> juju.action.Action
+          # 'application' -> juju.application.Application
+          # 'annotation'  -> juju.annotation.Annotation
+          # 'machine'     -> juju.machine.Machine
+          # 'unit'        -> juju.unit.Unit
+          # 'relation'    -> juju.relation.Relation
+
+          # Finally, the 'model' parameter is a reference to the
+          # juju.model.Model instance to which this observer is attached.
+          print(id(model))
+
+
+  model = Model()
+  await model.connect_current()
+
+  model.add_observer(MyModelObserver())
+
+
+Every change in the model will result in a call to the `on_change()`
+method of your observer(s).
+
+To target your code more precisely, define method names that correspond
+to the entity and type of change that you wish to handle.
+
+.. code:: python
+
+  from juju.model import Model, ModelObserver
+
+  class MyModelObserver(ModelObserver):
+      async def on_application_change(self, delta, old, new, model):
+          # Both 'old' and 'new' params will be instances of
+          # juju.application.Application
+          pass
+
+      async def on_unit_remove(self, delta, old, new, model):
+          # Since a unit is being removed, the 'new' param will always
+          # be None in this handler. The 'old' param will be an instance
+          # of juju.unit.Unit - the state of the unit before it was removed.
+          pass
+
+      async def on_machine_add(self, delta, old, new, model):
+          # Since a machine is being added, the 'old' param will always be
+          # None in this handler. The 'new' param will be an instance of
+          # juju.machine.Machine.
+          pass
+
+      async def on_change(self, delta, old, new, model):
+          # The catch-all handler - will be called whenever a more
+          # specific handler method is not defined.
+
+
+Any :class:`juju.model.ModelEntity` object can be observed directly by
+registering callbacks on the object itself.
+
+.. code:: python
+
+  import logging
+
+  async def on_app_change(delta, old, new, model):
+      logging.debug('App changed: %r', new)
+
+  async def on_app_remove(delta, old, new, model):
+      logging.debug('App removed: %r', old)
+
+  ubuntu_app = await model.deploy(
+      'ubuntu',
+      application_name='ubuntu',
+      series='trusty',
+      channel='stable',
+  )
+  ubuntu_app.on_change(on_app_change)
+  ubuntu_app.on_remove(on_app_remove)
diff --git a/docs/narrative/unit.rst b/docs/narrative/unit.rst
new file mode 100644
index 0000000..5d6b48d
--- /dev/null
+++ b/docs/narrative/unit.rst
@@ -0,0 +1,65 @@
+Units
+=====
+For api docs, see :class:`juju.unit.Unit`.
+
+
+Running Commands
+----------------
+Run arbitrary commands on a unit with the
+:meth:`juju.unit.Unit.run` method. This method blocks
+the current coroutine until a result is available, and
+returns a :class:`juju.action.Action` instance.
+
+
+.. code:: python
+
+  from juju.model import Model
+
+  model = Model()
+  await model.connect_current()
+
+  app = await model.deploy(
+      'ubuntu',
+      application_name='ubuntu',
+      series='trusty',
+      channel='stable',
+  )
+
+  for unit in app.units:
+      action = await unit.run('unit-get public-address')
+      print(action.results)
+
+      action = await unit.run('uname -a')
+      print(action.results)
+
+
+Running Actions
+---------------
+Run actions on a unit with the
+:meth:`juju.unit.Unit.run_action` method. This method
+returns a :class:`juju.action.Action` instance immediately. To block until
+the action completes, use the :meth:`juju.action.Action.wait` method, as
+in the example below.
+
+
+.. code:: python
+
+  from juju.model import Model
+
+  model = Model()
+  await model.connect_current()
+
+  app = await model.deploy(
+      'git',
+      application_name='git',
+      series='trusty',
+      channel='stable',
+  )
+
+  for unit in app.units:
+      # run the 'add-repo' action, passing a 'repo' param
+      action = await unit.run_action('add-repo', repo='myrepo')
+      # wait for the action to complete
+      action = await action.wait()
+
+      print(action.results)
diff --git a/docs/readme.rst b/docs/readme.rst
new file mode 100644
index 0000000..ecfbc5a
--- /dev/null
+++ b/docs/readme.rst
@@ -0,0 +1,95 @@
+A Python library for Juju
+=========================
+
+Source code: https://github.com/juju/python-libjuju
+
+Bug reports: https://github.com/juju/python-libjuju/issues
+
+Documentation: https://pythonlibjuju.readthedocs.io/en/latest/
+
+
+Requirements
+------------
+
+* Python 3.5+
+* Juju 2.0+
+
+
+Design Notes
+------------
+
+* Asynchronous - uses asyncio and async/await features of python 3.5
+* Websocket-level bindings are programmatically generated (indirectly) from the
+  Juju golang code, ensuring full api coverage
+* Provides an OO layer which encapsulates much of the websocket api and
+  provides familiar nouns and verbs (e.g. Model.deploy(), Application.add_unit(),
+  etc.)
+
+
+Installation
+------------
+
+.. code:: bash
+
+  pip3 install juju
+
+
+Quickstart
+----------
+Here's a simple example that shows basic usage of the library. The example
+connects to the currently active Juju model, deploys a single unit of the
+ubuntu charm, then exits.
+
+More examples can be found in the `examples/` directory of the source tree,
+and in the documentation.
+
+
+.. code:: python
+
+  #!/usr/bin/python3.5
+
+  import asyncio
+  import logging
+
+  from juju import loop
+  from juju.model import Model
+
+
+  async def deploy():
+      # Create a Model instance. We need to connect our Model to a Juju api
+      # server before we can use it.
+      model = Model()
+
+      # Connect to the currently active Juju model
+      await model.connect_current()
+
+      # Deploy a single unit of the ubuntu charm, using revision 0 from the
+      # stable channel of the Charm Store.
+      ubuntu_app = await model.deploy(
+          'ubuntu-0',
+          application_name='ubuntu',
+          series='xenial',
+          channel='stable',
+      )
+
+      # Disconnect from the api server and cleanup.
+      model.disconnect()
+
+
+  def main():
+      # Set logging level to debug so we can see verbose output from the
+      # juju library.
+      logging.basicConfig(level=logging.DEBUG)
+
+      # Quiet logging from the websocket library. If you want to see
+      # everything sent over the wire, set this to DEBUG.
+      ws_logger = logging.getLogger('websockets.protocol')
+      ws_logger.setLevel(logging.INFO)
+
+      # Run the deploy coroutine in an asyncio event loop, using a helper
+      # that abstracts loop creation and teardown.
+      loop.run(deploy())
+
+
+  if __name__ == '__main__':
+      main()
diff --git a/docs/requirements.txt b/docs/requirements.txt
new file mode 100644
index 0000000..06377bf
--- /dev/null
+++ b/docs/requirements.txt
@@ -0,0 +1,7 @@
+websockets
+pyyaml
+theblues
+python-dateutil
+sphinx
+sphinxcontrib-asyncio
+sphinx_rtd_theme
diff --git a/docs/upstream-updates/index.rst b/docs/upstream-updates/index.rst
new file mode 100644
index 0000000..52099e6
--- /dev/null
+++ b/docs/upstream-updates/index.rst
@@ -0,0 +1,66 @@
+Upstream Updates
+================
+
+Updating the facade and definitions code generated from the schema
+to reflect changes in upstream Juju consists of two steps:
+
+* Creating a new `schemas-juju-<version>.json` file from the Juju code-base
+* Generating the libjuju Python code from that schema
+
+Rarely, you may also have to add or update an override.
+
+
+Creating a Schema File
+----------------------
+
+First, you will need to fetch SchemaGen_ and a copy of the Juju source.
+Once your copy of the Juju source is at the version you want to update to
+(probably the `develop` branch, or a release tag) and you have updated
+and reinstalled SchemaGen to reflect those changes, you just need to send
+the output into a file in the libjuju repository:
+
+.. code:: bash
+
+  schemagen > juju/client/schemas-juju-2.2-rc1.json
+
+The version number you use in the filename should match the upstream
+version of Juju.  You should then also move the `latest` pointer to
+the new file:
+
+.. code:: bash
+
+  rm juju/client/schemas-juju-latest.json
+  ln -s schemas-juju-2.2-rc1.json juju/client/schemas-juju-latest.json
+
+
+Generating the Python Code
+--------------------------
+
+Once you have a new schema file, you can update the Python code
+using the `client` make target:
+
+.. code:: bash
+
+  make client
+
+You should expect to see updates to the `juju/client/_definitions.py` file,
+as well as one or more of the `juju/client/_clientX.py` files, depending on
+which facades were touched.
+
+
+Overrides
+---------
+
+It should be quite rare, but occasionally the generated Python code does
+not capture all of the logic needed to properly parse the output from the API
+or may otherwise need some small amount of tweaking.  This is what the
+`juju/client/overrides.py` file is for.  An example of this is the `Number`
+type, which isn't standard JSON and must be parsed slightly differently.
+
+At the top of that file are two lists, `__all__` and `__patches__`.  The
+former replaces entire class implementations, while the latter patches
+the attributes of the override classes into the matching generated class,
+leaving the rest of the generated class untouched.
+
+
+.. _SchemaGen: https://github.com/juju/schemagen