Squashed 'modules/libjuju/' content from commit c50c361
authorAdam Israel <adam.israel@canonical.com>
Tue, 15 Aug 2017 19:26:43 +0000 (15:26 -0400)
committerAdam Israel <adam.israel@canonical.com>
Tue, 15 Aug 2017 19:26:43 +0000 (15:26 -0400)
git-subtree-dir: modules/libjuju
git-subtree-split: c50c361a8b9a3bbf1a33f5659e492b481f065cd2

130 files changed:
.gitignore [new file with mode: 0644]
.travis.yml [new file with mode: 0644]
CONTRIBUTORS [new file with mode: 0644]
LICENSE [new file with mode: 0644]
MANIFEST.in [new file with mode: 0644]
Makefile [new file with mode: 0644]
README.rst [new symlink]
TODO [new file with mode: 0644]
VERSION [new file with mode: 0644]
docs/Makefile [new file with mode: 0644]
docs/_extensions/automembersummary.py [new file with mode: 0644]
docs/_static/custom.css [new file with mode: 0644]
docs/api/juju.action.rst [new file with mode: 0644]
docs/api/juju.annotation.rst [new file with mode: 0644]
docs/api/juju.application.rst [new file with mode: 0644]
docs/api/juju.client.rst [new file with mode: 0644]
docs/api/juju.cloud.rst [new file with mode: 0644]
docs/api/juju.constraints.rst [new file with mode: 0644]
docs/api/juju.controller.rst [new file with mode: 0644]
docs/api/juju.delta.rst [new file with mode: 0644]
docs/api/juju.errors.rst [new file with mode: 0644]
docs/api/juju.exceptions.rst [new file with mode: 0644]
docs/api/juju.juju.rst [new file with mode: 0644]
docs/api/juju.loop.rst [new file with mode: 0644]
docs/api/juju.machine.rst [new file with mode: 0644]
docs/api/juju.model.rst [new file with mode: 0644]
docs/api/juju.placement.rst [new file with mode: 0644]
docs/api/juju.relation.rst [new file with mode: 0644]
docs/api/juju.tag.rst [new file with mode: 0644]
docs/api/juju.unit.rst [new file with mode: 0644]
docs/api/juju.utils.rst [new file with mode: 0644]
docs/api/modules.rst [new file with mode: 0644]
docs/changelog.rst [new file with mode: 0644]
docs/conf.py [new file with mode: 0644]
docs/index.rst [new file with mode: 0644]
docs/narrative/application.rst [new file with mode: 0644]
docs/narrative/controller.rst [new file with mode: 0644]
docs/narrative/index.rst [new file with mode: 0644]
docs/narrative/model.rst [new file with mode: 0644]
docs/narrative/unit.rst [new file with mode: 0644]
docs/readme.rst [new file with mode: 0644]
docs/requirements.txt [new file with mode: 0644]
docs/upstream-updates/index.rst [new file with mode: 0644]
examples/action.py [new file with mode: 0644]
examples/add_machine.py [new file with mode: 0755]
examples/add_model.py [new file with mode: 0644]
examples/allwatcher.py [new file with mode: 0644]
examples/config.py [new file with mode: 0644]
examples/controller.py [new file with mode: 0644]
examples/deploy.py [new file with mode: 0644]
examples/fullstatus.py [new file with mode: 0644]
examples/future.py [new file with mode: 0644]
examples/leadership.py [new file with mode: 0644]
examples/livemodel.py [new file with mode: 0644]
examples/localcharm.py [new file with mode: 0644]
examples/relate.py [new file with mode: 0644]
examples/unitrun.py [new file with mode: 0644]
juju/__init__.py [new file with mode: 0644]
juju/action.py [new file with mode: 0644]
juju/annotation.py [new file with mode: 0644]
juju/application.py [new file with mode: 0644]
juju/client/__init__.py [new file with mode: 0644]
juju/client/_client.py [new file with mode: 0644]
juju/client/_client1.py [new file with mode: 0644]
juju/client/_client2.py [new file with mode: 0644]
juju/client/_client3.py [new file with mode: 0644]
juju/client/_client4.py [new file with mode: 0644]
juju/client/_client5.py [new file with mode: 0644]
juju/client/_definitions.py [new file with mode: 0644]
juju/client/client.py [new file with mode: 0644]
juju/client/codegen.py [new file with mode: 0644]
juju/client/connection.py [new file with mode: 0644]
juju/client/facade.py [new file with mode: 0644]
juju/client/overrides.py [new file with mode: 0644]
juju/client/runner.py [new file with mode: 0644]
juju/client/schemas-juju-2.0.0.json [new file with mode: 0644]
juju/client/schemas-juju-2.0.1.json [new file with mode: 0644]
juju/client/schemas-juju-2.0.2.json [new file with mode: 0644]
juju/client/schemas-juju-2.0.3.json [new file with mode: 0644]
juju/client/schemas-juju-2.1.0.json [new file with mode: 0644]
juju/client/schemas-juju-2.1.1.json [new file with mode: 0644]
juju/client/schemas-juju-2.1.2.json [new file with mode: 0644]
juju/client/schemas-juju-2.2-alpha1.json [new file with mode: 0644]
juju/client/schemas-juju-2.2-beta1.json [new file with mode: 0644]
juju/client/schemas-juju-2.2-beta2.json [new file with mode: 0644]
juju/client/schemas-juju-2.2-rc1.json [new file with mode: 0644]
juju/client/schemas-juju-2.3-alpha1.json [new file with mode: 0644]
juju/client/schemas-juju-latest.json [new symlink]
juju/cloud.py [new file with mode: 0644]
juju/constraints.py [new file with mode: 0644]
juju/controller.py [new file with mode: 0644]
juju/credential.py [new file with mode: 0644]
juju/delta.py [new file with mode: 0644]
juju/errors.py [new file with mode: 0644]
juju/exceptions.py [new file with mode: 0644]
juju/juju.py [new file with mode: 0644]
juju/loop.py [new file with mode: 0644]
juju/machine.py [new file with mode: 0644]
juju/model.py [new file with mode: 0644]
juju/placement.py [new file with mode: 0644]
juju/relation.py [new file with mode: 0644]
juju/tag.py [new file with mode: 0644]
juju/unit.py [new file with mode: 0644]
juju/utils.py [new file with mode: 0644]
scripts/gendoc [new file with mode: 0755]
setup.py [new file with mode: 0644]
tests/__init__.py [new file with mode: 0644]
tests/base.py [new file with mode: 0644]
tests/bundle/bundle.yaml [new file with mode: 0644]
tests/charm/metadata.yaml [new file with mode: 0644]
tests/integration/__init__.py [new file with mode: 0644]
tests/integration/bundle/bundle.yaml [new file with mode: 0644]
tests/integration/charm/metadata.yaml [new file with mode: 0644]
tests/integration/test_application.py [new file with mode: 0644]
tests/integration/test_client.py [new file with mode: 0644]
tests/integration/test_connection.py [new file with mode: 0644]
tests/integration/test_controller.py [new file with mode: 0644]
tests/integration/test_errors.py [new file with mode: 0644]
tests/integration/test_machine.py [new file with mode: 0644]
tests/integration/test_model.py [new file with mode: 0644]
tests/integration/test_unit.py [new file with mode: 0644]
tests/unit/__init__.py [new file with mode: 0644]
tests/unit/test_client.py [new file with mode: 0644]
tests/unit/test_connection.py [new file with mode: 0644]
tests/unit/test_constraints.py [new file with mode: 0644]
tests/unit/test_loop.py [new file with mode: 0644]
tests/unit/test_model.py [new file with mode: 0644]
tests/unit/test_overrides.py [new file with mode: 0644]
tests/unit/test_placement.py [new file with mode: 0644]
tox.ini [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..866a785
--- /dev/null
@@ -0,0 +1,12 @@
+*.sw[mnop]
+.venv/
+*.pyc
+*.py~
+docs/_build/
+__pycache__/
+.tox/
+*.egg-info/
+.cache/
+.\#*
+dist/
+dev/
diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..0a57c38
--- /dev/null
@@ -0,0 +1,23 @@
+dist: trusty
+sudo: required
+language: python
+python:
+  - "3.5"
+before_install:
+  - sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable -y
+  - sudo apt-get update -q
+  - sudo apt-get install lxd snapd -y
+  - sudo usermod -a -G lxd $USER
+  - sudo service lxd start || true
+  - sudo lxd init --auto
+install: pip install tox-travis
+env:
+  - SNAP_CMD="sudo snap install juju --classic --stable"
+  - SNAP_CMD="sudo snap install juju --classic --edge"
+script:
+  - (eval "$SNAP_CMD")
+  - sudo ln -s /snap/bin/juju /usr/bin/juju || true
+  - sudo -E sudo -u $USER -E bash -c "/snap/bin/juju bootstrap localhost test"
+  - tox -e py35,integration
+  - sudo -E sudo -u $USER -E bash -c "/snap/bin/juju destroy-controller --destroy-all-models -y test"
+  - sudo snap remove juju
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
new file mode 100644 (file)
index 0000000..3895eaa
--- /dev/null
@@ -0,0 +1,4 @@
+Benjamin Saller
+Tim Van Steenburgh
+Cory Johns
+Pete VanderGiessen
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..8dada3e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644 (file)
index 0000000..c14d3fc
--- /dev/null
@@ -0,0 +1,5 @@
+include *.py CONTRIBUTORS LICENSE README.rst VERSION
+recursive-include juju *.py
+recursive-include examples *.py
+recursive-include docs *.rst
+exclude Makefile
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..2e59306
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,40 @@
+BIN := .tox/py35/bin
+PY := $(BIN)/python3.5
+PIP := $(BIN)/pip
+SCHEMAGEN := $(shell which schemagen)
+VERSION=$(shell cat VERSION)
+
+clean:
+       find . -name __pycache__ -type d -exec rm -r {} +
+       find . -name *.pyc -delete
+       rm -rf .tox
+       rm -rf docs/_build/
+
+.tox:
+       tox -r --notest
+
+client:
+ifndef SCHEMAGEN
+       $(error "schemagen is not available, please install from https://github.com/juju/schemagen")
+endif
+       $(PY) -m juju.client.facade -s "juju/client/schemas*" -o juju/client/
+
+test:
+       tox
+
+docs: .tox
+       $(PIP) install -r docs/requirements.txt
+       rm -rf docs/_build/
+       $(BIN)/sphinx-build -b html docs/  docs/_build/
+       cd docs/_build/ && zip -r docs.zip *
+
+release:
+       git remote | xargs -L1 git fetch --tags
+       $(PY) setup.py sdist upload
+       git tag ${VERSION}
+       git remote | xargs -L1 git push --tags
+
+upload: release
+
+
+.PHONY: clean client test docs upload release
diff --git a/README.rst b/README.rst
new file mode 120000 (symlink)
index 0000000..c750ce5
--- /dev/null
@@ -0,0 +1 @@
+docs/readme.rst
\ No newline at end of file
diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..94fc342
--- /dev/null
+++ b/TODO
@@ -0,0 +1,5 @@
+TODO
+====
+
+- Add a LogWatcher coroutine that yields from debug-log api
+- Add a way to exit the event loop when a Model matches a bundle yaml
diff --git a/VERSION b/VERSION
new file mode 100644 (file)
index 0000000..a918a2a
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.6.0
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644 (file)
index 0000000..2869eb4
--- /dev/null
@@ -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 (file)
index 0000000..898da62
--- /dev/null
@@ -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 (file)
index 0000000..333cd74
--- /dev/null
@@ -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 (file)
index 0000000..cc86af2
--- /dev/null
@@ -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 (file)
index 0000000..ec31344
--- /dev/null
@@ -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 (file)
index 0000000..dba9177
--- /dev/null
@@ -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 (file)
index 0000000..6a699c0
--- /dev/null
@@ -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 (file)
index 0000000..39021e0
--- /dev/null
@@ -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 (file)
index 0000000..5fcbd31
--- /dev/null
@@ -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 (file)
index 0000000..4484fd5
--- /dev/null
@@ -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 (file)
index 0000000..9924f8c
--- /dev/null
@@ -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 (file)
index 0000000..7c77574
--- /dev/null
@@ -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 (file)
index 0000000..85be2fb
--- /dev/null
@@ -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 (file)
index 0000000..68698c3
--- /dev/null
@@ -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 (file)
index 0000000..4f175e9
--- /dev/null
@@ -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 (file)
index 0000000..edb5b6c
--- /dev/null
@@ -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 (file)
index 0000000..dfb735d
--- /dev/null
@@ -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 (file)
index 0000000..67cde0c
--- /dev/null
@@ -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 (file)
index 0000000..90e3130
--- /dev/null
@@ -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 (file)
index 0000000..9b3a29f
--- /dev/null
@@ -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 (file)
index 0000000..4a7d167
--- /dev/null
@@ -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 (file)
index 0000000..9220a1b
--- /dev/null
@@ -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 (file)
index 0000000..bf06f26
--- /dev/null
@@ -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 (file)
index 0000000..9da0cdc
--- /dev/null
@@ -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 (file)
index 0000000..a95ec04
--- /dev/null
@@ -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 (file)
index 0000000..b4b075f
--- /dev/null
@@ -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 (file)
index 0000000..1565e5f
--- /dev/null
@@ -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 (file)
index 0000000..2da0e7b
--- /dev/null
@@ -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 (file)
index 0000000..eb77e4c
--- /dev/null
@@ -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 (file)
index 0000000..57dbc81
--- /dev/null
@@ -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 (file)
index 0000000..5d6b48d
--- /dev/null
@@ -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 (file)
index 0000000..ecfbc5a
--- /dev/null
@@ -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 (file)
index 0000000..06377bf
--- /dev/null
@@ -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 (file)
index 0000000..52099e6
--- /dev/null
@@ -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
diff --git a/examples/action.py b/examples/action.py
new file mode 100644 (file)
index 0000000..0f25647
--- /dev/null
@@ -0,0 +1,50 @@
+"""
+This example:
+
+1. Connects to current model and resets it.
+2. Deploys a git unit.
+3. Runs an action against the unit.
+4. Waits for the action results to come back, then exits.
+
+"""
+import asyncio
+import logging
+
+from juju import loop
+from juju.model import Model
+
+
+async def run_action(unit):
+    logging.debug('Running action on unit %s', unit.name)
+
+    # unit.run() returns a juju.action.Action instance
+    action = await unit.run_action('add-repo', repo='myrepo')
+    # wait for the action to complete
+    action = await action.wait()
+
+    logging.debug("Action results: %s", action.results)
+
+
+async def main():
+    model = Model()
+    await model.connect_current()
+    await model.reset(force=True)
+
+    app = await model.deploy(
+        'git',
+        application_name='git',
+        series='trusty',
+        channel='stable',
+    )
+
+    for unit in app.units:
+        await run_action(unit)
+
+    await model.disconnect()
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    ws_logger = logging.getLogger('websockets.protocol')
+    ws_logger.setLevel(logging.INFO)
+    loop.run(main())
diff --git a/examples/add_machine.py b/examples/add_machine.py
new file mode 100755 (executable)
index 0000000..8ae2d40
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/env python3.5
+
+"""
+This example:
+
+1. Connects to the current model
+2. Creates two machines and a lxd container
+3. Deploys charm to the lxd container
+
+"""
+import logging
+
+from juju import loop
+from juju.model import Model
+
+MB = 1
+GB = 1024
+
+
+async def main():
+    model = Model()
+    await model.connect_current()
+
+    try:
+        # add a new default machine
+        machine1 = await model.add_machine()
+        # add a machine with constraints, disks, and series
+        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
+        )
+
+        await model.block_until(
+            lambda: all(unit.workload_status == 'active'
+                        for unit in application.units))
+
+        await application.remove()
+
+        await machine3.destroy(force=True)
+        await machine2.destroy(force=True)
+        await machine1.destroy(force=True)
+    finally:
+        await model.disconnect()
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    ws_logger = logging.getLogger('websockets.protocol')
+    ws_logger.setLevel(logging.INFO)
+
+    loop.run(main())
diff --git a/examples/add_model.py b/examples/add_model.py
new file mode 100644 (file)
index 0000000..3e46490
--- /dev/null
@@ -0,0 +1,66 @@
+"""
+This example:
+
+1. Creates a model on the current controller
+2. Deploys a charm to it.
+3. Attempts to ssh into the charm
+
+"""
+from juju import loop
+from juju import utils
+from juju.controller import Controller
+import asyncio
+from logging import getLogger
+import uuid
+
+LOG = getLogger(__name__)
+
+
+async def main():
+    controller = Controller()
+    print("Connecting to controller")
+    await controller.connect_current()
+
+    try:
+        model_name = "addmodeltest-{}".format(uuid.uuid4())
+        print("Adding model {}".format(model_name))
+        model = await controller.add_model(model_name)
+
+        print('Deploying ubuntu')
+        application = await model.deploy(
+            'ubuntu-10',
+            application_name='ubuntu',
+            series='trusty',
+            channel='stable',
+        )
+
+        print('Waiting for active')
+        await asyncio.sleep(10)
+        await model.block_until(
+            lambda: all(unit.workload_status == 'active'
+                        for unit in application.units))
+
+        print("Verifying that we can ssh into the created model")
+        ret = await utils.execute_process(
+            'juju', 'ssh', '-m', model_name, 'ubuntu/0', 'ls /', log=LOG)
+        assert ret
+
+        print('Removing ubuntu')
+        await application.remove()
+
+        print("Destroying model")
+        await controller.destroy_model(model.info.uuid)
+
+    except Exception:
+        LOG.exception(
+            "Test failed! Model {} may not be cleaned up".format(model_name))
+
+    finally:
+        print('Disconnecting from controller')
+        if model:
+            await model.disconnect()
+        await controller.disconnect()
+
+
+if __name__ == '__main__':
+    loop.run(main())
diff --git a/examples/allwatcher.py b/examples/allwatcher.py
new file mode 100644 (file)
index 0000000..c78d689
--- /dev/null
@@ -0,0 +1,31 @@
+"""
+This example:
+
+1. Connects to the current model
+2. Starts an AllWatcher
+3. Prints all changes received from the AllWatcher
+4. Runs forever (kill with Ctrl-C)
+
+"""
+import asyncio
+import logging
+
+from juju.client.connection import Connection
+from juju.client import client
+from juju import loop
+
+
+async def watch():
+    conn = await Connection.connect_current()
+    allwatcher = client.AllWatcherFacade.from_connection(conn)
+    while True:
+        change = await allwatcher.Next()
+        for delta in change.deltas:
+            print(delta.deltas)
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    # Run loop until the process is manually stopped (watch will loop
+    # forever).
+    loop.run(watch())
diff --git a/examples/config.py b/examples/config.py
new file mode 100644 (file)
index 0000000..bacc840
--- /dev/null
@@ -0,0 +1,55 @@
+"""
+This example:
+
+1. Connects to the current model
+2. Resets it
+3. Deploys a charm and prints its config and constraints
+
+"""
+import asyncio
+import logging
+
+from juju.model import Model
+from juju import loop
+
+log = logging.getLogger(__name__)
+
+MB = 1
+
+
+async def main():
+    model = Model()
+    await model.connect_current()
+    await model.reset(force=True)
+
+    ubuntu_app = await model.deploy(
+        'mysql',
+        application_name='mysql',
+        series='trusty',
+        channel='stable',
+        config={
+            'tuning-level': 'safest',
+        },
+        constraints={
+            'mem': 256 * MB,
+        },
+    )
+
+    # update and check app config
+    await ubuntu_app.set_config({'tuning-level': 'fast'})
+    config = await ubuntu_app.get_config()
+    assert(config['tuning-level']['value'] == 'fast')
+
+    # update and check app constraints
+    await ubuntu_app.set_constraints({'mem': 512 * MB})
+    constraints = await ubuntu_app.get_constraints()
+    assert(constraints['mem'] == 512 * MB)
+
+    await model.disconnect()
+
+    
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    ws_logger = logging.getLogger('websockets.protocol')
+    ws_logger.setLevel(logging.INFO)
+    loop.run(main())
diff --git a/examples/controller.py b/examples/controller.py
new file mode 100644 (file)
index 0000000..6002f68
--- /dev/null
@@ -0,0 +1,41 @@
+"""
+This example:
+
+1. Connects to current controller.
+2. Creates a new model.
+3. Deploys an application on the new model.
+4. Disconnects from the model
+5. Destroys the model
+
+"""
+import asyncio
+import logging
+
+from juju.controller import Controller
+from juju import loop
+
+
+async def main():
+    controller = Controller()
+    await controller.connect_current()
+    model = await controller.add_model(
+        'my-test-model',
+        'aws',
+        'aws-tim',
+    )
+    await model.deploy(
+        'ubuntu-0',
+        application_name='ubuntu',
+        series='trusty',
+        channel='stable',
+    )
+    await model.disconnect()
+    await controller.destroy_model(model.info.uuid)
+    await controller.disconnect()
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    ws_logger = logging.getLogger('websockets.protocol')
+    ws_logger.setLevel(logging.INFO)
+    loop.run(main())
diff --git a/examples/deploy.py b/examples/deploy.py
new file mode 100644 (file)
index 0000000..e6c306a
--- /dev/null
@@ -0,0 +1,40 @@
+"""
+This example:
+
+1. Connects to the current model
+2. Deploy a charm and waits until it reports itself active
+3. Destroys the unit and application
+
+"""
+from juju import loop
+from juju.model import Model
+
+
+async def main():
+    model = Model()
+    print('Connecting to model')
+    await model.connect_current()
+
+    try:
+        print('Deploying ubuntu')
+        application = await model.deploy(
+            'ubuntu-10',
+            application_name='ubuntu',
+            series='trusty',
+            channel='stable',
+        )
+
+        print('Waiting for active')
+        await model.block_until(
+            lambda: all(unit.workload_status == 'active'
+                        for unit in application.units))
+
+        print('Removing ubuntu')
+        await application.remove()
+    finally:
+        print('Disconnecting from model')
+        await model.disconnect()
+
+
+if __name__ == '__main__':
+    loop.run(main())
diff --git a/examples/fullstatus.py b/examples/fullstatus.py
new file mode 100644 (file)
index 0000000..cdaf51d
--- /dev/null
@@ -0,0 +1,23 @@
+import asyncio
+
+from juju.client.connection import Connection
+from juju.client.client import ClientFacade
+from juju import loop
+
+async def status():
+    conn = await Connection.connect_current()
+    client = ClientFacade.from_connection(conn)
+
+    patterns = None
+    status = await client.FullStatus(patterns)
+    await conn.close()
+
+    print('Applications:', list(status.applications.keys()))
+    print('Machines:', list(status.machines.keys()))
+    print('Relations:', status.relations)
+
+    return status
+
+if __name__ == '__main__':
+    loop.run(status())
+
diff --git a/examples/future.py b/examples/future.py
new file mode 100644 (file)
index 0000000..0180325
--- /dev/null
@@ -0,0 +1,48 @@
+"""
+This example doesn't work - it demonstrates features that don't exist yet.
+
+"""
+import asyncio
+import logging
+
+from juju.model import Model
+from juju import loop
+
+
+async def main():
+    model = Model()
+    await model.connect_current()
+    await model.reset(force=True)
+
+    goal_state = Model.from_yaml('bundle-like-thing')
+    ubuntu_app = await model.deploy(
+        'ubuntu-0',
+        application_name='ubuntu',
+        series='trusty',
+        channel='stable',
+    )
+    ubuntu_app.on_unit_added(callback=lambda unit: True)
+
+    await model.deploy(
+        'nrpe-11',
+        application_name='nrpe',
+        series='trusty',
+        channel='stable',
+        num_units=0,
+    )
+    await model.add_relation(
+        'ubuntu',
+        'nrpe',
+    )
+
+    result, ok = await model.block_until(
+        lambda: model.matches(goal_state),
+        timeout=600
+    )
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    ws_logger = logging.getLogger('websockets.protocol')
+    ws_logger.setLevel(logging.INFO)
+    loop.run(main())
diff --git a/examples/leadership.py b/examples/leadership.py
new file mode 100644 (file)
index 0000000..b231003
--- /dev/null
@@ -0,0 +1,28 @@
+"""
+This example:
+
+1. Connects to the current model.
+2. Prints out leadership status for all deployed units in the model.
+3. Cleanly disconnects.
+
+"""
+import asyncio
+
+from juju.model import Model
+from juju import loop
+
+async def report_leadership():
+    model = Model()
+    await model.connect_current()
+
+    print("Leadership: ")
+    for app in model.applications.values():
+        for unit in app.units:
+            print("{}: {}".format(
+                unit.name, await unit.is_leader_from_status()))
+
+    await model.disconnect()
+
+
+if __name__ == '__main__':
+    loop.run(report_leadership())
diff --git a/examples/livemodel.py b/examples/livemodel.py
new file mode 100644 (file)
index 0000000..47eb999
--- /dev/null
@@ -0,0 +1,32 @@
+"""
+This example:
+
+1. Connects to the current model
+2. Watches the model and prints all changes
+3. Runs forever (kill with Ctrl-C)
+
+"""
+import asyncio
+
+from juju.model import Model
+from juju import loop
+
+
+async def on_model_change(delta, old, new, model):
+    print(delta.entity, delta.type, delta.data)
+    print(old)
+    print(new)
+    print(model)
+
+
+async def watch_model():
+    model = Model()
+    await model.connect_current()
+
+    model.add_observer(on_model_change)
+
+
+if __name__ == '__main__':
+    # Run loop until the process is manually stopped (watch_model will loop
+    # forever).
+    loop.run(watch_model())
diff --git a/examples/localcharm.py b/examples/localcharm.py
new file mode 100644 (file)
index 0000000..978703e
--- /dev/null
@@ -0,0 +1,34 @@
+"""
+This example shows how to deploy a local charm. It:
+
+1. Connects to current model.
+2. Uploads a local charm (directory on filesystem) to the model.
+3. Deploys the uploaded charm.
+
+"""
+import asyncio
+import logging
+
+from juju.model import Model
+from juju import loop
+
+
+async def main():
+    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',
+    )
+
+    await model.disconnect()
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    ws_logger = logging.getLogger('websockets.protocol')
+    ws_logger.setLevel(logging.INFO)
+    loop.run(main())
diff --git a/examples/relate.py b/examples/relate.py
new file mode 100644 (file)
index 0000000..8f1e708
--- /dev/null
@@ -0,0 +1,98 @@
+"""
+This example:
+
+1. Connects to the current model
+2. Resets it
+3. Deploys two charms and relates them
+4. Waits for units to be idle, then exits
+
+"""
+import asyncio
+import logging
+
+from juju.model import Model, ModelObserver
+from juju import loop
+
+
+class MyRemoveObserver(ModelObserver):
+    async def on_change(self, delta, old, new, model):
+        if delta.type == 'remove':
+            assert(new.latest() == new)
+            assert(new.next() is None)
+            assert(new.dead)
+            assert(new.current)
+            assert(new.connected)
+            assert(new.previous().dead)
+            assert(not new.previous().current)
+            assert(not new.previous().connected)
+
+
+class MyModelObserver(ModelObserver):
+    _shutting_down = False
+
+    async def on_change(self, delta, old, new, model):
+        if model.units and model.all_units_idle() and not self._shutting_down:
+            self._shutting_down = True
+            logging.debug('All units idle, disconnecting')
+            await model.reset(force=True)
+            await model.disconnect()
+
+
+async def main():
+    model = Model()
+    await model.connect_current()
+
+    model.add_observer(MyRemoveObserver())
+    await model.reset(force=True)
+    model.add_observer(MyModelObserver())
+
+    ubuntu_app = await model.deploy(
+        'ubuntu',
+        application_name='ubuntu',
+        series='trusty',
+        channel='stable',
+    )
+    ubuntu_app.on_change(asyncio.coroutine(
+        lambda delta, old_app, new_app, model:
+            print('App changed: {}'.format(new_app.entity_id))
+    ))
+    ubuntu_app.on_remove(asyncio.coroutine(
+        lambda delta, old_app, new_app, model:
+            print('App removed: {}'.format(old_app.entity_id))
+    ))
+    ubuntu_app.on_unit_add(asyncio.coroutine(
+        lambda delta, old_unit, new_unit, model:
+            print('Unit added: {}'.format(new_unit.entity_id))
+    ))
+    ubuntu_app.on_unit_remove(asyncio.coroutine(
+        lambda delta, old_unit, new_unit, model:
+            print('Unit removed: {}'.format(old_unit.entity_id))
+    ))
+    unit_a, unit_b = await ubuntu_app.add_units(count=2)
+    unit_a.on_change(asyncio.coroutine(
+        lambda delta, old_unit, new_unit, model:
+            print('Unit changed: {}'.format(new_unit.entity_id))
+    ))
+    await model.deploy(
+        'nrpe',
+        application_name='nrpe',
+        series='trusty',
+        channel='stable',
+        # subordinates must be deployed without units
+        num_units=0,
+    )
+    my_relation = await model.add_relation(
+        'ubuntu',
+        'nrpe',
+    )
+    my_relation.on_remove(asyncio.coroutine(
+        lambda delta, old_rel, new_rel, model:
+            print('Relation removed: {}'.format(old_rel.endpoints))
+    ))
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    ws_logger = logging.getLogger('websockets.protocol')
+    ws_logger.setLevel(logging.INFO)
+    loop.run(main())
diff --git a/examples/unitrun.py b/examples/unitrun.py
new file mode 100644 (file)
index 0000000..3dfacd6
--- /dev/null
@@ -0,0 +1,47 @@
+"""
+This example:
+
+1. Connects to current model and resets it.
+2. Deploys one ubuntu unit.
+3. Runs an action against the unit.
+4. Waits for the action results to come back, then exits.
+
+"""
+import asyncio
+import logging
+
+from juju.model import Model
+from juju import loop
+
+
+async def run_command(unit):
+    logging.debug('Running command on unit %s', unit.name)
+
+    # unit.run() returns a juju.action.Action instance
+    action = await unit.run('unit-get public-address')
+    logging.debug("Action results: %s", action.results)
+
+
+async def main():
+    model = Model()
+    await model.connect_current()
+    await model.reset(force=True)
+
+    app = await model.deploy(
+        'ubuntu-0',
+        application_name='ubuntu',
+        series='trusty',
+        channel='stable',
+    )
+
+    for unit in app.units:
+        await run_command(unit)
+
+    await model.disconnect()
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.DEBUG)
+    ws_logger = logging.getLogger('websockets.protocol')
+    ws_logger.setLevel(logging.INFO)
+    loop.run(main())
diff --git a/juju/__init__.py b/juju/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/juju/action.py b/juju/action.py
new file mode 100644 (file)
index 0000000..7a136a7
--- /dev/null
@@ -0,0 +1,10 @@
+from . import model
+
+
+class Action(model.ModelEntity):
+    @property
+    def status(self):
+        return self.data['status']
+
+    async def wait(self):
+        return await self.model.wait_for_action(self.id)
diff --git a/juju/annotation.py b/juju/annotation.py
new file mode 100644 (file)
index 0000000..73c9b1c
--- /dev/null
@@ -0,0 +1,9 @@
+import logging
+
+from . import model
+
+log = logging.getLogger(__name__)
+
+
+class Annotation(model.ModelEntity):
+    pass
diff --git a/juju/application.py b/juju/application.py
new file mode 100644 (file)
index 0000000..8719a62
--- /dev/null
@@ -0,0 +1,391 @@
+import asyncio
+import logging
+
+from . import model
+from .client import client
+from .errors import JujuError
+from .placement import parse as parse_placement
+
+log = logging.getLogger(__name__)
+
+
+class Application(model.ModelEntity):
+    @property
+    def _unit_match_pattern(self):
+        return r'^{}.*$'.format(self.entity_id)
+
+    def on_unit_add(self, callable_):
+        """Add a "unit added" observer to this entity, which will be called
+        whenever a unit is added to this application.
+
+        """
+        self.model.add_observer(
+            callable_, 'unit', 'add', self._unit_match_pattern)
+
+    def on_unit_remove(self, callable_):
+        """Add a "unit removed" observer to this entity, which will be called
+        whenever a unit is removed from this application.
+
+        """
+        self.model.add_observer(
+            callable_, 'unit', 'remove', self._unit_match_pattern)
+
+    @property
+    def units(self):
+        return [
+            unit for unit in self.model.units.values()
+            if unit.application == self.name
+        ]
+
+    @property
+    def status(self):
+        """Get the application status, as set by the charm's leader.
+
+        """
+        return self.safe_data['status']['current']
+
+    @property
+    def status_message(self):
+        """Get the application status message, as set by the charm's leader.
+
+        """
+        return self.safe_data['status']['message']
+
+    @property
+    def tag(self):
+        return 'application-%s' % self.name
+
+    async def add_relation(self, local_relation, remote_relation):
+        """Add a relation to another application.
+
+        :param str local_relation: Name of relation on this application
+        :param str remote_relation: Name of relation on the other
+            application in the form '<application>[:<relation_name>]'
+
+        """
+        if ':' not in local_relation:
+            local_relation = '{}:{}'.format(self.name, local_relation)
+
+        return await self.model.add_relation(local_relation, remote_relation)
+
+    async def add_unit(self, count=1, to=None):
+        """Add one or more units to this application.
+
+        :param int count: Number of units to add
+        :param str to: Placement directive, e.g.::
+            '23' - machine 23
+            'lxc:7' - new lxc container on machine 7
+            '24/lxc/3' - lxc container 3 or machine 24
+
+            If None, a new machine is provisioned.
+
+        """
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Adding %s unit%s to %s',
+            count, '' if count == 1 else 's', self.name)
+
+        result = await app_facade.AddUnits(
+            application=self.name,
+            placement=parse_placement(to) if to else None,
+            num_units=count,
+        )
+
+        return await asyncio.gather(*[
+            asyncio.ensure_future(self.model._wait_for_new('unit', unit_id))
+            for unit_id in result.units
+        ])
+
+    add_units = add_unit
+
+    def allocate(self, budget, value):
+        """Allocate budget to this application.
+
+        :param str budget: Name of budget
+        :param int value: Budget limit
+
+        """
+        raise NotImplementedError()
+
+    def attach(self, resource_name, file_path):
+        """Upload a file as a resource for this application.
+
+        :param str resource: Name of the resource
+        :param str file_path: Path to the file to upload
+
+        """
+        raise NotImplementedError()
+
+    def collect_metrics(self):
+        """Collect metrics on this application.
+
+        """
+        raise NotImplementedError()
+
+    async def destroy_relation(self, local_relation, remote_relation):
+        """Remove a relation to another application.
+
+        :param str local_relation: Name of relation on this application
+        :param str remote_relation: Name of relation on the other
+            application in the form '<application>[:<relation_name>]'
+
+        """
+        if ':' not in local_relation:
+            local_relation = '{}:{}'.format(self.name, local_relation)
+
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Destroying relation %s <-> %s', local_relation, remote_relation)
+
+        return await app_facade.DestroyRelation([
+            local_relation, remote_relation])
+    remove_relation = destroy_relation
+
+    async def destroy_unit(self, *unit_names):
+        """Destroy units by name.
+
+        """
+        return await self.model.destroy_units(*unit_names)
+    destroy_units = destroy_unit
+
+    async def destroy(self):
+        """Remove this application from the model.
+
+        """
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Destroying %s', self.name)
+
+        return await app_facade.Destroy(self.name)
+    remove = destroy
+
+    async def expose(self):
+        """Make this application publicly available over the network.
+
+        """
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Exposing %s', self.name)
+
+        return await app_facade.Expose(self.name)
+
+    async def get_config(self):
+        """Return the configuration settings dict for this application.
+
+        """
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Getting config for %s', self.name)
+
+        return (await app_facade.Get(self.name)).config
+
+    async def get_constraints(self):
+        """Return the machine constraints dict for this application.
+
+        """
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Getting constraints for %s', self.name)
+
+        result = (await app_facade.Get(self.name)).constraints
+        return vars(result) if result else result
+
+    def get_actions(self, schema=False):
+        """Get actions defined for this application.
+
+        :param bool schema: Return the full action schema
+
+        """
+        raise NotImplementedError()
+
+    def get_resources(self, details=False):
+        """Return resources for this application.
+
+        :param bool details: Include detailed info about resources used by each
+            unit
+
+        """
+        raise NotImplementedError()
+
+    async def run(self, command, timeout=None):
+        """Run command on all units for this application.
+
+        :param str command: The command to run
+        :param int timeout: Time to wait before command is considered failed
+
+        """
+        action = client.ActionFacade.from_connection(self.connection)
+
+        log.debug(
+            'Running `%s` on all units of %s', command, self.name)
+
+        # TODO this should return a list of Actions
+        return await action.Run(
+            [self.name],
+            command,
+            [],
+            timeout,
+            [],
+        )
+
+    async def set_annotations(self, annotations):
+        """Set annotations on this application.
+
+        :param annotations map[string]string: the annotations as key/value
+            pairs.
+
+        """
+        log.debug('Updating annotations on application %s', self.name)
+
+        self.ann_facade = client.AnnotationsFacade.from_connection(
+            self.connection)
+
+        ann = client.EntityAnnotations(
+            entity=self.tag,
+            annotations=annotations,
+        )
+        return await self.ann_facade.Set([ann])
+
+    async def set_config(self, config, to_default=False):
+        """Set configuration options for this application.
+
+        :param config: Dict of configuration to set
+        :param bool to_default: Set application options to default values
+
+        """
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Setting config for %s: %s', self.name, config)
+
+        return await app_facade.Set(self.name, config)
+
+    async def set_constraints(self, constraints):
+        """Set machine constraints for this application.
+
+        :param dict constraints: Dict of machine constraints
+
+        """
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Setting constraints for %s: %s', self.name, constraints)
+
+        return await app_facade.SetConstraints(self.name, constraints)
+
+    def set_meter_status(self, status, info=None):
+        """Set the meter status on this status.
+
+        :param str status: Meter status, e.g. 'RED', 'AMBER'
+        :param str info: Extra info message
+
+        """
+        raise NotImplementedError()
+
+    def set_plan(self, plan_name):
+        """Set the plan for this application, effective immediately.
+
+        :param str plan_name: Name of plan
+
+        """
+        raise NotImplementedError()
+
+    async def unexpose(self):
+        """Remove public availability over the network for this application.
+
+        """
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        log.debug(
+            'Unexposing %s', self.name)
+
+        return await app_facade.Unexpose(self.name)
+
+    def update_allocation(self, allocation):
+        """Update existing allocation for this application.
+
+        :param int allocation: The allocation to set
+
+        """
+        raise NotImplementedError()
+
+    async def upgrade_charm(
+            self, channel=None, force_series=False, force_units=False,
+            path=None, resources=None, revision=None, switch=None):
+        """Upgrade the charm for this application.
+
+        :param str channel: Channel to use when getting the charm from the
+            charm store, e.g. 'development'
+        :param bool force_series: Upgrade even if series of deployed
+            application is not supported by the new charm
+        :param bool force_units: Upgrade all units immediately, even if in
+            error state
+        :param str path: Uprade to a charm located at path
+        :param dict resources: Dictionary of resource name/filepath pairs
+        :param int revision: Explicit upgrade revision
+        :param str switch: Crossgrade charm url
+
+        """
+        # TODO: Support local upgrades
+        if path is not None:
+            raise NotImplementedError("path option is not implemented")
+        if resources is not None:
+            raise NotImplementedError("resources option is not implemented")
+
+        if switch is not None and revision is not None:
+            raise ValueError("switch and revision are mutually exclusive")
+
+        client_facade = client.ClientFacade.from_connection(self.connection)
+        app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+        if switch is not None:
+            charm_url = switch
+            if not charm_url.startswith('cs:'):
+                charm_url = 'cs:' + charm_url
+        else:
+            charm_url = self.data['charm-url']
+            charm_url = charm_url.rpartition('-')[0]
+            if revision is not None:
+                charm_url = "%s-%d" % (charm_url, revision)
+            else:
+                charmstore = self.model.charmstore
+                entity = await charmstore.entity(charm_url, channel=channel)
+                charm_url = entity['Id']
+
+        if charm_url == self.data['charm-url']:
+            raise JujuError('already running charm "%s"' % charm_url)
+
+        await client_facade.AddCharm(
+            url=charm_url,
+            channel=channel
+        )
+
+        await app_facade.SetCharm(
+            application=self.entity_id,
+            channel=channel,
+            charm_url=charm_url,
+            config_settings=None,
+            config_settings_yaml=None,
+            force_series=force_series,
+            force_units=force_units,
+            resource_ids=None,
+            storage_constraints=None
+        )
+
+        await self.model.block_until(
+            lambda: self.data['charm-url'] == charm_url
+        )
+
+    async def get_metrics(self):
+        """Get metrics for this application's units.
+
+        :return: Dictionary of unit_name:metrics
+
+        """
+        return await self.model.get_metrics(self.tag)
diff --git a/juju/client/__init__.py b/juju/client/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/juju/client/_client.py b/juju/client/_client.py
new file mode 100644 (file)
index 0000000..d510e11
--- /dev/null
@@ -0,0 +1,367 @@
+# DO NOT CHANGE THIS FILE! This file is auto-generated by facade.py.
+# Changes will be overwritten/lost when the file is regenerated.
+
+from juju.client._definitions import *
+
+from juju.client import _client1, _client2, _client3, _client4, _client5
+
+
+CLIENTS = {
+    "1": _client1,
+    "2": _client2,
+    "3": _client3,
+    "4": _client4,
+    "5": _client5
+}
+
+
+
+def lookup_facade(name, version):
+        """
+        Given a facade name and version, attempt to pull that facade out
+        of the correct client<version>.py file.
+
+        """
+        try:
+            facade = getattr(CLIENTS[str(version)], name)
+        except KeyError:
+            raise ImportError("No facades found for version {}".format(version))
+        except AttributeError:
+            raise ImportError(
+                "No facade with name '{}' in version {}".format(name, version))
+        return facade
+
+
+
+class TypeFactory:
+    @classmethod
+    def from_connection(cls, connection):
+        """
+        Given a connected Connection object, return an initialized and
+        connected instance of an API Interface matching the name of
+        this class.
+
+        @param connection: initialized Connection object.
+
+        """
+        version = connection.facades[cls.__name__[:-6]]
+
+        c = lookup_facade(cls.__name__, version)
+        c = c()
+        c.connect(connection)
+
+        return c
+
+
+class ActionFacade(TypeFactory):
+    pass
+
+
+class AgentFacade(TypeFactory):
+    pass
+
+
+class AgentToolsFacade(TypeFactory):
+    pass
+
+
+class AllModelWatcherFacade(TypeFactory):
+    pass
+
+
+class AllWatcherFacade(TypeFactory):
+    pass
+
+
+class AnnotationsFacade(TypeFactory):
+    pass
+
+
+class ApplicationFacade(TypeFactory):
+    pass
+
+
+class ApplicationRelationsWatcherFacade(TypeFactory):
+    pass
+
+
+class ApplicationScalerFacade(TypeFactory):
+    pass
+
+
+class BackupsFacade(TypeFactory):
+    pass
+
+
+class BlockFacade(TypeFactory):
+    pass
+
+
+class BundleFacade(TypeFactory):
+    pass
+
+
+class CharmRevisionUpdaterFacade(TypeFactory):
+    pass
+
+
+class CharmsFacade(TypeFactory):
+    pass
+
+
+class CleanerFacade(TypeFactory):
+    pass
+
+
+class ClientFacade(TypeFactory):
+    pass
+
+
+class CloudFacade(TypeFactory):
+    pass
+
+
+class ControllerFacade(TypeFactory):
+    pass
+
+
+class DeployerFacade(TypeFactory):
+    pass
+
+
+class DiscoverSpacesFacade(TypeFactory):
+    pass
+
+
+class DiskManagerFacade(TypeFactory):
+    pass
+
+
+class EntityWatcherFacade(TypeFactory):
+    pass
+
+
+class FilesystemAttachmentsWatcherFacade(TypeFactory):
+    pass
+
+
+class FirewallerFacade(TypeFactory):
+    pass
+
+
+class HighAvailabilityFacade(TypeFactory):
+    pass
+
+
+class HostKeyReporterFacade(TypeFactory):
+    pass
+
+
+class ImageManagerFacade(TypeFactory):
+    pass
+
+
+class ImageMetadataFacade(TypeFactory):
+    pass
+
+
+class InstancePollerFacade(TypeFactory):
+    pass
+
+
+class KeyManagerFacade(TypeFactory):
+    pass
+
+
+class KeyUpdaterFacade(TypeFactory):
+    pass
+
+
+class LeadershipServiceFacade(TypeFactory):
+    pass
+
+
+class LifeFlagFacade(TypeFactory):
+    pass
+
+
+class LogForwardingFacade(TypeFactory):
+    pass
+
+
+class LoggerFacade(TypeFactory):
+    pass
+
+
+class MachineActionsFacade(TypeFactory):
+    pass
+
+
+class MachineManagerFacade(TypeFactory):
+    pass
+
+
+class MachineUndertakerFacade(TypeFactory):
+    pass
+
+
+class MachinerFacade(TypeFactory):
+    pass
+
+
+class MeterStatusFacade(TypeFactory):
+    pass
+
+
+class MetricsAdderFacade(TypeFactory):
+    pass
+
+
+class MetricsDebugFacade(TypeFactory):
+    pass
+
+
+class MetricsManagerFacade(TypeFactory):
+    pass
+
+
+class MigrationFlagFacade(TypeFactory):
+    pass
+
+
+class MigrationMasterFacade(TypeFactory):
+    pass
+
+
+class MigrationMinionFacade(TypeFactory):
+    pass
+
+
+class MigrationStatusWatcherFacade(TypeFactory):
+    pass
+
+
+class MigrationTargetFacade(TypeFactory):
+    pass
+
+
+class ModelConfigFacade(TypeFactory):
+    pass
+
+
+class ModelManagerFacade(TypeFactory):
+    pass
+
+
+class NotifyWatcherFacade(TypeFactory):
+    pass
+
+
+class PayloadsFacade(TypeFactory):
+    pass
+
+
+class PayloadsHookContextFacade(TypeFactory):
+    pass
+
+
+class PingerFacade(TypeFactory):
+    pass
+
+
+class ProvisionerFacade(TypeFactory):
+    pass
+
+
+class ProxyUpdaterFacade(TypeFactory):
+    pass
+
+
+class RebootFacade(TypeFactory):
+    pass
+
+
+class RelationUnitsWatcherFacade(TypeFactory):
+    pass
+
+
+class RemoteApplicationWatcherFacade(TypeFactory):
+    pass
+
+
+class RemoteRelationsWatcherFacade(TypeFactory):
+    pass
+
+
+class ResourcesFacade(TypeFactory):
+    pass
+
+
+class ResourcesHookContextFacade(TypeFactory):
+    pass
+
+
+class ResumerFacade(TypeFactory):
+    pass
+
+
+class RetryStrategyFacade(TypeFactory):
+    pass
+
+
+class SSHClientFacade(TypeFactory):
+    pass
+
+
+class SingularFacade(TypeFactory):
+    pass
+
+
+class SpacesFacade(TypeFactory):
+    pass
+
+
+class StatusHistoryFacade(TypeFactory):
+    pass
+
+
+class StorageFacade(TypeFactory):
+    pass
+
+
+class StorageProvisionerFacade(TypeFactory):
+    pass
+
+
+class StringsWatcherFacade(TypeFactory):
+    pass
+
+
+class SubnetsFacade(TypeFactory):
+    pass
+
+
+class UndertakerFacade(TypeFactory):
+    pass
+
+
+class UnitAssignerFacade(TypeFactory):
+    pass
+
+
+class UniterFacade(TypeFactory):
+    pass
+
+
+class UpgraderFacade(TypeFactory):
+    pass
+
+
+class UserManagerFacade(TypeFactory):
+    pass
+
+
+class VolumeAttachmentsWatcherFacade(TypeFactory):
+    pass
+
+
diff --git a/juju/client/_client1.py b/juju/client/_client1.py
new file mode 100644 (file)
index 0000000..3774056
--- /dev/null
@@ -0,0 +1,6645 @@
+# DO NOT CHANGE THIS FILE! This file is auto-generated by facade.py.
+# Changes will be overwritten/lost when the file is regenerated.
+
+from juju.client.facade import Type, ReturnMapping
+from juju.client._definitions import *
+
+
+class AgentToolsFacade(Type):
+    name = 'AgentTools'
+    version = 1
+    schema =     {'properties': {'UpdateToolsAvailable': {'type': 'object'}}, 'type': 'object'}
+    
+
+    @ReturnMapping(None)
+    async def UpdateToolsAvailable(self):
+        '''
+
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='AgentTools', request='UpdateToolsAvailable', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class AllWatcherFacade(Type):
+    name = 'AllWatcher'
+    version = 1
+    schema =     {'definitions': {'AllWatcherNextResults': {'additionalProperties': False,
+                                               'properties': {'deltas': {'items': {'$ref': '#/definitions/Delta'},
+                                                                         'type': 'array'}},
+                                               'required': ['deltas'],
+                                               'type': 'object'},
+                     'Delta': {'additionalProperties': False,
+                               'properties': {'entity': {'additionalProperties': True,
+                                                         'type': 'object'},
+                                              'removed': {'type': 'boolean'}},
+                               'required': ['removed', 'entity'],
+                               'type': 'object'}},
+     'properties': {'Next': {'properties': {'Result': {'$ref': '#/definitions/AllWatcherNextResults'}},
+                             'type': 'object'},
+                    'Stop': {'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(AllWatcherNextResults)
+    async def Next(self):
+        '''
+
+        Returns -> typing.Sequence<+T_co>[~Delta]<~Delta>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='AllWatcher', request='Next', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def Stop(self):
+        '''
+
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='AllWatcher', request='Stop', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class ApplicationRelationsWatcherFacade(Type):
+    name = 'ApplicationRelationsWatcher'
+    version = 1
+    schema =     {'definitions': {'ApplicationRelationsChange': {'additionalProperties': False,
+                                                    'properties': {'changed': {'items': {'$ref': '#/definitions/RelationChange'},
+                                                                               'type': 'array'},
+                                                                   'removed': {'items': {'type': 'integer'},
+                                                                               'type': 'array'}},
+                                                    'type': 'object'},
+                     'ApplicationRelationsWatchResult': {'additionalProperties': False,
+                                                         'properties': {'ApplicationRelationsWatcherId': {'type': 'string'},
+                                                                        'changes': {'$ref': '#/definitions/ApplicationRelationsChange'},
+                                                                        'error': {'$ref': '#/definitions/Error'}},
+                                                         'required': ['ApplicationRelationsWatcherId'],
+                                                         'type': 'object'},
+                     'Error': {'additionalProperties': False,
+                               'properties': {'code': {'type': 'string'},
+                                              'info': {'$ref': '#/definitions/ErrorInfo'},
+                                              'message': {'type': 'string'}},
+                               'required': ['message', 'code'],
+                               'type': 'object'},
+                     'ErrorInfo': {'additionalProperties': False,
+                                   'properties': {'macaroon': {'$ref': '#/definitions/Macaroon'},
+                                                  'macaroon-path': {'type': 'string'}},
+                                   'type': 'object'},
+                     'Macaroon': {'additionalProperties': False, 'type': 'object'},
+                     'RelationChange': {'additionalProperties': False,
+                                        'properties': {'changedunits': {'patternProperties': {'.*': {'$ref': '#/definitions/RelationUnitChange'}},
+                                                                        'type': 'object'},
+                                                       'departedunits': {'items': {'type': 'string'},
+                                                                         'type': 'array'},
+                                                       'id': {'type': 'integer'},
+                                                       'life': {'type': 'string'}},
+                                        'required': ['id', 'life'],
+                                        'type': 'object'},
+                     'RelationUnitChange': {'additionalProperties': False,
+                                            'properties': {'settings': {'patternProperties': {'.*': {'additionalProperties': True,
+                                                                                                     'type': 'object'}},
+                                                                        'type': 'object'}},
+                                            'type': 'object'}},
+     'properties': {'Next': {'properties': {'Result': {'$ref': '#/definitions/ApplicationRelationsWatchResult'}},
+                             'type': 'object'},
+                    'Stop': {'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(ApplicationRelationsWatchResult)
+    async def Next(self):
+        '''
+
+        Returns -> typing.Union[str, _ForwardRef('ApplicationRelationsChange'), _ForwardRef('Error')]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='ApplicationRelationsWatcher', request='Next', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def Stop(self):
+        '''
+
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='ApplicationRelationsWatcher', request='Stop', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class ApplicationScalerFacade(Type):
+    name = 'ApplicationScaler'
+    version = 1
+    schema =     {'definitions': {'Entities': {'additionalProperties': False,
+                                  'properties': {'entities': {'items': {'$ref': '#/definitions/Entity'},
+                                                              'type': 'array'}},
+                                  'required': ['entities'],
+                                  'type': 'object'},
+                     'Entity': {'additionalProperties': False,
+                                'properties': {'tag': {'type': 'string'}},
+                                'required': ['tag'],
+                                'type': 'object'},
+                     'Error': {'additionalProperties': False,
+                               'properties': {'code': {'type': 'string'},
+                                              'info': {'$ref': '#/definitions/ErrorInfo'},
+                                              'message': {'type': 'string'}},
+                               'required': ['message', 'code'],
+                               'type': 'object'},
+                     'ErrorInfo': {'additionalProperties': False,
+                                   'properties': {'macaroon': {'$ref': '#/definitions/Macaroon'},
+                                                  'macaroon-path': {'type': 'string'}},
+                                   'type': 'object'},
+                     'ErrorResult': {'additionalProperties': False,
+                                     'properties': {'error': {'$ref': '#/definitions/Error'}},
+                                     'type': 'object'},
+                     'ErrorResults': {'additionalProperties': False,
+                                      'properties': {'results': {'items': {'$ref': '#/definitions/ErrorResult'},
+                                                                 'type': 'array'}},
+                                      'required': ['results'],
+                                      'type': 'object'},
+                     'Macaroon': {'additionalProperties': False, 'type': 'object'},
+                     'StringsWatchResult': {'additionalProperties': False,
+                                            'properties': {'changes': {'items': {'type': 'string'},
+                                                                       'type': 'array'},
+                                                           'error': {'$ref': '#/definitions/Error'},
+                                                           'watcher-id': {'type': 'string'}},
+                                            'required': ['watcher-id'],
+                                            'type': 'object'}},
+     'properties': {'Rescale': {'properties': {'Params': {'$ref': '#/definitions/Entities'},
+                                               'Result': {'$ref': '#/definitions/ErrorResults'}},
+                                'type': 'object'},
+                    'Watch': {'properties': {'Result': {'$ref': '#/definitions/StringsWatchResult'}},
+                              'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(ErrorResults)
+    async def Rescale(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~Entity]<~Entity>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='ApplicationScaler', request='Rescale', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(StringsWatchResult)
+    async def Watch(self):
+        '''
+
+        Returns -> typing.Union[typing.Sequence<+T_co>[str], _ForwardRef('Error')]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='ApplicationScaler', request='Watch', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class BackupsFacade(Type):
+    name = 'Backups'
+    version = 1
+    schema =     {'definitions': {'BackupsCreateArgs': {'additionalProperties': False,
+                                           'properties': {'notes': {'type': 'string'}},
+                                           'required': ['notes'],
+                                           'type': 'object'},
+                     'BackupsInfoArgs': {'additionalProperties': False,
+                                         'properties': {'id': {'type': 'string'}},
+                                         'required': ['id'],
+                                         'type': 'object'},
+                     'BackupsListArgs': {'additionalProperties': False,
+                                         'type': 'object'},
+                     'BackupsListResult': {'additionalProperties': False,
+                                           'properties': {'list': {'items': {'$ref': '#/definitions/BackupsMetadataResult'},
+                                                                   'type': 'array'}},
+                                           'required': ['list'],
+                                           'type': 'object'},
+                     'BackupsMetadataResult': {'additionalProperties': False,
+                                               'properties': {'ca-cert': {'type': 'string'},
+                                                              'ca-private-key': {'type': 'string'},
+                                                              'checksum': {'type': 'string'},
+                                                              'checksum-format': {'type': 'string'},
+                                                              'finished': {'format': 'date-time',
+                                                                           'type': 'string'},
+                                                              'hostname': {'type': 'string'},
+                                                              'id': {'type': 'string'},
+                                                              'machine': {'type': 'string'},
+                                                              'model': {'type': 'string'},
+                                                              'notes': {'type': 'string'},
+                                                              'series': {'type': 'string'},
+                                                              'size': {'type': 'integer'},
+                                                              'started': {'format': 'date-time',
+                                                                          'type': 'string'},
+                                                              'stored': {'format': 'date-time',
+                                                                         'type': 'string'},
+                                                              'version': {'$ref': '#/definitions/Number'}},
+                                               'required': ['id',
+                                                            'checksum',
+                                                            'checksum-format',
+                                                            'size',
+                                                            'stored',
+                                                            'started',
+                                                            'finished',
+                                                            'notes',
+                                                            'model',
+                                                            'machine',
+                                                            'hostname',
+                                                            'version',
+                                                            'series',
+                                                            'ca-cert',
+                                                            'ca-private-key'],
+                                               'type': 'object'},
+                     'BackupsRemoveArgs': {'additionalProperties': False,
+                                           'properties': {'id': {'type': 'string'}},
+                                           'required': ['id'],
+                                           'type': 'object'},
+                     'Number': {'additionalProperties': False,
+                                'properties': {'Build': {'type': 'integer'},
+                                               'Major': {'type': 'integer'},
+                                               'Minor': {'type': 'integer'},
+                                               'Patch': {'type': 'integer'},
+                                               'Tag': {'type': 'string'}},
+                                'required': ['Major',
+                                             'Minor',
+                                             'Tag',
+                                             'Patch',
+                                             'Build'],
+                                'type': 'object'},
+                     'RestoreArgs': {'additionalProperties': False,
+                                     'properties': {'backup-id': {'type': 'string'}},
+                                     'required': ['backup-id'],
+                                     'type': 'object'}},
+     'properties': {'Create': {'properties': {'Params': {'$ref': '#/definitions/BackupsCreateArgs'},
+                                              'Result': {'$ref': '#/definitions/BackupsMetadataResult'}},
+                               'type': 'object'},
+                    'FinishRestore': {'type': 'object'},
+                    'Info': {'properties': {'Params': {'$ref': '#/definitions/BackupsInfoArgs'},
+                                            'Result': {'$ref': '#/definitions/BackupsMetadataResult'}},
+                             'type': 'object'},
+                    'List': {'properties': {'Params': {'$ref': '#/definitions/BackupsListArgs'},
+                                            'Result': {'$ref': '#/definitions/BackupsListResult'}},
+                             'type': 'object'},
+                    'PrepareRestore': {'type': 'object'},
+                    'Remove': {'properties': {'Params': {'$ref': '#/definitions/BackupsRemoveArgs'}},
+                               'type': 'object'},
+                    'Restore': {'properties': {'Params': {'$ref': '#/definitions/RestoreArgs'}},
+                                'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(BackupsMetadataResult)
+    async def Create(self, notes):
+        '''
+        notes : str
+        Returns -> typing.Union[str, int, _ForwardRef('Number')]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Backups', request='Create', version=1, params=_params)
+        _params['notes'] = notes
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def FinishRestore(self):
+        '''
+
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Backups', request='FinishRestore', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(BackupsMetadataResult)
+    async def Info(self, id_):
+        '''
+        id_ : str
+        Returns -> typing.Union[str, int, _ForwardRef('Number')]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Backups', request='Info', version=1, params=_params)
+        _params['id'] = id_
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(BackupsListResult)
+    async def List(self):
+        '''
+
+        Returns -> typing.Sequence<+T_co>[~BackupsMetadataResult]<~BackupsMetadataResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Backups', request='List', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def PrepareRestore(self):
+        '''
+
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Backups', request='PrepareRestore', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def Remove(self, id_):
+        '''
+        id_ : str
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Backups', request='Remove', version=1, params=_params)
+        _params['id'] = id_
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def Restore(self, backup_id):
+        '''
+        backup_id : str
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Backups', request='Restore', version=1, params=_params)
+        _params['backup-id'] = backup_id
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class BundleFacade(Type):
+    name = 'Bundle'
+    version = 1
+    schema =     {'definitions': {'BundleChange': {'additionalProperties': False,
+                                      'properties': {'args': {'items': {'additionalProperties': True,
+                                                                        'type': 'object'},
+                                                              'type': 'array'},
+                                                     'id': {'type': 'string'},
+                                                     'method': {'type': 'string'},
+                                                     'requires': {'items': {'type': 'string'},
+                                                                  'type': 'array'}},
+                                      'required': ['id',
+                                                   'method',
+                                                   'args',
+                                                   'requires'],
+                                      'type': 'object'},
+                     'BundleChangesParams': {'additionalProperties': False,
+                                             'properties': {'yaml': {'type': 'string'}},
+                                             'required': ['yaml'],
+                                             'type': 'object'},
+                     'BundleChangesResults': {'additionalProperties': False,
+                                              'properties': {'changes': {'items': {'$ref': '#/definitions/BundleChange'},
+                                                                         'type': 'array'},
+                                                             'errors': {'items': {'type': 'string'},
+                                                                        'type': 'array'}},
+                                              'type': 'object'}},
+     'properties': {'GetChanges': {'properties': {'Params': {'$ref': '#/definitions/BundleChangesParams'},
+                                                  'Result': {'$ref': '#/definitions/BundleChangesResults'}},
+                                   'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(BundleChangesResults)
+    async def GetChanges(self, yaml):
+        '''
+        yaml : str
+        Returns -> typing.Sequence<+T_co>[~BundleChange]<~BundleChange>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Bundle', request='GetChanges', version=1, params=_params)
+        _params['yaml'] = yaml
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class ClientFacade(Type):
+    name = 'Client'
+    version = 1
+    schema =     {'definitions': {'APIHostPortsResult': {'additionalProperties': False,
+                                            'properties': {'servers': {'items': {'items': {'$ref': '#/definitions/HostPort'},
+                                                                                 'type': 'array'},
+                                                                       'type': 'array'}},
+                                            'required': ['servers'],
+                                            'type': 'object'},
+                     'AddCharm': {'additionalProperties': False,
+                                  'properties': {'channel': {'type': 'string'},
+                                                 'url': {'type': 'string'}},
+                                  'required': ['url', 'channel'],
+                                  'type': 'object'},
+                     'AddCharmWithAuthorization': {'additionalProperties': False,
+                                                   'properties': {'channel': {'type': 'string'},
+                                                                  'macaroon': {'$ref': '#/definitions/Macaroon'},
+                                                                  'url': {'type': 'string'}},
+                                                   'required': ['url',
+                                                                'channel',
+                                                                'macaroon'],
+                                                   'type': 'object'},
+                     'AddMachineParams': {'additionalProperties': False,
+                                          'properties': {'addresses': {'items': {'$ref': '#/definitions/Address'},
+                                                                       'type': 'array'},
+                                                         'constraints': {'$ref': '#/definitions/Value'},
+                                                         'container-type': {'type': 'string'},
+                                                         'disks': {'items': {'$ref': '#/definitions/Constraints'},
+                                                                   'type': 'array'},
+                                                         'hardware-characteristics': {'$ref': '#/definitions/HardwareCharacteristics'},
+                                                         'instance-id': {'type': 'string'},
+                                                         'jobs': {'items': {'type': 'string'},
+                                                                  'type': 'array'},
+                                                         'nonce': {'type': 'string'},
+                                                         'parent-id': {'type': 'string'},
+                                                         'placement': {'$ref': '#/definitions/Placement'},
+                                                         'series': {'type': 'string'}},
+                                          'required': ['series',
+                                                       'constraints',
+                                                       'jobs',
+                                                       'parent-id',
+                                                       'container-type',
+                                                       'instance-id',
+                                                       'nonce',
+                                                       'hardware-characteristics',
+                                                       'addresses'],
+                                          'type': 'object'},
+                     'AddMachines': {'additionalProperties': False,
+                                     'properties': {'params': {'items': {'$ref': '#/definitions/AddMachineParams'},
+                                                               'type': 'array'}},
+                                     'required': ['params'],
+                                     'type': 'object'},
+                     'AddMachinesResult': {'additionalProperties': False,
+                                           'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                          'machine': {'type': 'string'}},
+                                           'required': ['machine'],
+                                           'type': 'object'},
+                     'AddMachinesResults': {'additionalProperties': False,
+                                            'properties': {'machines': {'items': {'$ref': '#/definitions/AddMachinesResult'},
+                                                                        'type': 'array'}},
+                                            'required': ['machines'],
+                                            'type': 'object'},
+                     'Address': {'additionalProperties': False,
+                                 'properties': {'scope': {'type': 'string'},
+                                                'space-name': {'type': 'string'},
+                                                'type': {'type': 'string'},
+                                                'value': {'type': 'string'}},
+                                 'required': ['value', 'type', 'scope'],
+                                 'type': 'object'},
+                     'AgentVersionResult': {'additionalProperties': False,
+                                            'properties': {'version': {'$ref': '#/definitions/Number'}},
+                                            'required': ['version'],
+                                            'type': 'object'},
+                     'AllWatcherId': {'additionalProperties': False,
+                                      'properties': {'watcher-id': {'type': 'string'}},
+                                      'required': ['watcher-id'],
+                                      'type': 'object'},
+                     'ApplicationStatus': {'additionalProperties': False,
+                                           'properties': {'can-upgrade-to': {'type': 'string'},
+                                                          'charm': {'type': 'string'},
+                                                          'err': {'additionalProperties': True,
+                                                                  'type': 'object'},
+                                                          'exposed': {'type': 'boolean'},
+                                                          'life': {'type': 'string'},
+                                                          'meter-statuses': {'patternProperties': {'.*': {'$ref': '#/definitions/MeterStatus'}},
+                                                                             'type': 'object'},
+                                                          'relations': {'patternProperties': {'.*': {'items': {'type': 'string'},
+                                                                                                     'type': 'array'}},
+                                                                        'type': 'object'},
+                                                          'series': {'type': 'string'},
+                                                          'status': {'$ref': '#/definitions/DetailedStatus'},
+                                                          'subordinate-to': {'items': {'type': 'string'},
+                                                                             'type': 'array'},
+                                                          'units': {'patternProperties': {'.*': {'$ref': '#/definitions/UnitStatus'}},
+                                                                    'type': 'object'},
+                                                          'workload-version': {'type': 'string'}},
+                                           'required': ['charm',
+                                                        'series',
+                                                        'exposed',
+                                                        'life',
+                                                        'relations',
+                                                        'can-upgrade-to',
+                                                        'subordinate-to',
+                                                        'units',
+                                                        'meter-statuses',
+                                                        'status',
+                                                        'workload-version'],
+                                           'type': 'object'},
+                     'Binary': {'additionalProperties': False,
+                                'properties': {'Arch': {'type': 'string'},
+                                               'Number': {'$ref': '#/definitions/Number'},
+                                               'Series': {'type': 'string'}},
+                                'required': ['Number', 'Series', 'Arch'],
+                                'type': 'object'},
+                     'BundleChange': {'additionalProperties': False,
+                                      'properties': {'args': {'items': {'additionalProperties': True,
+                                                                        'type': 'object'},
+                                                              'type': 'array'},
+                                                     'id': {'type': 'string'},
+                                                     'method': {'type': 'string'},
+                                                     'requires': {'items': {'type': 'string'},
+                                                                  'type': 'array'}},
+                                      'required': ['id',
+                                                   'method',
+                                                   'args',
+                                                   'requires'],
+                                      'type': 'object'},
+                     'BundleChangesParams': {'additionalProperties': False,
+                                             'properties': {'yaml': {'type': 'string'}},
+                                             'required': ['yaml'],
+                                             'type': 'object'},
+                     'BundleChangesResults': {'additionalProperties': False,
+                                              'properties': {'changes': {'items': {'$ref': '#/definitions/BundleChange'},
+                                                                         'type': 'array'},
+                                                             'errors': {'items': {'type': 'string'},
+                                                                        'type': 'array'}},
+                                              'type': 'object'},
+                     'BytesResult': {'additionalProperties': False,
+                                     'properties': {'result': {'items': {'type': 'integer'},
+                                                               'type': 'array'}},
+                                     'required': ['result'],
+                                     'type': 'object'},
+                     'ConfigValue': {'additionalProperties': False,
+                                     'properties': {'source': {'type': 'string'},
+                                                    'value': {'additionalProperties': True,
+                                                              'type': 'object'}},
+                                     'required': ['value', 'source'],
+                                     'type': 'object'},
+                     'Constraints': {'additionalProperties': False,
+                                     'properties': {'Count': {'type': 'integer'},
+                                                    'Pool': {'type': 'string'},
+                                                    'Size': {'type': 'integer'}},
+                                     'required': ['Pool', 'Size', 'Count'],
+                                     'type': 'object'},
+                     'DestroyMachines': {'additionalProperties': False,
+                                         'properties': {'force': {'type': 'boolean'},
+                                                        'machine-names': {'items': {'type': 'string'},
+                                                                          'type': 'array'}},
+                                         'required': ['machine-names', 'force'],
+                                         'type': 'object'},
+                     'DetailedStatus': {'additionalProperties': False,
+                                        'properties': {'data': {'patternProperties': {'.*': {'additionalProperties': True,
+                                                                                             'type': 'object'}},
+                                                                'type': 'object'},
+                                                       'err': {'additionalProperties': True,
+                                                               'type': 'object'},
+                                                       'info': {'type': 'string'},
+                                                       'kind': {'type': 'string'},
+                                                       'life': {'type': 'string'},
+                                                       'since': {'format': 'date-time',
+                                                                 'type': 'string'},
+                                                       'status': {'type': 'string'},
+                                                       'version': {'type': 'string'}},
+                                        'required': ['status',
+                                                     'info',
+                                                     'data',
+                                                     'since',
+                                                     'kind',
+                                                     'version',
+                                                     'life'],
+                                        'type': 'object'},
+                     'EndpointStatus': {'additionalProperties': False,
+                                        'properties': {'application': {'type': 'string'},
+                                                       'name': {'type': 'string'},
+                                                       'role': {'type': 'string'},
+                                                       'subordinate': {'type': 'boolean'}},
+                                        'required': ['application',
+                                                     'name',
+                                                     'role',
+                                                     'subordinate'],
+                                        'type': 'object'},
+                     'Entities': {'additionalProperties': False,
+                                  'properties': {'entities': {'items': {'$ref': '#/definitions/Entity'},
+                                                              'type': 'array'}},
+                                  'required': ['entities'],
+                                  'type': 'object'},
+                     'Entity': {'additionalProperties': False,
+                                'properties': {'tag': {'type': 'string'}},
+                                'required': ['tag'],
+                                'type': 'object'},
+                     'EntityStatus': {'additionalProperties': False,
+                                      'properties': {'data': {'patternProperties': {'.*': {'additionalProperties': True,
+                                                                                           'type': 'object'}},
+                                                              'type': 'object'},
+                                                     'info': {'type': 'string'},
+                                                     'since': {'format': 'date-time',
+                                                               'type': 'string'},
+                                                     'status': {'type': 'string'}},
+                                      'required': ['status', 'info', 'since'],
+                                      'type': 'object'},
+                     'Error': {'additionalProperties': False,
+                               'properties': {'code': {'type': 'string'},
+                                              'info': {'$ref': '#/definitions/ErrorInfo'},
+                                              'message': {'type': 'string'}},
+                               'required': ['message', 'code'],
+                               'type': 'object'},
+                     'ErrorInfo': {'additionalProperties': False,
+                                   'properties': {'macaroon': {'$ref': '#/definitions/Macaroon'},
+                                                  'macaroon-path': {'type': 'string'}},
+                                   'type': 'object'},
+                     'ErrorResult': {'additionalProperties': False,
+                                     'properties': {'error': {'$ref': '#/definitions/Error'}},
+                                     'type': 'object'},
+                     'ErrorResults': {'additionalProperties': False,
+                                      'properties': {'results': {'items': {'$ref': '#/definitions/ErrorResult'},
+                                                                 'type': 'array'}},
+                                      'required': ['results'],
+                                      'type': 'object'},
+                     'FindToolsParams': {'additionalProperties': False,
+                                         'properties': {'arch': {'type': 'string'},
+                                                        'major': {'type': 'integer'},
+                                                        'minor': {'type': 'integer'},
+                                                        'number': {'$ref': '#/definitions/Number'},
+                                                        'series': {'type': 'string'}},
+                                         'required': ['number',
+                                                      'major',
+                                                      'minor',
+                                                      'arch',
+                                                      'series'],
+                                         'type': 'object'},
+                     'FindToolsResult': {'additionalProperties': False,
+                                         'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                        'list': {'items': {'$ref': '#/definitions/Tools'},
+                                                                 'type': 'array'}},
+                                         'required': ['list'],
+                                         'type': 'object'},
+                     'FullStatus': {'additionalProperties': False,
+                                    'properties': {'applications': {'patternProperties': {'.*': {'$ref': '#/definitions/ApplicationStatus'}},
+                                                                    'type': 'object'},
+                                                   'machines': {'patternProperties': {'.*': {'$ref': '#/definitions/MachineStatus'}},
+                                                                'type': 'object'},
+                                                   'model': {'$ref': '#/definitions/ModelStatusInfo'},
+                                                   'relations': {'items': {'$ref': '#/definitions/RelationStatus'},
+                                                                 'type': 'array'},
+                                                   'remote-applications': {'patternProperties': {'.*': {'$ref': '#/definitions/RemoteApplicationStatus'}},
+                                                                           'type': 'object'}},
+                                    'required': ['model',
+                                                 'machines',
+                                                 'applications',
+                                                 'remote-applications',
+                                                 'relations'],
+                                    'type': 'object'},
+                     'GetConstraintsResults': {'additionalProperties': False,
+                                               'properties': {'constraints': {'$ref': '#/definitions/Value'}},
+                                               'required': ['constraints'],
+                                               'type': 'object'},
+                     'HardwareCharacteristics': {'additionalProperties': False,
+                                                 'properties': {'arch': {'type': 'string'},
+                                                                'availability-zone': {'type': 'string'},
+                                                                'cpu-cores': {'type': 'integer'},
+                                                                'cpu-power': {'type': 'integer'},
+                                                                'mem': {'type': 'integer'},
+                                                                'root-disk': {'type': 'integer'},
+                                                                'tags': {'items': {'type': 'string'},
+                                                                         'type': 'array'}},
+                                                 'type': 'object'},
+                     'History': {'additionalProperties': False,
+                                 'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                'statuses': {'items': {'$ref': '#/definitions/DetailedStatus'},
+                                                             'type': 'array'}},
+                                 'required': ['statuses'],
+                                 'type': 'object'},
+                     'HostPort': {'additionalProperties': False,
+                                  'properties': {'Address': {'$ref': '#/definitions/Address'},
+                                                 'port': {'type': 'integer'}},
+                                  'required': ['Address', 'port'],
+                                  'type': 'object'},
+                     'Macaroon': {'additionalProperties': False, 'type': 'object'},
+                     'MachineHardware': {'additionalProperties': False,
+                                         'properties': {'arch': {'type': 'string'},
+                                                        'availability-zone': {'type': 'string'},
+                                                        'cores': {'type': 'integer'},
+                                                        'cpu-power': {'type': 'integer'},
+                                                        'mem': {'type': 'integer'},
+                                                        'root-disk': {'type': 'integer'},
+                                                        'tags': {'items': {'type': 'string'},
+                                                                 'type': 'array'}},
+                                         'type': 'object'},
+                     'MachineStatus': {'additionalProperties': False,
+                                       'properties': {'agent-status': {'$ref': '#/definitions/DetailedStatus'},
+                                                      'constraints': {'type': 'string'},
+                                                      'containers': {'patternProperties': {'.*': {'$ref': '#/definitions/MachineStatus'}},
+                                                                     'type': 'object'},
+                                                      'dns-name': {'type': 'string'},
+                                                      'hardware': {'type': 'string'},
+                                                      'has-vote': {'type': 'boolean'},
+                                                      'id': {'type': 'string'},
+                                                      'instance-id': {'type': 'string'},
+                                                      'instance-status': {'$ref': '#/definitions/DetailedStatus'},
+                                                      'ip-addresses': {'items': {'type': 'string'},
+                                                                       'type': 'array'},
+                                                      'jobs': {'items': {'type': 'string'},
+                                                               'type': 'array'},
+                                                      'network-interfaces': {'patternProperties': {'.*': {'$ref': '#/definitions/NetworkInterface'}},
+                                                                             'type': 'object'},
+                                                      'series': {'type': 'string'},
+                                                      'wants-vote': {'type': 'boolean'}},
+                                       'required': ['agent-status',
+                                                    'instance-status',
+                                                    'dns-name',
+                                                    'instance-id',
+                                                    'series',
+                                                    'id',
+                                                    'containers',
+                                                    'constraints',
+                                                    'hardware',
+                                                    'jobs',
+                                                    'has-vote',
+                                                    'wants-vote'],
+                                       'type': 'object'},
+                     'MeterStatus': {'additionalProperties': False,
+                                     'properties': {'color': {'type': 'string'},
+                                                    'message': {'type': 'string'}},
+                                     'required': ['color', 'message'],
+                                     'type': 'object'},
+                     'ModelConfigResults': {'additionalProperties': False,
+                                            'properties': {'config': {'patternProperties': {'.*': {'$ref': '#/definitions/ConfigValue'}},
+                                                                      'type': 'object'}},
+                                            'required': ['config'],
+                                            'type': 'object'},
+                     'ModelInfo': {'additionalProperties': False,
+                                   'properties': {'agent-version': {'$ref': '#/definitions/Number'},
+                                                  'cloud-credential-tag': {'type': 'string'},
+                                                  'cloud-region': {'type': 'string'},
+                                                  'cloud-tag': {'type': 'string'},
+                                                  'controller-uuid': {'type': 'string'},
+                                                  'default-series': {'type': 'string'},
+                                                  'life': {'type': 'string'},
+                                                  'machines': {'items': {'$ref': '#/definitions/ModelMachineInfo'},
+                                                               'type': 'array'},
+                                                  'migration': {'$ref': '#/definitions/ModelMigrationStatus'},
+                                                  'name': {'type': 'string'},
+                                                  'owner-tag': {'type': 'string'},
+                                                  'provider-type': {'type': 'string'},
+                                                  'sla': {'$ref': '#/definitions/ModelSLAInfo'},
+                                                  'status': {'$ref': '#/definitions/EntityStatus'},
+                                                  'users': {'items': {'$ref': '#/definitions/ModelUserInfo'},
+                                                            'type': 'array'},
+                                                  'uuid': {'type': 'string'}},
+                                   'required': ['name',
+                                                'uuid',
+                                                'controller-uuid',
+                                                'cloud-tag',
+                                                'owner-tag',
+                                                'life',
+                                                'users',
+                                                'machines',
+                                                'sla',
+                                                'agent-version'],
+                                   'type': 'object'},
+                     'ModelMachineInfo': {'additionalProperties': False,
+                                          'properties': {'hardware': {'$ref': '#/definitions/MachineHardware'},
+                                                         'has-vote': {'type': 'boolean'},
+                                                         'id': {'type': 'string'},
+                                                         'instance-id': {'type': 'string'},
+                                                         'status': {'type': 'string'},
+                                                         'wants-vote': {'type': 'boolean'}},
+                                          'required': ['id'],
+                                          'type': 'object'},
+                     'ModelMigrationStatus': {'additionalProperties': False,
+                                              'properties': {'end': {'format': 'date-time',
+                                                                     'type': 'string'},
+                                                             'start': {'format': 'date-time',
+                                                                       'type': 'string'},
+                                                             'status': {'type': 'string'}},
+                                              'required': ['status', 'start'],
+                                              'type': 'object'},
+                     'ModelSLA': {'additionalProperties': False,
+                                  'properties': {'ModelSLAInfo': {'$ref': '#/definitions/ModelSLAInfo'},
+                                                 'creds': {'items': {'type': 'integer'},
+                                                           'type': 'array'}},
+                                  'required': ['ModelSLAInfo', 'creds'],
+                                  'type': 'object'},
+                     'ModelSLAInfo': {'additionalProperties': False,
+                                      'properties': {'level': {'type': 'string'},
+                                                     'owner': {'type': 'string'}},
+                                      'required': ['level', 'owner'],
+                                      'type': 'object'},
+                     'ModelSet': {'additionalProperties': False,
+                                  'properties': {'config': {'patternProperties': {'.*': {'additionalProperties': True,
+                                                                                         'type': 'object'}},
+                                                            'type': 'object'}},
+                                  'required': ['config'],
+                                  'type': 'object'},
+                     'ModelStatusInfo': {'additionalProperties': False,
+                                         'properties': {'available-version': {'type': 'string'},
+                                                        'cloud-tag': {'type': 'string'},
+                                                        'meter-status': {'$ref': '#/definitions/MeterStatus'},
+                                                        'model-status': {'$ref': '#/definitions/DetailedStatus'},
+                                                        'name': {'type': 'string'},
+                                                        'region': {'type': 'string'},
+                                                        'sla': {'type': 'string'},
+                                                        'version': {'type': 'string'}},
+                                         'required': ['name',
+                                                      'cloud-tag',
+                                                      'version',
+                                                      'available-version',
+                                                      'model-status',
+                                                      'meter-status',
+                                                      'sla'],
+                                         'type': 'object'},
+                     'ModelUnset': {'additionalProperties': False,
+                                    'properties': {'keys': {'items': {'type': 'string'},
+                                                            'type': 'array'}},
+                                    'required': ['keys'],
+                                    'type': 'object'},
+                     'ModelUserInfo': {'additionalProperties': False,
+                                       'properties': {'access': {'type': 'string'},
+                                                      'display-name': {'type': 'string'},
+                                                      'last-connection': {'format': 'date-time',
+                                                                          'type': 'string'},
+                                                      'user': {'type': 'string'}},
+                                       'required': ['user',
+                                                    'display-name',
+                                                    'last-connection',
+                                                    'access'],
+                                       'type': 'object'},
+                     'ModelUserInfoResult': {'additionalProperties': False,
+                                             'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                            'result': {'$ref': '#/definitions/ModelUserInfo'}},
+                                             'type': 'object'},
+                     'ModelUserInfoResults': {'additionalProperties': False,
+                                              'properties': {'results': {'items': {'$ref': '#/definitions/ModelUserInfoResult'},
+                                                                         'type': 'array'}},
+                                              'required': ['results'],
+                                              'type': 'object'},
+                     'NetworkInterface': {'additionalProperties': False,
+                                          'properties': {'dns-nameservers': {'items': {'type': 'string'},
+                                                                             'type': 'array'},
+                                                         'gateway': {'type': 'string'},
+                                                         'ip-addresses': {'items': {'type': 'string'},
+                                                                          'type': 'array'},
+                                                         'is-up': {'type': 'boolean'},
+                                                         'mac-address': {'type': 'string'},
+                                                         'space': {'type': 'string'}},
+                                          'required': ['ip-addresses',
+                                                       'mac-address',
+                                                       'is-up'],
+                                          'type': 'object'},
+                     'Number': {'additionalProperties': False,
+                                'properties': {'Build': {'type': 'integer'},
+                                               'Major': {'type': 'integer'},
+                                               'Minor': {'type': 'integer'},
+                                               'Patch': {'type': 'integer'},
+                                               'Tag': {'type': 'string'}},
+                                'required': ['Major',
+                                             'Minor',
+                                             'Tag',
+                                             'Patch',
+                                             'Build'],
+                                'type': 'object'},
+                     'Placement': {'additionalProperties': False,
+                                   'properties': {'directive': {'type': 'string'},
+                                                  'scope': {'type': 'string'}},
+                                   'required': ['scope', 'directive'],
+                                   'type': 'object'},
+                     'PrivateAddress': {'additionalProperties': False,
+                                        'properties': {'target': {'type': 'string'}},
+                                        'required': ['target'],
+                                        'type': 'object'},
+                     'PrivateAddressResults': {'additionalProperties': False,
+                                               'properties': {'private-address': {'type': 'string'}},
+                                               'required': ['private-address'],
+                                               'type': 'object'},
+                     'ProvisioningScriptParams': {'additionalProperties': False,
+                                                  'properties': {'data-dir': {'type': 'string'},
+                                                                 'disable-package-commands': {'type': 'boolean'},
+                                                                 'machine-id': {'type': 'string'},
+                                                                 'nonce': {'type': 'string'}},
+                                                  'required': ['machine-id',
+                                                               'nonce',
+                                                               'data-dir',
+                                                               'disable-package-commands'],
+                                                  'type': 'object'},
+                     'ProvisioningScriptResult': {'additionalProperties': False,
+                                                  'properties': {'script': {'type': 'string'}},
+                                                  'required': ['script'],
+                                                  'type': 'object'},
+                     'PublicAddress': {'additionalProperties': False,
+                                       'properties': {'target': {'type': 'string'}},
+                                       'required': ['target'],
+                                       'type': 'object'},
+                     'PublicAddressResults': {'additionalProperties': False,
+                                              'properties': {'public-address': {'type': 'string'}},
+                                              'required': ['public-address'],
+                                              'type': 'object'},
+                     'RelationStatus': {'additionalProperties': False,
+                                        'properties': {'endpoints': {'items': {'$ref': '#/definitions/EndpointStatus'},
+                                                                     'type': 'array'},
+                                                       'id': {'type': 'integer'},
+                                                       'interface': {'type': 'string'},
+                                                       'key': {'type': 'string'},
+                                                       'scope': {'type': 'string'}},
+                                        'required': ['id',
+                                                     'key',
+                                                     'interface',
+                                                     'scope',
+                                                     'endpoints'],
+                                        'type': 'object'},
+                     'RemoteApplicationStatus': {'additionalProperties': False,
+                                                 'properties': {'application-name': {'type': 'string'},
+                                                                'application-url': {'type': 'string'},
+                                                                'endpoints': {'items': {'$ref': '#/definitions/RemoteEndpoint'},
+                                                                              'type': 'array'},
+                                                                'err': {'additionalProperties': True,
+                                                                        'type': 'object'},
+                                                                'life': {'type': 'string'},
+                                                                'relations': {'patternProperties': {'.*': {'items': {'type': 'string'},
+                                                                                                           'type': 'array'}},
+                                                                              'type': 'object'},
+                                                                'status': {'$ref': '#/definitions/DetailedStatus'}},
+                                                 'required': ['application-url',
+                                                              'application-name',
+                                                              'endpoints',
+                                                              'life',
+                                                              'relations',
+                                                              'status'],
+                                                 'type': 'object'},
+                     'RemoteEndpoint': {'additionalProperties': False,
+                                        'properties': {'interface': {'type': 'string'},
+                                                       'limit': {'type': 'integer'},
+                                                       'name': {'type': 'string'},
+                                                       'role': {'type': 'string'},
+                                                       'scope': {'type': 'string'}},
+                                        'required': ['name',
+                                                     'role',
+                                                     'interface',
+                                                     'limit',
+                                                     'scope'],
+                                        'type': 'object'},
+                     'ResolveCharmResult': {'additionalProperties': False,
+                                            'properties': {'error': {'type': 'string'},
+                                                           'url': {'type': 'string'}},
+                                            'type': 'object'},
+                     'ResolveCharmResults': {'additionalProperties': False,
+                                             'properties': {'urls': {'items': {'$ref': '#/definitions/ResolveCharmResult'},
+                                                                     'type': 'array'}},
+                                             'required': ['urls'],
+                                             'type': 'object'},
+                     'ResolveCharms': {'additionalProperties': False,
+                                       'properties': {'references': {'items': {'type': 'string'},
+                                                                     'type': 'array'}},
+                                       'required': ['references'],
+                                       'type': 'object'},
+                     'Resolved': {'additionalProperties': False,
+                                  'properties': {'retry': {'type': 'boolean'},
+                                                 'unit-name': {'type': 'string'}},
+                                  'required': ['unit-name', 'retry'],
+                                  'type': 'object'},
+                     'SetConstraints': {'additionalProperties': False,
+                                        'properties': {'application': {'type': 'string'},
+                                                       'constraints': {'$ref': '#/definitions/Value'}},
+                                        'required': ['application', 'constraints'],
+                                        'type': 'object'},
+                     'SetModelAgentVersion': {'additionalProperties': False,
+                                              'properties': {'version': {'$ref': '#/definitions/Number'}},
+                                              'required': ['version'],
+                                              'type': 'object'},
+                     'StatusHistoryFilter': {'additionalProperties': False,
+                                             'properties': {'date': {'format': 'date-time',
+                                                                     'type': 'string'},
+                                                            'delta': {'type': 'integer'},
+                                                            'exclude': {'items': {'type': 'string'},
+                                                                        'type': 'array'},
+                                                            'size': {'type': 'integer'}},
+                                             'required': ['size',
+                                                          'date',
+                                                          'delta',
+                                                          'exclude'],
+                                             'type': 'object'},
+                     'StatusHistoryRequest': {'additionalProperties': False,
+                                              'properties': {'filter': {'$ref': '#/definitions/StatusHistoryFilter'},
+                                                             'historyKind': {'type': 'string'},
+                                                             'size': {'type': 'integer'},
+                                                             'tag': {'type': 'string'}},
+                                              'required': ['historyKind',
+                                                           'size',
+                                                           'filter',
+                                                           'tag'],
+                                              'type': 'object'},
+                     'StatusHistoryRequests': {'additionalProperties': False,
+                                               'properties': {'requests': {'items': {'$ref': '#/definitions/StatusHistoryRequest'},
+                                                                           'type': 'array'}},
+                                               'required': ['requests'],
+                                               'type': 'object'},
+                     'StatusHistoryResult': {'additionalProperties': False,
+                                             'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                            'history': {'$ref': '#/definitions/History'}},
+                                             'required': ['history'],
+                                             'type': 'object'},
+                     'StatusHistoryResults': {'additionalProperties': False,
+                                              'properties': {'results': {'items': {'$ref': '#/definitions/StatusHistoryResult'},
+                                                                         'type': 'array'}},
+                                              'required': ['results'],
+                                              'type': 'object'},
+                     'StatusParams': {'additionalProperties': False,
+                                      'properties': {'patterns': {'items': {'type': 'string'},
+                                                                  'type': 'array'}},
+                                      'required': ['patterns'],
+                                      'type': 'object'},
+                     'StringResult': {'additionalProperties': False,
+                                      'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                     'result': {'type': 'string'}},
+                                      'required': ['result'],
+                                      'type': 'object'},
+                     'Tools': {'additionalProperties': False,
+                               'properties': {'sha256': {'type': 'string'},
+                                              'size': {'type': 'integer'},
+                                              'url': {'type': 'string'},
+                                              'version': {'$ref': '#/definitions/Binary'}},
+                               'required': ['version', 'url', 'size'],
+                               'type': 'object'},
+                     'UnitStatus': {'additionalProperties': False,
+                                    'properties': {'agent-status': {'$ref': '#/definitions/DetailedStatus'},
+                                                   'charm': {'type': 'string'},
+                                                   'leader': {'type': 'boolean'},
+                                                   'machine': {'type': 'string'},
+                                                   'opened-ports': {'items': {'type': 'string'},
+                                                                    'type': 'array'},
+                                                   'public-address': {'type': 'string'},
+                                                   'subordinates': {'patternProperties': {'.*': {'$ref': '#/definitions/UnitStatus'}},
+                                                                    'type': 'object'},
+                                                   'workload-status': {'$ref': '#/definitions/DetailedStatus'},
+                                                   'workload-version': {'type': 'string'}},
+                                    'required': ['agent-status',
+                                                 'workload-status',
+                                                 'workload-version',
+                                                 'machine',
+                                                 'opened-ports',
+                                                 'public-address',
+                                                 'charm',
+                                                 'subordinates'],
+                                    'type': 'object'},
+                     'Value': {'additionalProperties': False,
+                               'properties': {'arch': {'type': 'string'},
+                                              'container': {'type': 'string'},
+                                              'cores': {'type': 'integer'},
+                                              'cpu-power': {'type': 'integer'},
+                                              'instance-type': {'type': 'string'},
+                                              'mem': {'type': 'integer'},
+                                              'root-disk': {'type': 'integer'},
+                                              'spaces': {'items': {'type': 'string'},
+                                                         'type': 'array'},
+                                              'tags': {'items': {'type': 'string'},
+                                                       'type': 'array'},
+                                              'virt-type': {'type': 'string'}},
+                               'type': 'object'}},
+     'properties': {'APIHostPorts': {'properties': {'Result': {'$ref': '#/definitions/APIHostPortsResult'}},
+                                     'type': 'object'},
+                    'AbortCurrentUpgrade': {'type': 'object'},
+                    'AddCharm': {'properties': {'Params': {'$ref': '#/definitions/AddCharm'}},
+                                 'type': 'object'},
+                    'AddCharmWithAuthorization': {'properties': {'Params': {'$ref': '#/definitions/AddCharmWithAuthorization'}},
+                                                  'type': 'object'},
+                    'AddMachines': {'properties': {'Params': {'$ref': '#/definitions/AddMachines'},
+                                                   'Result': {'$ref': '#/definitions/AddMachinesResults'}},
+                                    'type': 'object'},
+                    'AddMachinesV2': {'properties': {'Params': {'$ref': '#/definitions/AddMachines'},
+                                                     'Result': {'$ref': '#/definitions/AddMachinesResults'}},
+                                      'type': 'object'},
+                    'AgentVersion': {'properties': {'Result': {'$ref': '#/definitions/AgentVersionResult'}},
+                                     'type': 'object'},
+                    'CACert': {'properties': {'Result': {'$ref': '#/definitions/BytesResult'}},
+                               'type': 'object'},
+                    'DestroyMachines': {'properties': {'Params': {'$ref': '#/definitions/DestroyMachines'}},
+                                        'type': 'object'},
+                    'FindTools': {'properties': {'Params': {'$ref': '#/definitions/FindToolsParams'},
+                                                 'Result': {'$ref': '#/definitions/FindToolsResult'}},
+                                  'type': 'object'},
+                    'FullStatus': {'properties': {'Params': {'$ref': '#/definitions/StatusParams'},
+                                                  'Result': {'$ref': '#/definitions/FullStatus'}},
+                                   'type': 'object'},
+                    'GetBundleChanges': {'properties': {'Params': {'$ref': '#/definitions/BundleChangesParams'},
+                                                        'Result': {'$ref': '#/definitions/BundleChangesResults'}},
+                                         'type': 'object'},
+                    'GetModelConstraints': {'properties': {'Result': {'$ref': '#/definitions/GetConstraintsResults'}},
+                                            'type': 'object'},
+                    'InjectMachines': {'properties': {'Params': {'$ref': '#/definitions/AddMachines'},
+                                                      'Result': {'$ref': '#/definitions/AddMachinesResults'}},
+                                       'type': 'object'},
+                    'ModelGet': {'properties': {'Result': {'$ref': '#/definitions/ModelConfigResults'}},
+                                 'type': 'object'},
+                    'ModelInfo': {'properties': {'Result': {'$ref': '#/definitions/ModelInfo'}},
+                                  'type': 'object'},
+                    'ModelSet': {'properties': {'Params': {'$ref': '#/definitions/ModelSet'}},
+                                 'type': 'object'},
+                    'ModelUnset': {'properties': {'Params': {'$ref': '#/definitions/ModelUnset'}},
+                                   'type': 'object'},
+                    'ModelUserInfo': {'properties': {'Result': {'$ref': '#/definitions/ModelUserInfoResults'}},
+                                      'type': 'object'},
+                    'PrivateAddress': {'properties': {'Params': {'$ref': '#/definitions/PrivateAddress'},
+                                                      'Result': {'$ref': '#/definitions/PrivateAddressResults'}},
+                                       'type': 'object'},
+                    'ProvisioningScript': {'properties': {'Params': {'$ref': '#/definitions/ProvisioningScriptParams'},
+                                                          'Result': {'$ref': '#/definitions/ProvisioningScriptResult'}},
+                                           'type': 'object'},
+                    'PublicAddress': {'properties': {'Params': {'$ref': '#/definitions/PublicAddress'},
+                                                     'Result': {'$ref': '#/definitions/PublicAddressResults'}},
+                                      'type': 'object'},
+                    'ResolveCharms': {'properties': {'Params': {'$ref': '#/definitions/ResolveCharms'},
+                                                     'Result': {'$ref': '#/definitions/ResolveCharmResults'}},
+                                      'type': 'object'},
+                    'Resolved': {'properties': {'Params': {'$ref': '#/definitions/Resolved'}},
+                                 'type': 'object'},
+                    'RetryProvisioning': {'properties': {'Params': {'$ref': '#/definitions/Entities'},
+                                                         'Result': {'$ref': '#/definitions/ErrorResults'}},
+                                          'type': 'object'},
+                    'SLALevel': {'properties': {'Result': {'$ref': '#/definitions/StringResult'}},
+                                 'type': 'object'},
+                    'SetModelAgentVersion': {'properties': {'Params': {'$ref': '#/definitions/SetModelAgentVersion'}},
+                                             'type': 'object'},
+                    'SetModelConstraints': {'properties': {'Params': {'$ref': '#/definitions/SetConstraints'}},
+                                            'type': 'object'},
+                    'SetSLALevel': {'properties': {'Params': {'$ref': '#/definitions/ModelSLA'}},
+                                    'type': 'object'},
+                    'StatusHistory': {'properties': {'Params': {'$ref': '#/definitions/StatusHistoryRequests'},
+                                                     'Result': {'$ref': '#/definitions/StatusHistoryResults'}},
+                                      'type': 'object'},
+                    'WatchAll': {'properties': {'Result': {'$ref': '#/definitions/AllWatcherId'}},
+                                 'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(APIHostPortsResult)
+    async def APIHostPorts(self):
+        '''
+
+        Returns -> typing.Sequence<+T_co>[~HostPort]<~HostPort>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='APIHostPorts', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def AbortCurrentUpgrade(self):
+        '''
+
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='AbortCurrentUpgrade', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def AddCharm(self, channel, url):
+        '''
+        channel : str
+        url : str
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='AddCharm', version=1, params=_params)
+        _params['channel'] = channel
+        _params['url'] = url
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def AddCharmWithAuthorization(self, channel, macaroon, url):
+        '''
+        channel : str
+        macaroon : Macaroon
+        url : str
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='AddCharmWithAuthorization', version=1, params=_params)
+        _params['channel'] = channel
+        _params['macaroon'] = macaroon
+        _params['url'] = url
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(AddMachinesResults)
+    async def AddMachines(self, params):
+        '''
+        params : typing.Sequence<+T_co>[~AddMachineParams]<~AddMachineParams>
+        Returns -> typing.Sequence<+T_co>[~AddMachinesResult]<~AddMachinesResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='AddMachines', version=1, params=_params)
+        _params['params'] = params
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(AddMachinesResults)
+    async def AddMachinesV2(self, params):
+        '''
+        params : typing.Sequence<+T_co>[~AddMachineParams]<~AddMachineParams>
+        Returns -> typing.Sequence<+T_co>[~AddMachinesResult]<~AddMachinesResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='AddMachinesV2', version=1, params=_params)
+        _params['params'] = params
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(AgentVersionResult)
+    async def AgentVersion(self):
+        '''
+
+        Returns -> Number
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='AgentVersion', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(BytesResult)
+    async def CACert(self):
+        '''
+
+        Returns -> typing.Sequence<+T_co>[int]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='CACert', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def DestroyMachines(self, force, machine_names):
+        '''
+        force : bool
+        machine_names : typing.Sequence<+T_co>[str]
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='DestroyMachines', version=1, params=_params)
+        _params['force'] = force
+        _params['machine-names'] = machine_names
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(FindToolsResult)
+    async def FindTools(self, arch, major, minor, number, series):
+        '''
+        arch : str
+        major : int
+        minor : int
+        number : Number
+        series : str
+        Returns -> typing.Union[_ForwardRef('Error'), typing.Sequence<+T_co>[~Tools]<~Tools>]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='FindTools', version=1, params=_params)
+        _params['arch'] = arch
+        _params['major'] = major
+        _params['minor'] = minor
+        _params['number'] = number
+        _params['series'] = series
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(FullStatus)
+    async def FullStatus(self, patterns):
+        '''
+        patterns : typing.Sequence<+T_co>[str]
+        Returns -> typing.Union[_ForwardRef('ModelStatusInfo'), typing.Sequence<+T_co>[~RelationStatus]<~RelationStatus>, typing.Mapping<~KT, +VT_co>[str, ~RemoteApplicationStatus]<~RemoteApplicationStatus>]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='FullStatus', version=1, params=_params)
+        _params['patterns'] = patterns
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(BundleChangesResults)
+    async def GetBundleChanges(self, yaml):
+        '''
+        yaml : str
+        Returns -> typing.Sequence<+T_co>[~BundleChange]<~BundleChange>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='GetBundleChanges', version=1, params=_params)
+        _params['yaml'] = yaml
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(GetConstraintsResults)
+    async def GetModelConstraints(self):
+        '''
+
+        Returns -> Value
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='GetModelConstraints', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(AddMachinesResults)
+    async def InjectMachines(self, params):
+        '''
+        params : typing.Sequence<+T_co>[~AddMachineParams]<~AddMachineParams>
+        Returns -> typing.Sequence<+T_co>[~AddMachinesResult]<~AddMachinesResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='InjectMachines', version=1, params=_params)
+        _params['params'] = params
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ModelConfigResults)
+    async def ModelGet(self):
+        '''
+
+        Returns -> typing.Mapping<~KT, +VT_co>[str, ~ConfigValue]<~ConfigValue>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='ModelGet', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ModelInfo)
+    async def ModelInfo(self):
+        '''
+
+        Returns -> typing.Union[_ForwardRef('Number'), _ForwardRef('ModelMigrationStatus'), _ForwardRef('ModelSLAInfo'), _ForwardRef('EntityStatus'), typing.Sequence<+T_co>[~ModelUserInfo]<~ModelUserInfo>]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='ModelInfo', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def ModelSet(self, config):
+        '''
+        config : typing.Mapping<~KT, +VT_co>[str, typing.Any]
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='ModelSet', version=1, params=_params)
+        _params['config'] = config
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def ModelUnset(self, keys):
+        '''
+        keys : typing.Sequence<+T_co>[str]
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='ModelUnset', version=1, params=_params)
+        _params['keys'] = keys
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ModelUserInfoResults)
+    async def ModelUserInfo(self):
+        '''
+
+        Returns -> typing.Sequence<+T_co>[~ModelUserInfoResult]<~ModelUserInfoResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='ModelUserInfo', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(PrivateAddressResults)
+    async def PrivateAddress(self, target):
+        '''
+        target : str
+        Returns -> str
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='PrivateAddress', version=1, params=_params)
+        _params['target'] = target
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ProvisioningScriptResult)
+    async def ProvisioningScript(self, data_dir, disable_package_commands, machine_id, nonce):
+        '''
+        data_dir : str
+        disable_package_commands : bool
+        machine_id : str
+        nonce : str
+        Returns -> str
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='ProvisioningScript', version=1, params=_params)
+        _params['data-dir'] = data_dir
+        _params['disable-package-commands'] = disable_package_commands
+        _params['machine-id'] = machine_id
+        _params['nonce'] = nonce
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(PublicAddressResults)
+    async def PublicAddress(self, target):
+        '''
+        target : str
+        Returns -> str
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='PublicAddress', version=1, params=_params)
+        _params['target'] = target
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ResolveCharmResults)
+    async def ResolveCharms(self, references):
+        '''
+        references : typing.Sequence<+T_co>[str]
+        Returns -> typing.Sequence<+T_co>[~ResolveCharmResult]<~ResolveCharmResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='ResolveCharms', version=1, params=_params)
+        _params['references'] = references
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def Resolved(self, retry, unit_name):
+        '''
+        retry : bool
+        unit_name : str
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='Resolved', version=1, params=_params)
+        _params['retry'] = retry
+        _params['unit-name'] = unit_name
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ErrorResults)
+    async def RetryProvisioning(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~Entity]<~Entity>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='RetryProvisioning', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(StringResult)
+    async def SLALevel(self):
+        '''
+
+        Returns -> typing.Union[_ForwardRef('Error'), str]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='SLALevel', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def SetModelAgentVersion(self, version):
+        '''
+        version : Number
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='SetModelAgentVersion', version=1, params=_params)
+        _params['version'] = version
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def SetModelConstraints(self, application, constraints):
+        '''
+        application : str
+        constraints : Value
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='SetModelConstraints', version=1, params=_params)
+        _params['application'] = application
+        _params['constraints'] = constraints
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(None)
+    async def SetSLALevel(self, creds, level):
+        '''
+        creds : typing.Sequence<+T_co>[int]
+        level : str
+        Returns -> None
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='SetSLALevel', version=1, params=_params)
+        _params['creds'] = creds
+        _params['level'] = level
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(StatusHistoryResults)
+    async def StatusHistory(self, requests):
+        '''
+        requests : typing.Sequence<+T_co>[~StatusHistoryRequest]<~StatusHistoryRequest>
+        Returns -> typing.Sequence<+T_co>[~StatusHistoryResult]<~StatusHistoryResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='StatusHistory', version=1, params=_params)
+        _params['requests'] = requests
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(AllWatcherId)
+    async def WatchAll(self):
+        '''
+
+        Returns -> str
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Client', request='WatchAll', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class CloudFacade(Type):
+    name = 'Cloud'
+    version = 1
+    schema =     {'definitions': {'Cloud': {'additionalProperties': False,
+                               'properties': {'auth-types': {'items': {'type': 'string'},
+                                                             'type': 'array'},
+                                              'endpoint': {'type': 'string'},
+                                              'identity-endpoint': {'type': 'string'},
+                                              'regions': {'items': {'$ref': '#/definitions/CloudRegion'},
+                                                          'type': 'array'},
+                                              'storage-endpoint': {'type': 'string'},
+                                              'type': {'type': 'string'}},
+                               'required': ['type'],
+                               'type': 'object'},
+                     'CloudCredential': {'additionalProperties': False,
+                                         'properties': {'attrs': {'patternProperties': {'.*': {'type': 'string'}},
+                                                                  'type': 'object'},
+                                                        'auth-type': {'type': 'string'},
+                                                        'redacted': {'items': {'type': 'string'},
+                                                                     'type': 'array'}},
+                                         'required': ['auth-type'],
+                                         'type': 'object'},
+                     'CloudCredentialResult': {'additionalProperties': False,
+                                               'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                              'result': {'$ref': '#/definitions/CloudCredential'}},
+                                               'type': 'object'},
+                     'CloudCredentialResults': {'additionalProperties': False,
+                                                'properties': {'results': {'items': {'$ref': '#/definitions/CloudCredentialResult'},
+                                                                           'type': 'array'}},
+                                                'type': 'object'},
+                     'CloudInstanceTypesConstraint': {'additionalProperties': False,
+                                                      'properties': {'cloud-tag': {'type': 'string'},
+                                                                     'constraints': {'$ref': '#/definitions/Value'},
+                                                                     'region': {'type': 'string'}},
+                                                      'required': ['cloud-tag',
+                                                                   'region'],
+                                                      'type': 'object'},
+                     'CloudInstanceTypesConstraints': {'additionalProperties': False,
+                                                       'properties': {'constraints': {'items': {'$ref': '#/definitions/CloudInstanceTypesConstraint'},
+                                                                                      'type': 'array'}},
+                                                       'required': ['constraints'],
+                                                       'type': 'object'},
+                     'CloudRegion': {'additionalProperties': False,
+                                     'properties': {'endpoint': {'type': 'string'},
+                                                    'identity-endpoint': {'type': 'string'},
+                                                    'name': {'type': 'string'},
+                                                    'storage-endpoint': {'type': 'string'}},
+                                     'required': ['name'],
+                                     'type': 'object'},
+                     'CloudResult': {'additionalProperties': False,
+                                     'properties': {'cloud': {'$ref': '#/definitions/Cloud'},
+                                                    'error': {'$ref': '#/definitions/Error'}},
+                                     'type': 'object'},
+                     'CloudResults': {'additionalProperties': False,
+                                      'properties': {'results': {'items': {'$ref': '#/definitions/CloudResult'},
+                                                                 'type': 'array'}},
+                                      'type': 'object'},
+                     'CloudsResult': {'additionalProperties': False,
+                                      'properties': {'clouds': {'patternProperties': {'.*': {'$ref': '#/definitions/Cloud'}},
+                                                                'type': 'object'}},
+                                      'type': 'object'},
+                     'Entities': {'additionalProperties': False,
+                                  'properties': {'entities': {'items': {'$ref': '#/definitions/Entity'},
+                                                              'type': 'array'}},
+                                  'required': ['entities'],
+                                  'type': 'object'},
+                     'Entity': {'additionalProperties': False,
+                                'properties': {'tag': {'type': 'string'}},
+                                'required': ['tag'],
+                                'type': 'object'},
+                     'Error': {'additionalProperties': False,
+                               'properties': {'code': {'type': 'string'},
+                                              'info': {'$ref': '#/definitions/ErrorInfo'},
+                                              'message': {'type': 'string'}},
+                               'required': ['message', 'code'],
+                               'type': 'object'},
+                     'ErrorInfo': {'additionalProperties': False,
+                                   'properties': {'macaroon': {'$ref': '#/definitions/Macaroon'},
+                                                  'macaroon-path': {'type': 'string'}},
+                                   'type': 'object'},
+                     'ErrorResult': {'additionalProperties': False,
+                                     'properties': {'error': {'$ref': '#/definitions/Error'}},
+                                     'type': 'object'},
+                     'ErrorResults': {'additionalProperties': False,
+                                      'properties': {'results': {'items': {'$ref': '#/definitions/ErrorResult'},
+                                                                 'type': 'array'}},
+                                      'required': ['results'],
+                                      'type': 'object'},
+                     'InstanceType': {'additionalProperties': False,
+                                      'properties': {'arches': {'items': {'type': 'string'},
+                                                                'type': 'array'},
+                                                     'cost': {'type': 'integer'},
+                                                     'cpu-cores': {'type': 'integer'},
+                                                     'deprecated': {'type': 'boolean'},
+                                                     'memory': {'type': 'integer'},
+                                                     'name': {'type': 'string'},
+                                                     'root-disk': {'type': 'integer'},
+                                                     'virt-type': {'type': 'string'}},
+                                      'required': ['arches', 'cpu-cores', 'memory'],
+                                      'type': 'object'},
+                     'InstanceTypesResult': {'additionalProperties': False,
+                                             'properties': {'cost-currency': {'type': 'string'},
+                                                            'cost-divisor': {'type': 'integer'},
+                                                            'cost-unit': {'type': 'string'},
+                                                            'error': {'$ref': '#/definitions/Error'},
+                                                            'instance-types': {'items': {'$ref': '#/definitions/InstanceType'},
+                                                                               'type': 'array'}},
+                                             'type': 'object'},
+                     'InstanceTypesResults': {'additionalProperties': False,
+                                              'properties': {'results': {'items': {'$ref': '#/definitions/InstanceTypesResult'},
+                                                                         'type': 'array'}},
+                                              'required': ['results'],
+                                              'type': 'object'},
+                     'Macaroon': {'additionalProperties': False, 'type': 'object'},
+                     'StringResult': {'additionalProperties': False,
+                                      'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                     'result': {'type': 'string'}},
+                                      'required': ['result'],
+                                      'type': 'object'},
+                     'StringsResult': {'additionalProperties': False,
+                                       'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                      'result': {'items': {'type': 'string'},
+                                                                 'type': 'array'}},
+                                       'type': 'object'},
+                     'StringsResults': {'additionalProperties': False,
+                                        'properties': {'results': {'items': {'$ref': '#/definitions/StringsResult'},
+                                                                   'type': 'array'}},
+                                        'required': ['results'],
+                                        'type': 'object'},
+                     'UpdateCloudCredential': {'additionalProperties': False,
+                                               'properties': {'credential': {'$ref': '#/definitions/CloudCredential'},
+                                                              'tag': {'type': 'string'}},
+                                               'required': ['tag', 'credential'],
+                                               'type': 'object'},
+                     'UpdateCloudCredentials': {'additionalProperties': False,
+                                                'properties': {'credentials': {'items': {'$ref': '#/definitions/UpdateCloudCredential'},
+                                                                               'type': 'array'}},
+                                                'type': 'object'},
+                     'UserCloud': {'additionalProperties': False,
+                                   'properties': {'cloud-tag': {'type': 'string'},
+                                                  'user-tag': {'type': 'string'}},
+                                   'required': ['user-tag', 'cloud-tag'],
+                                   'type': 'object'},
+                     'UserClouds': {'additionalProperties': False,
+                                    'properties': {'user-clouds': {'items': {'$ref': '#/definitions/UserCloud'},
+                                                                   'type': 'array'}},
+                                    'type': 'object'},
+                     'Value': {'additionalProperties': False,
+                               'properties': {'arch': {'type': 'string'},
+                                              'container': {'type': 'string'},
+                                              'cores': {'type': 'integer'},
+                                              'cpu-power': {'type': 'integer'},
+                                              'instance-type': {'type': 'string'},
+                                              'mem': {'type': 'integer'},
+                                              'root-disk': {'type': 'integer'},
+                                              'spaces': {'items': {'type': 'string'},
+                                                         'type': 'array'},
+                                              'tags': {'items': {'type': 'string'},
+                                                       'type': 'array'},
+                                              'virt-type': {'type': 'string'}},
+                               'type': 'object'}},
+     'properties': {'Cloud': {'properties': {'Params': {'$ref': '#/definitions/Entities'},
+                                             'Result': {'$ref': '#/definitions/CloudResults'}},
+                              'type': 'object'},
+                    'Clouds': {'properties': {'Result': {'$ref': '#/definitions/CloudsResult'}},
+                               'type': 'object'},
+                    'Credential': {'properties': {'Params': {'$ref': '#/definitions/Entities'},
+                                                  'Result': {'$ref': '#/definitions/CloudCredentialResults'}},
+                                   'type': 'object'},
+                    'DefaultCloud': {'properties': {'Result': {'$ref': '#/definitions/StringResult'}},
+                                     'type': 'object'},
+                    'InstanceTypes': {'properties': {'Params': {'$ref': '#/definitions/CloudInstanceTypesConstraints'},
+                                                     'Result': {'$ref': '#/definitions/InstanceTypesResults'}},
+                                      'type': 'object'},
+                    'RevokeCredentials': {'properties': {'Params': {'$ref': '#/definitions/Entities'},
+                                                         'Result': {'$ref': '#/definitions/ErrorResults'}},
+                                          'type': 'object'},
+                    'UpdateCredentials': {'properties': {'Params': {'$ref': '#/definitions/UpdateCloudCredentials'},
+                                                         'Result': {'$ref': '#/definitions/ErrorResults'}},
+                                          'type': 'object'},
+                    'UserCredentials': {'properties': {'Params': {'$ref': '#/definitions/UserClouds'},
+                                                       'Result': {'$ref': '#/definitions/StringsResults'}},
+                                        'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(CloudResults)
+    async def Cloud(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~Entity]<~Entity>
+        Returns -> typing.Sequence<+T_co>[~CloudResult]<~CloudResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Cloud', request='Cloud', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(CloudsResult)
+    async def Clouds(self):
+        '''
+
+        Returns -> typing.Mapping<~KT, +VT_co>[str, ~Cloud]<~Cloud>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Cloud', request='Clouds', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(CloudCredentialResults)
+    async def Credential(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~Entity]<~Entity>
+        Returns -> typing.Sequence<+T_co>[~CloudCredentialResult]<~CloudCredentialResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Cloud', request='Credential', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(StringResult)
+    async def DefaultCloud(self):
+        '''
+
+        Returns -> typing.Union[_ForwardRef('Error'), str]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Cloud', request='DefaultCloud', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(InstanceTypesResults)
+    async def InstanceTypes(self, constraints):
+        '''
+        constraints : typing.Sequence<+T_co>[~CloudInstanceTypesConstraint]<~CloudInstanceTypesConstraint>
+        Returns -> typing.Sequence<+T_co>[~InstanceTypesResult]<~InstanceTypesResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Cloud', request='InstanceTypes', version=1, params=_params)
+        _params['constraints'] = constraints
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ErrorResults)
+    async def RevokeCredentials(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~Entity]<~Entity>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Cloud', request='RevokeCredentials', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ErrorResults)
+    async def UpdateCredentials(self, credentials):
+        '''
+        credentials : typing.Sequence<+T_co>[~UpdateCloudCredential]<~UpdateCloudCredential>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Cloud', request='UpdateCredentials', version=1, params=_params)
+        _params['credentials'] = credentials
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(StringsResults)
+    async def UserCredentials(self, user_clouds):
+        '''
+        user_clouds : typing.Sequence<+T_co>[~UserCloud]<~UserCloud>
+        Returns -> typing.Sequence<+T_co>[~StringsResult]<~StringsResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Cloud', request='UserCredentials', version=1, params=_params)
+        _params['user-clouds'] = user_clouds
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class DeployerFacade(Type):
+    name = 'Deployer'
+    version = 1
+    schema =     {'definitions': {'APIHostPortsResult': {'additionalProperties': False,
+                                            'properties': {'servers': {'items': {'items': {'$ref': '#/definitions/HostPort'},
+                                                                                 'type': 'array'},
+                                                                       'type': 'array'}},
+                                            'required': ['servers'],
+                                            'type': 'object'},
+                     'Address': {'additionalProperties': False,
+                                 'properties': {'scope': {'type': 'string'},
+                                                'space-name': {'type': 'string'},
+                                                'type': {'type': 'string'},
+                                                'value': {'type': 'string'}},
+                                 'required': ['value', 'type', 'scope'],
+                                 'type': 'object'},
+                     'BytesResult': {'additionalProperties': False,
+                                     'properties': {'result': {'items': {'type': 'integer'},
+                                                               'type': 'array'}},
+                                     'required': ['result'],
+                                     'type': 'object'},
+                     'DeployerConnectionValues': {'additionalProperties': False,
+                                                  'properties': {'api-addresses': {'items': {'type': 'string'},
+                                                                                   'type': 'array'},
+                                                                 'state-addresses': {'items': {'type': 'string'},
+                                                                                     'type': 'array'}},
+                                                  'required': ['state-addresses',
+                                                               'api-addresses'],
+                                                  'type': 'object'},
+                     'Entities': {'additionalProperties': False,
+                                  'properties': {'entities': {'items': {'$ref': '#/definitions/Entity'},
+                                                              'type': 'array'}},
+                                  'required': ['entities'],
+                                  'type': 'object'},
+                     'Entity': {'additionalProperties': False,
+                                'properties': {'tag': {'type': 'string'}},
+                                'required': ['tag'],
+                                'type': 'object'},
+                     'EntityPassword': {'additionalProperties': False,
+                                        'properties': {'password': {'type': 'string'},
+                                                       'tag': {'type': 'string'}},
+                                        'required': ['tag', 'password'],
+                                        'type': 'object'},
+                     'EntityPasswords': {'additionalProperties': False,
+                                         'properties': {'changes': {'items': {'$ref': '#/definitions/EntityPassword'},
+                                                                    'type': 'array'}},
+                                         'required': ['changes'],
+                                         'type': 'object'},
+                     'EntityStatusArgs': {'additionalProperties': False,
+                                          'properties': {'data': {'patternProperties': {'.*': {'additionalProperties': True,
+                                                                                               'type': 'object'}},
+                                                                  'type': 'object'},
+                                                         'info': {'type': 'string'},
+                                                         'status': {'type': 'string'},
+                                                         'tag': {'type': 'string'}},
+                                          'required': ['tag',
+                                                       'status',
+                                                       'info',
+                                                       'data'],
+                                          'type': 'object'},
+                     'Error': {'additionalProperties': False,
+                               'properties': {'code': {'type': 'string'},
+                                              'info': {'$ref': '#/definitions/ErrorInfo'},
+                                              'message': {'type': 'string'}},
+                               'required': ['message', 'code'],
+                               'type': 'object'},
+                     'ErrorInfo': {'additionalProperties': False,
+                                   'properties': {'macaroon': {'$ref': '#/definitions/Macaroon'},
+                                                  'macaroon-path': {'type': 'string'}},
+                                   'type': 'object'},
+                     'ErrorResult': {'additionalProperties': False,
+                                     'properties': {'error': {'$ref': '#/definitions/Error'}},
+                                     'type': 'object'},
+                     'ErrorResults': {'additionalProperties': False,
+                                      'properties': {'results': {'items': {'$ref': '#/definitions/ErrorResult'},
+                                                                 'type': 'array'}},
+                                      'required': ['results'],
+                                      'type': 'object'},
+                     'HostPort': {'additionalProperties': False,
+                                  'properties': {'Address': {'$ref': '#/definitions/Address'},
+                                                 'port': {'type': 'integer'}},
+                                  'required': ['Address', 'port'],
+                                  'type': 'object'},
+                     'LifeResult': {'additionalProperties': False,
+                                    'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                   'life': {'type': 'string'}},
+                                    'required': ['life'],
+                                    'type': 'object'},
+                     'LifeResults': {'additionalProperties': False,
+                                     'properties': {'results': {'items': {'$ref': '#/definitions/LifeResult'},
+                                                                'type': 'array'}},
+                                     'required': ['results'],
+                                     'type': 'object'},
+                     'Macaroon': {'additionalProperties': False, 'type': 'object'},
+                     'NotifyWatchResult': {'additionalProperties': False,
+                                           'properties': {'NotifyWatcherId': {'type': 'string'},
+                                                          'error': {'$ref': '#/definitions/Error'}},
+                                           'required': ['NotifyWatcherId'],
+                                           'type': 'object'},
+                     'SetStatus': {'additionalProperties': False,
+                                   'properties': {'entities': {'items': {'$ref': '#/definitions/EntityStatusArgs'},
+                                                               'type': 'array'}},
+                                   'required': ['entities'],
+                                   'type': 'object'},
+                     'StringResult': {'additionalProperties': False,
+                                      'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                     'result': {'type': 'string'}},
+                                      'required': ['result'],
+                                      'type': 'object'},
+                     'StringsResult': {'additionalProperties': False,
+                                       'properties': {'error': {'$ref': '#/definitions/Error'},
+                                                      'result': {'items': {'type': 'string'},
+                                                                 'type': 'array'}},
+                                       'type': 'object'},
+                     'StringsWatchResult': {'additionalProperties': False,
+                                            'properties': {'changes': {'items': {'type': 'string'},
+                                                                       'type': 'array'},
+                                                           'error': {'$ref': '#/definitions/Error'},
+                                                           'watcher-id': {'type': 'string'}},
+                                            'required': ['watcher-id'],
+                                            'type': 'object'},
+                     'StringsWatchResults': {'additionalProperties': False,
+                                             'properties': {'results': {'items': {'$ref': '#/definitions/StringsWatchResult'},
+                                                                        'type': 'array'}},
+                                             'required': ['results'],
+                                             'type': 'object'}},
+     'properties': {'APIAddresses': {'properties': {'Result': {'$ref': '#/definitions/StringsResult'}},
+                                     'type': 'object'},
+                    'APIHostPorts': {'properties': {'Result': {'$ref': '#/definitions/APIHostPortsResult'}},
+                                     'type': 'object'},
+                    'CACert': {'properties': {'Result': {'$ref': '#/definitions/BytesResult'}},
+                               'type': 'object'},
+                    'ConnectionInfo': {'properties': {'Result': {'$ref': '#/definitions/DeployerConnectionValues'}},
+                                       'type': 'object'},
+                    'Life': {'properties': {'Params': {'$ref': '#/definitions/Entities'},
+                                            'Result': {'$ref': '#/definitions/LifeResults'}},
+                             'type': 'object'},
+                    'ModelUUID': {'properties': {'Result': {'$ref': '#/definitions/StringResult'}},
+                                  'type': 'object'},
+                    'Remove': {'properties': {'Params': {'$ref': '#/definitions/Entities'},
+                                              'Result': {'$ref': '#/definitions/ErrorResults'}},
+                               'type': 'object'},
+                    'SetPasswords': {'properties': {'Params': {'$ref': '#/definitions/EntityPasswords'},
+                                                    'Result': {'$ref': '#/definitions/ErrorResults'}},
+                                     'type': 'object'},
+                    'SetStatus': {'properties': {'Params': {'$ref': '#/definitions/SetStatus'},
+                                                 'Result': {'$ref': '#/definitions/ErrorResults'}},
+                                  'type': 'object'},
+                    'StateAddresses': {'properties': {'Result': {'$ref': '#/definitions/StringsResult'}},
+                                       'type': 'object'},
+                    'UpdateStatus': {'properties': {'Params': {'$ref': '#/definitions/SetStatus'},
+                                                    'Result': {'$ref': '#/definitions/ErrorResults'}},
+                                     'type': 'object'},
+                    'WatchAPIHostPorts': {'properties': {'Result': {'$ref': '#/definitions/NotifyWatchResult'}},
+                                          'type': 'object'},
+                    'WatchUnits': {'properties': {'Params': {'$ref': '#/definitions/Entities'},
+                                                  'Result': {'$ref': '#/definitions/StringsWatchResults'}},
+                                   'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(StringsResult)
+    async def APIAddresses(self):
+        '''
+
+        Returns -> typing.Union[_ForwardRef('Error'), typing.Sequence<+T_co>[str]]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='APIAddresses', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(APIHostPortsResult)
+    async def APIHostPorts(self):
+        '''
+
+        Returns -> typing.Sequence<+T_co>[~HostPort]<~HostPort>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='APIHostPorts', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(BytesResult)
+    async def CACert(self):
+        '''
+
+        Returns -> typing.Sequence<+T_co>[int]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='CACert', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(DeployerConnectionValues)
+    async def ConnectionInfo(self):
+        '''
+
+        Returns -> typing.Sequence<+T_co>[str]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='ConnectionInfo', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(LifeResults)
+    async def Life(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~Entity]<~Entity>
+        Returns -> typing.Sequence<+T_co>[~LifeResult]<~LifeResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='Life', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(StringResult)
+    async def ModelUUID(self):
+        '''
+
+        Returns -> typing.Union[_ForwardRef('Error'), str]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='ModelUUID', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ErrorResults)
+    async def Remove(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~Entity]<~Entity>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='Remove', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ErrorResults)
+    async def SetPasswords(self, changes):
+        '''
+        changes : typing.Sequence<+T_co>[~EntityPassword]<~EntityPassword>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='SetPasswords', version=1, params=_params)
+        _params['changes'] = changes
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ErrorResults)
+    async def SetStatus(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~EntityStatusArgs]<~EntityStatusArgs>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='SetStatus', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(StringsResult)
+    async def StateAddresses(self):
+        '''
+
+        Returns -> typing.Union[_ForwardRef('Error'), typing.Sequence<+T_co>[str]]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='StateAddresses', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(ErrorResults)
+    async def UpdateStatus(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~EntityStatusArgs]<~EntityStatusArgs>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='UpdateStatus', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(NotifyWatchResult)
+    async def WatchAPIHostPorts(self):
+        '''
+
+        Returns -> typing.Union[str, _ForwardRef('Error')]
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='WatchAPIHostPorts', version=1, params=_params)
+
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+    @ReturnMapping(StringsWatchResults)
+    async def WatchUnits(self, entities):
+        '''
+        entities : typing.Sequence<+T_co>[~Entity]<~Entity>
+        Returns -> typing.Sequence<+T_co>[~StringsWatchResult]<~StringsWatchResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='Deployer', request='WatchUnits', version=1, params=_params)
+        _params['entities'] = entities
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class HostKeyReporterFacade(Type):
+    name = 'HostKeyReporter'
+    version = 1
+    schema =     {'definitions': {'Error': {'additionalProperties': False,
+                               'properties': {'code': {'type': 'string'},
+                                              'info': {'$ref': '#/definitions/ErrorInfo'},
+                                              'message': {'type': 'string'}},
+                               'required': ['message', 'code'],
+                               'type': 'object'},
+                     'ErrorInfo': {'additionalProperties': False,
+                                   'properties': {'macaroon': {'$ref': '#/definitions/Macaroon'},
+                                                  'macaroon-path': {'type': 'string'}},
+                                   'type': 'object'},
+                     'ErrorResult': {'additionalProperties': False,
+                                     'properties': {'error': {'$ref': '#/definitions/Error'}},
+                                     'type': 'object'},
+                     'ErrorResults': {'additionalProperties': False,
+                                      'properties': {'results': {'items': {'$ref': '#/definitions/ErrorResult'},
+                                                                 'type': 'array'}},
+                                      'required': ['results'],
+                                      'type': 'object'},
+                     'Macaroon': {'additionalProperties': False, 'type': 'object'},
+                     'SSHHostKeySet': {'additionalProperties': False,
+                                       'properties': {'entity-keys': {'items': {'$ref': '#/definitions/SSHHostKeys'},
+                                                                      'type': 'array'}},
+                                       'required': ['entity-keys'],
+                                       'type': 'object'},
+                     'SSHHostKeys': {'additionalProperties': False,
+                                     'properties': {'public-keys': {'items': {'type': 'string'},
+                                                                    'type': 'array'},
+                                                    'tag': {'type': 'string'}},
+                                     'required': ['tag', 'public-keys'],
+                                     'type': 'object'}},
+     'properties': {'ReportKeys': {'properties': {'Params': {'$ref': '#/definitions/SSHHostKeySet'},
+                                                  'Result': {'$ref': '#/definitions/ErrorResults'}},
+                                   'type': 'object'}},
+     'type': 'object'}
+    
+
+    @ReturnMapping(ErrorResults)
+    async def ReportKeys(self, entity_keys):
+        '''
+        entity_keys : typing.Sequence<+T_co>[~SSHHostKeys]<~SSHHostKeys>
+        Returns -> typing.Sequence<+T_co>[~ErrorResult]<~ErrorResult>
+        '''
+        # map input types to rpc msg
+        _params = dict()
+        msg = dict(type='HostKeyReporter', request='ReportKeys', version=1, params=_params)
+        _params['entity-keys'] = entity_keys
+        reply = await self.rpc(msg)
+        return reply
+
+
+
+class KeyManagerFacade(Type):
+    name = 'KeyManager'
+    version = 1
+    schema =     {'definitions': {'Entities': {'additionalProperties': False,
+                                  'properties': {'entities': {'items': {'$ref': '#/definitions/Entity'},
+                                                              'type': 'array'}},
+                                  'required': ['entities'],
+                                  'type': 'object'},
+                     'Entity': {'additionalProperties': False,
+                                'properties': {'tag': {'type': 'string'}},
+                                'required': ['tag'],
+                                'type': 'object'},
+                     'Error': {'additionalProperties': False,
+                               'properties': {'code': {'type': 'string'},
+                                              'info': {'$ref': '#/definitions/ErrorInfo'},
+                                              'message': {'type': 'string'}},
+                               'required': ['message', 'code'],
+                               'type': 'object'},
+                     'ErrorInfo': {'additionalProperties': False,
+                      &n