blendb-api-v1.raml 15.7 KB
Newer Older
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
#%RAML 0.8

title: BlenDB API
version: v1
baseUri: http://blendb.c3sl.ufpr.br/api/{version}
mediaType:  application/json

securitySchemes:
    - oauth_2_0:
        description: |
            OAuth2 is a protocol that lets apps request authorization to
            private details in the system while avoiding the use of passwords.
            This is preferred over Basic Authentication because tokens can be
            limited to specific types of data, and can be revoked by users at
            any time.
        type: OAuth 2.0
        describedBy:
            headers:
                Authorization:
                    description: |
                        Used to send a valid OAuth 2 access token. Do not use
                        together with the "access_token" query string parameter.
                    type: string
            queryParameters:
                access_token:
                    description: |
                        Used to send a valid OAuth 2 access token. Do not use
                        together with the "Authorization" header.
                    type: string
            responses:
                401:
                    description: |
                        Bad or expired token. This can happen if access token
                        has expired or has been revoked by the user.
                    body:
                        application/json:
                            example: |
                                {
                                    id: "invalid_oauth_token",
                                    message: "Bad or expired token. This can happen if access token has expired or has been revoked by the user."
                                }
                403:
                    description: |
                        Bad OAuth2 request (wrong consumer key, bad nonce,
                        expired timestamp, ...).
                    body:
                        application/json:
                            example: |
                                {
                                    id: "invalid_oauth_request",
                                    message: "Bad OAuth2 request (wrong consumer key, bad nonce, expired timestamp, ...)."
                                }
        settings:
            authorizationUri: http://simmc.c3sl.ufpr.br/oauth/authorize
            accessTokenUri: http://simmc.c3sl.ufpr.br/oauth/access_token
            authorizationGrants: [ code, token ]
            scopes:
                - "user"
                - "user:email"

resourceTypes:
    - base:
        get?: &common
            responses:
                403:
                    description: API rate limit exceeded.
                    headers:
                        X-RateLimit-Limit:
                            type: integer
                        X-RateLimit-Remaining:
                            type: integer
                        X-RateLimit-Reset:
                            type: integer
                    body:
                        application/json:
                            example: |
                                {
                                    id: "too_many_requests",
                                    message: "API Rate limit exceeded."
                                }
        post?: *common
        put?: *common
        delete?: *common
    - collection:
        type: base
        get?:
            description: |
                List all of the <<resourcePathName>> (with optional
                filtering).
            responses:
                200:
                    description: |
                        A list of <<resourcePathName>>.
                    body:
                        application/json:
                            schema: <<collectionSchema>>
                            example: <<collectionExample>>
        post?:
            description: |
                Create a new <<resourcePathName|!singularize>>.
            responses:
                201:
                    description: |
                        Sucessfully created a new
                        <<resourcePathName|!singularize>>.
                    headers:
                        Location:
                            description: |
                                A link to the newly created
                                <<resourcePathName|!singularize>>.
                            type: string
                409:
                    description: |
                        Failed to create a new
                        <<resourcePathName|!singularize>> because a conflict
                        with an already existing
                        <<resourcePathName|!singularize>> was detected.
                    body:
                        application/json:
                            example: |
                                {
                                    "id": "already_exists",
                                    "message": "The <<resourcePathName|!singularize>> could not be created due to a conflict with an already existing <<resourcePathName|!singularize>>."
                                }
    - item:
        type: base
        get?:
            description: |
                Return a single <<resourcePathName|!singularize>>.
            responses:
                200:
                    description: |
                        A single <<resourcePathName|!singularize>>.
                    body:
                        application/json:
                            schema: <<itemSchema>>
                            example: <<itemExample>>
                404:
                    description: |
                        The <<resourcePathName|!singularize>> could not be
                        found.
                    body:
                        application/json:
                            example: |
                                {
                                    "id": "not_found",
                                    "message": "The <<resourcePathName|!singularize>> could not be found."
                                }
        put?:
            description: |
                Update a <<resourcePathName>>.
            responses:
                204:
                    description: |
                        The <<resourcePathName|!singularize>> was updated.
                404:
                    description: |
                        The <<resourcePathName|!singularize>> could not be
                        found.
                    body:
                        application/json:
                            example: |
                                {
                                    "id": "not_found",
                                    "message": "The <<resourcePathName|!singularize>> could not be found."
                                }
                409:
                    description: |
                        Failed to update the <<resourcePathName|!singularize>>
                        because a conflict with another
                        <<resourcePathName|!singularize>> was detected.
                    body:
                        application/json:
                            example: |
                                {
                                    "id": "already_exists",
                                    "message": "Failed to update the <<resourcePathName|!singularize>> because a conflict with another <<resourcePathName|!singularize>> was detected."
                                }
        patch?:
            description: |
                Partially update a <<resourcePathName>>.
            responses:
                204:
                    description: |
                        The <<resourcePathName|!singularize>> was updated.
                404:
                    description: |
                        The <<resourcePathName|!singularize>> could not be
                        found.
                    body:
                        application/json:
                            example: |
                                {
                                    "id": "not_found",
                                    "message": "The <<resourcePathName|!singularize>> could not be found."
                                }
                409:
                    description: |
                        Failed to update the <<resourcePathName|!singularize>>
                        because a conflict with another
                        <<resourcePathName|!singularize>> was detected.
                    body:
                        application/json:
                            example: |
                                {
                                    "id": "already_exists",
                                    "message": "Failed to update the <<resourcePathName|!singularize>> because a conflict with another <<resourcePathName|!singularize>> was detected."
                                }
        delete?:
            description: |
                Removes a <<resourcePathName>>.
            responses:
                204:
                    description: |
                        The <<resourcePathName|!singularize>> was removed.
                404:
                    description: |
                        The <<resourcePathName|!singularize>> could not be
                        found.
                    body:
                        application/json:
                            example: |
                                {
                                    "id": "not_found",
                                    "message": "The <<resourcePathName|!singularize>> could not be found."
                                }
    - index:
        type: base
        get?:
            description: |
                Return an index on the <<resourcePathName>> collection.
            responses:
                200:
                    description: |
                        An index on the <<resourcePathName>> collection.
                    body:
                        application/json:

