aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2014-11-20 11:22:40 +0100
committerMilo Casagrande <milo.casagrande@linaro.org>2014-11-20 11:22:40 +0100
commite3e191163e2dbc0543cb6e6cc17d4465a3a376dd (patch)
tree3140baf444ed634aa9dad0f44940bddccc5ac4cc /doc
parent9549ae802cbce56cc28cd9b7cb96b6a49240aba0 (diff)
doc: Add new examples.
Change-Id: I7a2796ba397125e4b3ffac05f97ead4cfd1ac4a9
Diffstat (limited to 'doc')
-rw-r--r--doc/examples.rst108
1 files changed, 108 insertions, 0 deletions
diff --git a/doc/examples.rst b/doc/examples.rst
index 704ab41..5cffde8 100644
--- a/doc/examples.rst
+++ b/doc/examples.rst
@@ -174,3 +174,111 @@ module automatically handles ``gzip`` and ``deflate`` compressions.
if __name__ == "__main__":
main()
+
+
+Creating a new lab
+------------------
+
+.. note::
+
+ Creation of new lab that can send boot reports is permitted only with an
+ administrative token.
+
+The response object will contain:
+
+* The ``token`` that should be used to send boot lab reports.
+
+* The ``name`` of the lab that should be used to send boot lab reports.
+
+* The lab internal ``_id`` value.
+
+
+::
+
+ #!/usr/bin/env python
+
+ try:
+ import simplejson as json
+ except ImportError:
+ import json
+
+ import requests
+ import urlparse
+
+ AUTHORIZATION_TOKEN = 'foo'
+ BACKEND_URL = 'http://api.armcloud.us'
+
+
+ def main():
+ headers = {
+ 'Authorization': AUTHORIZATION_TOKEN,
+ 'Content-Type': 'application/json'
+ }
+
+ payload = {
+ 'version': '1.0',
+ 'name': 'lab-enymton-00',
+ 'contact': {
+ 'name': 'Ema',
+ 'surname': 'Nymton',
+ 'email': 'ema.nymton@example.org'
+ }
+ }
+
+ url = urlparse.urljoin(BACKEND_URL, '/lab')
+ response = requests.post(url, data=json.dumps(payload), headers=headers)
+
+ print response.content
+
+ if __name__ == '__main__':
+ main()
+
+
+Sending a boot report
+---------------------
+
+::
+
+ #!/usr/bin/env python
+
+ try:
+ import simplejson as json
+ except ImportError:
+ import json
+
+ import requests
+ import urlparse
+
+ AUTHORIZATION_TOKEN = 'foo'
+ BACKEND_URL = 'http://api.armcloud.us'
+
+
+ def main():
+ headers = {
+ 'Authorization': AUTHORIZATION_TOKEN,
+ 'Content-Type': 'application/json'
+ }
+
+ payload = {
+ 'version': '1.0',
+ 'lab_name': 'lab-name-00',
+ 'kernel': 'next-20141118',
+ 'job': 'next',
+ 'defconfig': 'arm-omap2plus_defconfig2',
+ 'board': 'omap4-panda',
+ 'boot_result': 'PASS',
+ 'boot_time': 10.4,
+ 'boot_warnings': 1,
+ 'endian': 'little',
+ 'git_branch': 'local/master',
+ 'git_commit': 'fad15b648058ee5ea4b352888afa9030e0092f1b',
+ 'git_describe': 'next-20141118'
+ }
+
+ url = urlparse.urljoin(BACKEND_URL, '/boot')
+ response = requests.post(url, data=json.dumps(payload), headers=headers)
+
+ print response.content
+
+ if __name__ == '__main__':
+ main()