aboutsummaryrefslogtreecommitdiff
path: root/doc/collection-count.rst
blob: 1aa9c513499f7b678f53cdeb8081fc31dd5e6622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
count
-----

GET
***

.. http:get:: /count/(string:collection)

 Count the elements in all collections or in the provided ``collection``.

 :param collection: The name of the collection to get the count of.
    Can be one of ``boot``, ``defconfig``, ``job``.
 :type collection: string

 :reqheader Authorization: The token necessary to authorize the request.
 :reqheader Accept-Encoding: Accept the ``gzip`` coding.

 :resheader Content-Type: Will be ``application/json; charset=UTF-8``.

 :query int limit: Number of results to return. Default 0 (all results).
 :query int skip: Number of results to skip. Default 0 (none).
 :query string sort: Field to sort the results on. Can be repeated multiple times.
 :query int sort_order: The sort order of the results: -1 (descending), 1
    (ascending). This will be applied only to the first ``sort``
    parameter passed. Default -1.
 :query int date_range: Number of days to consider, starting from today
    (:ref:`more info <intro_schema_time_date>`). By default consider all results.
 :query string arch: A type of computer architetcture (like ``arm``, ``arm64``).
 :query string board: The name of a board.
 :query string created_on: The creation date: accepted formats are ``YYYY-MM-DD`` and ``YYYYMMDD``.
 :query string defconfig: A defconfig name.
 :query int errors: The number of errors.
 :query string job: A job name.
 :query string job_id: A job ID.
 :query string kernel: A kernel name.
 :query string name: The name of an object.
 :query boolean private: The private status.
 :query string status: The status of the elements to get the count of. Can be
    one of: ``PASS`` or ``FAIL``.
 :query int warnings: The number of warnings.

 :status 200: Resuslts found.
 :status 403: Not authorized to perform the operation.
 :status 404: The provided resource has not been found.
 :status 500: Internal database error.

 .. note::

    Not all the query parameters are valid for each collection. Please refer
    to the GET method :ref:`documentation <collections>` of the collection to know which parameters
    can be used.

 **Example Requests**

 .. sourcecode:: http

    GET /count/ HTTP/1.1
    Host: api.armcloud.us
    Accept: */*
    Authorization: token

 .. sourcecode:: http 

    GET /count/job/ HTTP/1.1
    Host: api.armcloud.us
    Accept: */*
    Authorization: token

 .. sourcecode:: http

    GET /count/job?job=next&date_range=1 HTTP/1.1
    Host: api.armcloud.us
    Accept: */*
    Authorization: token

 **Example Responses**

 .. sourcecode:: http

    HTTP/1.1 200 OK
    Vary: Accept-Encoding
    Date: Wed, 06 Aug 2014 13:08:12 GMT
    Content-Type: application/json; charset=UTF-8

    {
        "code": 200,
        "result":
        [
            {
                "count": 260,
                "collection": "job"
            }, 
            {
                "count": 32810,
                "collection": "defconfig"
            },
            {
                "count": 10746,
                "collection": "boot"
            }
        ]
    }

 .. sourcecode:: http

    HTTP/1.1 200 OK
    Vary: Accept-Encoding
    Date: Wed, 06 Aug 2014 13:23:42 GMT

    {
        "code": 200, 
        "result":
        [
            {
                "count": 260,
                "collection": "job"
            }
        ]
    }

 .. sourcecode:: http

    HTTP/1.1 200 OK
    Vary: Accept-Encoding
    Date: Fri, 08 Aug 2014 14:15:40 GMT

    {
        "code": 200,
        "result":
        [
            {
                "count": 1,
                "collection": "job",
                "fields": {
                    "job": "next",
                    "created_on": {
                        "$lt": {
                            "$date": 1407542399000
                        },
                        "$gte": {
                            "$date": 1407369600000
                        }
                    }
                }
            }
        ]
    }

POST
****

.. caution::
    Not implemented. Will return a :ref:`status code <http_status_code>`
    of ``501``.


DELETE
******

.. caution::
    Not implemented. Will return a :ref:`status code <http_status_code>`
    of ``501``.