Browse code

added new sphinx contrib extention for better REST API docs, and changed the index search API so that it uses the new docs, as a test to make sure it works correctly

Ken Cochrane authored on 2013/05/07 02:38:51
Showing 5 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+Sphinx==1.1.3
1
+sphinxcontrib-httpdomain==1.1.8
0 2
\ No newline at end of file
... ...
@@ -9,7 +9,7 @@ Commands
9 9
 Contents:
10 10
 
11 11
 .. toctree::
12
-  :maxdepth: 2
12
+  :maxdepth: 3
13 13
 
14 14
   basics
15 15
   workingwithrepository
... ...
@@ -25,7 +25,7 @@ import sys, os
25 25
 
26 26
 # Add any Sphinx extension module names here, as strings. They can be extensions
27 27
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
28
-extensions = []
28
+extensions = ['sphinxcontrib.httpdomain']
29 29
 
30 30
 # Add any paths that contain templates here, relative to this directory.
31 31
 templates_path = ['_templates']
... ...
@@ -5,16 +5,34 @@ Docker Index Search API
5 5
 Search
6 6
 ------
7 7
 
8
-**URL:** /v1/search?q={{search_term}}
8
+.. http:get:: /v1/search
9 9
 
10
-**Results:**
10
+   Search the Index given a search term. It accepts :http:method:`get` only.
11 11
 
12
-.. code-block:: json
12
+   **Example request**:
13 13
 
14
-   {"query":"{{search_term}}",
15
-    "num_results": 27,
16
-    "results" : [
17
-       {"name": "dotcloud/base", "description": "A base ubuntu64  image..."},
18
-       {"name": "base2", "description": "A base ubuntu64  image..."},
19
-     ]
20
-   }
21 14
\ No newline at end of file
15
+   .. sourcecode:: http
16
+
17
+      GET /v1/search?q=search_term HTTP/1.1
18
+      Host: example.com
19
+      Accept: application/json
20
+
21
+   **Example response**:
22
+
23
+   .. sourcecode:: http
24
+
25
+      HTTP/1.1 200 OK
26
+      Vary: Accept
27
+      Content-Type: application/json
28
+
29
+      {"query":"search_term",
30
+        "num_results": 2,
31
+        "results" : [
32
+           {"name": "dotcloud/base", "description": "A base ubuntu64  image..."},
33
+           {"name": "base2", "description": "A base ubuntu64  image..."},
34
+         ]
35
+       }
36
+   
37
+   :query q: what you want to search for
38
+   :statuscode 200: no error
39
+   :statuscode 500: server error
22 40
\ No newline at end of file
... ...
@@ -84,7 +84,9 @@ It’s possible to run docker pull https://<registry>/repositories/samalba/busyb
84 84
 
85 85
 Currently registry redirects to s3 urls for downloads, going forward all downloads need to be streamed through the registry. The Registry will then abstract the calls to S3 by a top-level class which implements sub-classes for S3 and local storage.
86 86
 
87
-Token is only returned when it is a private repo, public repos do not require tokens to be returned. The Registry will still contact the Index to make sure the pull is authorized (“is it ok to download this repos without a Token?”).
87
+Token is only returned when the 'X-Docker-Token' header is sent with request.
88
+
89
+Basic Auth is required to pull private repos. Basic auth isn't required for pulling public repos, but if one is provided, it needs to be valid and for an active account.
88 90
 
89 91
 API (pulling repository foo/bar):
90 92
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
@@ -426,6 +428,8 @@ You have 3 options:
426 426
         - X-Docker-Token: true
427 427
 
428 428
     In this case, along with the 200 response, you’ll get a new token (if user auth is ok):
429
+    If authorization isn't correct you get a 401 response.
430
+    If account isn't active you will get a 403 response.
429 431
 
430 432
     **Response**:
431 433
         - 200 OK