traits:
    - paged:
        queryParameters:
            page:
                description: Specify the page that you want to retrieve
                type: integer
                default: 1
                example: 1
            per_page:
                description: The number of items to return per page
                type: integer
                minimum: 1
                maximum: 50
                default: 10
                example: 20
    - searchable:
        queryParameters:
            query:
                description: |
                    Query string that filters the data returned for your
                    request.
                type: string
    - filtered:
        queryParameters:
            filters:
                description: |
                    Filters that restrict the data returned for your request.
                type: string

    - projectable:
        queryParameters:
            fields:
                description: |
                    Fields to be returned.
                type: string

/metrics:
    description: |
        A Metric represents a statistic that can be queried to generate reports.
        This collection allows the user to list all the metrics available in the
        system and their descriptions.
    securedBy: [ null, oauth_2_0 ]
    get:

/dimensions:
    description: |
        A Dimension allows the data to be aggregated by one or more columns.
        This collection allows the user to list all the dimensions available in
        the system and their descriptions.
    securedBy: [ null, oauth_2_0 ]
    get:

/data:
    description: |
      This is the main part of the API. You may query it for report
      data by specifying metrics (at least one). You may also supply
      additional query parameters such as dimensions, filters, and
      start/end dates to refine your query.
    type: base
    get:
        is: [ filtered ]
        queryParameters:
            metrics:
                description: |
                    A list of comma-separated metrics.
                type: string
                required: true
                example: "met:daysSinceLastContact,met:estimatedNetworkBandwidth"
            dimensions:
                description: |
                    A list of comma-separated dimensions.
                type: string
                required: true
                example: "dim:project,dim:point"
            start-date:
                description: |
                    Start date for fetching data. Requests can specify a
                    start date formatted as YYYY-MM-DD, or as a relative date
                    (e.g., today, yesterday, or NdaysAgo where N is a positive
                    integer).
                type: string
                required: false
                pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo)"
                example: 7daysAgo
            end-date:
                description: |
                    End date for fetching data. Requests can specify a
                    end date formatted as YYYY-MM-DD, or as a relative date
                    (e.g., today, yesterday, or NdaysAgo where N is a positive
                    integer).
                type: string
                required: false
                pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo)"
                example: yesterday
            filters:
                description: |
                    Filters that restrict the data returned for your request.
                type: string
                example: "dim:location(4).id%3D%3D10723"
            sort:
                description: |
                    A list of comma-separated dimensions and metrics
                    indicating the sorting order and sorting direction for
                    the returned data.
                type: string
                example: "dim:project"
        responses:
            200:
                description: |
                    Query successfully executed. Data is returned in a table format.
                body:
                    application/json:
            400:
                description: |
                    The supplied query is invalid. Specified metric or dimension
                    doesn't exist, incorrect formatting for a filter, unacceptable
                    date range, etc.
                body:
                    application/json:
                        example: |
                            {
                                "id": "metric_not_found",
                                "message": "The specified metric 'met:electricCharge' could not be found."
                            }

/collect/{class}:
    description: |
        This API may be used to send data to the monitoring system. There are a
        few available data types (like network bandwidth usage, machine
        inventory, etc.) and each of them requires a specific format for the
        data being sent.
    type: base
    uriParameters:
        class:
            description: The class of data that is being collected.
            type: string
            minLength: 4
            maxLength: 64
            pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
    post:
        body:
            application/json:
        responses:
            200:
                description: |
                    Data has been successfully received and stored by the server.
            400:
                description: |
                    An error has been found in your request. You may review your
                    request and the data that is being sent and try again later.
                body:
                    application/json:
                        example: |
                            {
                                "id": "invalid_attribute",
                                "message": "Invalid attribute \"memory\" for data type \"network_bandwidth\"."
                            }