Skip to content

Commit 2f88c11

Browse files
author
Josh Sager
committed
Ported introduction text from current docs to OpenAPI
This includes: * Pagination * Lists and Objects * Filtering and Sorting * Errors * HTTP Status Codes
1 parent 5ec2a08 commit 2f88c11

File tree

1 file changed

+179
-19
lines changed

1 file changed

+179
-19
lines changed

openapi.yaml

Lines changed: 179 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,184 @@ info:
2626
service endpoints allow four levels of access: __view__, __create__, __modify__, __delete__.
2727
Developers now have the capability to create their own exciting new services on top of Linode's
2828
world-class infrastructure.
29+
30+
31+
32+
Download our OpenAPI specification: [Download](/openapi.yaml)
33+
34+
35+
36+
# Pagination
37+
38+
Resource lists are always paginated. The response will look similar to this:
39+
40+
```json
41+
{
42+
"data": [ ... ],
43+
"page": 1,
44+
"pages": 3,
45+
"results": 300
46+
}
47+
```
48+
49+
Pages start at 1. You may retrieve a specific page of results by adding
50+
`?page=x` to your URL (for example, `?page=4`). Page sizes default to 100,
51+
and can be set to return between 25 and 100. Page size can be set using
52+
`?page_size=x`.
53+
54+
# Filtering and Sorting
55+
56+
Collections are searchable by fields they include, marked in the spec as
57+
`x-linode-filterable: true`. Filters are passed
58+
in the `X-Filter` header and are formatted as JSON objects. Here is a request
59+
call for Linode Types in our "standard" class:
60+
61+
```Shell
62+
curl "https://api.linode.com/v4/linode/types" \
63+
-H 'X-Filter: { \
64+
"class": "standard"
65+
}'
66+
```
67+
68+
The filter object's keys are the keys of the object you're filtering,
69+
and the values are accepted values. You can add multiple filters by
70+
including more than one key. For example, filtering for "standard" Linode
71+
Types that offer one vcpu:
72+
73+
```Shell
74+
curl "https://api.linode.com/v4/linode/types" \
75+
-H 'X-Filter: { \
76+
"class": "standard",
77+
"vcpus": 1
78+
}'
79+
```
80+
81+
In the above example, both filters are combined with an "and" operation.
82+
However, if you wanted either Types with one vcpu or Types in our "standard"
83+
class, you can add an operator:
84+
85+
```Shell
86+
curl "https://api.linode.com/v4/linode/types" \
87+
-H 'X-Filter: {
88+
"+or": [
89+
{ "vcpus": 1 },
90+
{ "class": "standard" }
91+
]
92+
}'
93+
```
94+
95+
Each filter in the `+or` array is its own filter object, and all condintions
96+
in it are combined with an "and" operation as they were in the previous example.
97+
98+
Other operators are also available. Operators are keys of a Filter JSON
99+
object. Their value must be of the appropriate type, and they are evaluated
100+
as described below:
101+
102+
| OPERATOR | TYPE | DESCRIPTION |
103+
|----------|--------|-----------------------------------|
104+
| +and | array | All conditions must be true |
105+
| +or | array | One condition must be true |
106+
| +gt | number | Value must be greater than number |
107+
| +gte | number | Value must be greater than or equal to number |
108+
| +lt | number | Value must be less than number |
109+
| +lte | number | Value must be less than or equal to number |
110+
| +contains | string | Given string must be in the value |
111+
| +neq | string | Does not equal the value |
112+
| +order_by | string | Attribute to order the results by - must be filterable |
113+
| +order | string | Either "asc" or "desc". Defaults to "asc". Requires an `+order_by` be given. |
114+
115+
For example, filtering for Linode Types that offer memory equal to or higher
116+
than 61440:
117+
118+
```Shell
119+
curl "https://api.linode.com/v4/linode/types" \
120+
-H 'X-Filter: {
121+
"memory": {
122+
"+gte": 61440
123+
}
124+
}'
125+
```
126+
127+
You can combine and nest operators to construct arbitrarily-complex queries.
128+
For example, give me all Linode Types which are either `standard` or
129+
`highmem` class, and have between 12 and 20 vcpus:
130+
131+
```Shell
132+
curl "https://api.linode.com/v4/linode/types" \
133+
-H 'X-Filter: {
134+
"+or": [
135+
{
136+
"+or": [
137+
{
138+
"class": "standard"
139+
},
140+
{
141+
"class": "highmem"
142+
}
143+
]
144+
},
145+
{
146+
"+and": [
147+
{
148+
"vcpus": {
149+
"+gte": 12
150+
}
151+
},
152+
{
153+
"vcpus": {
154+
"+lte": 20
155+
}
156+
}
157+
]
158+
}
159+
]
160+
}'
161+
```
162+
163+
# Errors
164+
165+
Success is indicated via [Standard HTTP status codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes).
166+
`2xx` codes indicate success, `4xx` codes indicate an
167+
error on your side, and `5xx` errors indicate an error on our side. An error
168+
on your side might be an invalid input, a required parameter being omitted,
169+
etc. Errors on our side shouldn't happen often. If an error does occur, please
170+
let us know.
171+
172+
Requests that return errors will look like this:
173+
174+
```Shell
175+
{
176+
"errors": [
177+
{
178+
"reason": "Invalid JSON"
179+
}
180+
]
181+
}
182+
```
183+
184+
The `errors` field is an array of the things that went wrong with your request.
185+
We will try to include as many of the problems in the response as possible,
186+
but it's conceivable that fixing these errors and resubmitting may result in
187+
new errors coming back once we are able to get further along in the process
188+
of handling your request.
189+
190+
191+
Within each error object, the `field` parameter will be included if the error
192+
pertains to a specific field in the JSON you've submitted. This will be
193+
omitted if there is no relevant field. The reason is a human-readable
194+
explanation of the error, and will always be included.
195+
196+
# HTTP Status Codes
197+
198+
| STATUS | DESCRIPTION |
199+
|---------|-------------|
200+
| 200 OK | The request was successful |
201+
| 400 Bad Request | You submitted an invalid request (missing parameters, etc.) |
202+
| 401 Unauthorized | You failed to authenticate for this resource |
203+
| 403 Forbidden | You are authenticated, but don't have permission to do this |
204+
| 404 Not Found | The resource you're requesting does not exist |
205+
| 429 Too Many Requests | You've hit a rate limit |
206+
| 500 Internal Server Error | Please [open a Support Ticket](/#operation/createTicket) |
29207
contact:
30208
name: Linode
31209
url: /
@@ -10271,7 +10449,7 @@ components:
1027110449
1027210450
* Must start with an alpha character.
1027310451
* Must consist of alphanumeric characters, dashes (`-`), and underscores (`_`).
10274-
* Cannot not have two dashes (`--`) or underscores (`__`) in a row.
10452+
* Cannot have two dashes (`--`) or underscores (`__`) in a row.
1027510453
example: linode123
1027610454
minLength: 3
1027710455
maxLength: 32
@@ -11204,24 +11382,6 @@ components:
1120411382
Throttle connections per second. Set to 0 to disable throttling.
1120511383
example: 0
1120611384
x-linode-cli-display: 6
11207-
transfer:
11208-
type: object
11209-
description: >
11210-
Transfer statistics for this NodeBalancer for the current month.
11211-
readOnly: true
11212-
properties:
11213-
in:
11214-
type: number
11215-
description: Inbound transfer.
11216-
example: 3821.6655349731445
11217-
out:
11218-
type: number
11219-
description: Outbound transfer.
11220-
example: 241188.2196378708
11221-
total:
11222-
type: number
11223-
description: Total transfer (in + out).
11224-
example: 245009.88517284393
1122511385
NodeBalancerConfig:
1122611386
type: object
1122711387
description: >

0 commit comments

Comments
 (0)