forked from aziontech/azionapi-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedgefunctions.yaml
909 lines (756 loc) · 24.8 KB
/
edgefunctions.yaml
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
openapi: 3.0.0
info:
description: >-
## Welcome to the Azion API!
With the following APIs you can check, remove or update existing settings,
besides creating new ones.
* * *
## Overview
The Azion API is a RESTful API, based on HTTPS requests, that allows you to
integrate your systems with our platform, simply, quickly, and securely.
Here you will find instructions on how our API works and what functionality
is available.
This documentation is being constantly updated. Make sure you verify if
there are any updates or changes before you perform any development in your
application, even if you are familiar with our API.
* * *
Both HTTPS requests and responses must be in JavaScript Object Notation
(JSON) format. All HTTPS requests and responses must follow these
conventions.
**Base URL**
The base URL of the API, which must be used, is:
[**https://api.azionapi.net/**](https://api.azionapi.net/)
**HTTP Methods**
Each HTTP method defines the type of operation that will be run.
| HTTP Method | CRUD | Whole Collection (e.g. /items) | Specific Item (e.g.
/items/:item_id) |
| --- | --- | --- | --- |
| GET | Read | It retrieves the list of items in a Collection. | It
retrieves a specific item in a Collection. |
| POST | Create | It creates a new item in the Collection. | \- |
| PUT | Update/Replace | It replaces a whole Collection with a new one. | It
replaces an item in a Collection with a new one. |
| PATCH | Update/Modify | It partially updates a Collection. | It partially
updates an item in a Collection |
| DELETE | Delete | It deletes a whole Collection. | It deletes an item in a
Collection. |
* * *
**Status Codes**
The HTTP return code defines the status – successful or not – after the
requested operation is run.
| Status Code | Meaning |
| --- | --- |
| 200 OK | General Status for a successful operation. |
| 201 CREATED | Successfully created a collection or item, by means of POST
or PUT. |
| 204 NO CONTENT | Successful operation, but without any content to be
return to the Body. Generally used for DELETE or PUT operations. |
| 207 MULTI-STATUS | A batch of operations were triggered by a single
request, which resulted in different return codes when it was run, for some
of the operations. The codes are displayed in the “status” field, in the
body of the response, for each sub-batch of operations for whichever are
applicable. |
| 400 BAD REQUEST | Request error, such as invalid parameters, missing
mandatory parameters or others. |
| 401 UNAUTHORIZED | Error caused by a missing HTTP Authentication header. |
| 403 FORBIDDEN | User does not have the permissions to run the requested
operation. |
| 404 NOT FOUND | The requested resource does not exist. |
| 405 METHOD NOT ALLOWED | The requested method is not applicable with the
URL. |
| 406 NOT ACCEPTABLE | Accept header missing from the HTTP request or the
header contains formatting or the version is not supported by the API. |
| 409 CONFLICT | Conflict generated in running the request, such as a
request to create an already existing record. |
| 429 TOO MANY REQUESTS | The request was temporarily rejected, due to
exceeding the limit on operations. Wait for the time defined in the
X-Ratelimit-Reset header and try again. |
| 500 INTERNAL SERVER ERROR | Unintentional error, due to an unidentified
failure in the request process. |
| \--- | |
| **HTTP Headers** | |
All requests must be generated with the HTTP header specifying the desired
code format for responses and the API version used. The current version of
the API is 3 and the format is application/json.
```
Accept: application/json; version=3
```
* * *
**Rate Limit**
The limit of operations that can be run via the API is defined by 3 HTTP
response headers:
* **X-ratelimit-limit:** number of operations allowed in one time-frame;
* **X-ratelimit-remaining:** number of operations still available in one
time-frame;
* **X-ratelimit-reset:** is the date and time, in IOS 8601 format, which
represents the point in the future when the time-frame will be closed and
when the limits will, therefore, be reset.
Example of HTTP response headers and a request:
```
Date: Thu, 02 Nov 2017 12:30:28 GMT
X-ratelimit-remaining: 199
X-ratelimit-limit: 200
X-ratelimit-reset: 2017-11-02T12:31:28.675446
```
In the example provided, 200 operations are allowed within a 1-minute time
frame. Of those, there are 199 still available, because one has already been
run. The total limit will be reset after 1 minute.
When the X-ratelimit-limit is reached, or in other words, when the
X-ratelimit-remaining reaches zero, the API will give the error, HTTP 429
TOO MANY REQUESTS. If your application receives this error, you will need to
wait until the time defined in X-ratelimit-reset has passed, to make another
request.
* **X-ratelimit-limit by product**
The *X-ratelimit limit* variations by product are the following:
* **Real-Time Metrics:** 20 requests per minute.
* **Real-Time Purge:** 200 requests per minute; except for the Wildcard,
which is 2000 a day.
> The rate-limit values are based on the client_id.
* * *
**Optional Parameters**
In this version, it is possible to include some optional parameters as part
of the GET method, which can help and modify the form in which your data
will be returned.
You can combine these parameters to get the result you want.
They are:
| Parameter | Description | Accepted values: |
| --- | --- | --- |
| order_by | Identifies which field the return should be sorted by. The
default ordering is ascending. | Depends on the fields available from the
endpoint structure |
| sort | Defines which ordering to be used: ascending or descending. | asc
<br> <br>desc |
| page | Identifies which page should be returned, if the return is
paginated. The default value is 1. | Page number. |
| page_size | Identifies how many items should be returned per page. The
default value is 10. | Desired number of items. |
* * *
**Request Exemple**
You can use one parameter, or a combination. See the example below, which
uses all of them in the same request.
```
GET /domains?order_by=name&page_size=20&sort=desc&page=3
Accept: application/json; version=3
Authorization: token 2909f3932069047f4736dc87e72baaddd19c9f75
```
* * *
# Authentication
Authentication and authorization of operations via Azion API is done through
Tokens.
The first step is to create the Token through authenticating a user
registered in [Real-Time Manager](https://sso.azion.com/login).
* * *
## Encoding Username and Password in Base64
Only token creation and cancelling operations are performed through Basic
Authentication, that is, with a username and password. You can create and
cancel the token through the API itself, but for that you need to encode
your username and password in base64.
Base64 encoding can be done from the command line on a Unix terminal:
```
$ echo 'user@domain:password'|base64
dXNlckBkb21haW46cGFzc3dvcmQK
```
title: Edge Function
version: 1.0.0
servers:
- url: https://api.azionapi.net
- url: https://stage-api.azionapi.net
tags:
- name: edge_functions
description: "Manages serverless functions on the Edge Functions library"
paths:
/edge_functions:
get:
parameters:
- in: query
name: page
required: false
schema:
format: int64
type: integer
- in: query
name: page_size
required: false
schema:
format: int64
type: integer
- in: query
name: sort
required: false
schema:
type: string
- in: query
name: order_by
required: false
schema:
type: string
responses:
"200":
content:
application/json; version=3:
example:
count: 1
total_pages: 1
schema_version: 3
links:
previous: ''
next: ''
results:
- id: 4184
name: Teste
language: javascript
code: "async function handleRequest(request) {\r\n return new\
\ Response(\"Hello World!\",\r\n {\r\n status:200\r\
\n })\r\n }\r\n addEventListener(\"fetch\", event\
\ => {\r\n event.respondWith(handleRequest(event.request))\r\
\n })"
json_args: {}
function_to_run: ""
initiator_type: edge_application
active: true
last_editor: [email protected]
modified: 2021-12-27T19:44:04.427738Z
reference_count: 0
schema:
$ref: '#/components/schemas/ListEdgeFunctionResponse'
description: Success
default:
content:
application/json:
example:
detail: Sorry unable to perform operation.
schema:
$ref: "#/components/schemas/ErrorResponse"
description: Unexpected error
security:
- JWT: []
summary: edge_functions
tags:
- edge_functions
operationId: getFunctions
post:
parameters: []
requestBody:
$ref: '#/components/requestBodies/CreateEdgeFunctionRequest'
content:
application/json:
example:
name: Teste2
language: javascript
code: "async function handleRequest(request) {\r\n return new Response(\"\
Hello World!\",\r\n {\r\n status:200\r\n })\r\
\n }\r\n addEventListener(\"fetch\", event => {\r\n event.respondWith(handleRequest(event.request))\r\
\n })"
json_args: {}
active: true
schema:
properties:
name:
type: string
language:
type: string
code:
type: string
json_args: {}
active:
type: boolean
type: object
required: true
responses:
"201":
content:
application/json:
schema:
$ref: "#/components/schemas/EdgeFunctionResponse"
description: Success
"400":
content:
application/json:
example:
name:
- This field may not be blank
active:
- This field is required.
code:
- This field is required.
language:
- This field is required.
schema:
$ref: '#/components/schemas/BadRequestResponse'
description: Invalid request
default:
content:
application/json:
example:
message: Sorry unable to perform operation.
schema:
$ref: "#/components/schemas/ErrorResponse"
description: Unexpected error
security:
- JWT: []
summary: edge_functions
tags:
- edge_functions
operationId: postFunction
/edge_functions/{id}:
delete:
parameters:
- explode: false
in: path
name: id
required: true
schema:
type: integer
format: int64
style: simple
responses:
"204":
description: Success
default:
content:
application/json:
example:
message: Sorry unable to perform operation.
schema:
$ref: "#/components/schemas/ErrorResponse"
description: Unexpected error
security:
- JWT: []
summary: edge_functions
tags:
- edge_functions
operationId: deleteFunction
get:
parameters:
- explode: false
in: path
name: id
required: true
schema:
type: integer
format: int64
style: simple
responses:
"200":
description: Success
content:
application/json:
example:
results:
id: 4184
name: Teste
language: javascript
code: "async function handleRequest(request) {\r\n return new\
\ Response(\"Hello World!\",\r\n {\r\n status:200\r\
\n })\r\n }\r\n addEventListener(\"fetch\", event\
\ => {\r\n event.respondWith(handleRequest(event.request))\r\
\n })"
json_args: {}
function_to_run: ""
initiator_type: edge_application
active: true
last_editor: [email protected]
modified: 2021-12-27T20:49:25.373356Z
reference_count: 0
schema_version: 3
schema:
$ref: '#/components/schemas/EdgeFunctionResponse'
default:
content:
application/json:
example:
message: Sorry unable to perform operation.
schema:
$ref: "#/components/schemas/ErrorResponse"
description: Unexpected error
security:
- JWT: []
summary: edge_functions
tags:
- edge_functions
operationId: getFunction
patch:
parameters:
- explode: false
in: path
name: id
required: true
schema:
type: integer
format: int64
style: simple
requestBody:
$ref: '#/components/requestBodies/PatchEdgeFunctionRequest'
content:
application/json; version=3:
example:
name: Teste
code: "async function handleRequest(request) {\r\n return new Response(\"\
Hello World!\",\r\n {\r\n status:200\r\n })\r\
\n }\r\n addEventListener(\"fetch\", event => {\r\n event.respondWith(handleRequest(event.request))\r\
\n })"
json_args: {}
active: true
schema:
properties:
name:
type: string
code:
type: string
json_args: {}
active:
type: boolean
type: object
required: true
responses:
"200":
content:
application/json:
example:
results:
id: 4184
name: Teste
language: javascript
code: "async function handleRequest(request) {\r\n return new\
\ Response(\"Hello World!\",\r\n {\r\n status:200\r\
\n })\r\n }\r\n addEventListener(\"fetch\", event\
\ => {\r\n event.respondWith(handleRequest(event.request))\r\
\n })"
json_args: {}
function_to_run: ""
initiator_type: edge_application
active: true
last_editor: [email protected]
modified: 2021-12-27T20:49:25.373356Z
reference_count: 0
schema_version: 3
schema:
$ref: '#/components/schemas/EdgeFunctionResponse'
description: Success
"400":
content:
application/json:
example:
name:
- This field may not be blank
active:
- This field is required.
code:
- This field is required.
language:
- This field is required.
schema:
$ref: '#/components/schemas/BadRequestResponse'
description: Invalid request
default:
content:
application/json:
example:
message: Sorry unable to perform operation.
schema:
$ref: "#/components/schemas/ErrorResponse"
description: Unexpected error
security:
- JWT: []
summary: edge_functions
tags:
- edge_functions
operationId: patchFunction
put:
parameters:
- explode: false
in: path
name: id
required: true
schema:
type: integer
format: int64
style: simple
requestBody:
$ref: '#/components/requestBodies/PutEdgeFunctionRequest'
content:
application/json; version=3:
example:
name: Teste
code: "async function handleRequest(request) {\r\n return new Response(\"\
Hello World!\",\r\n {\r\n status:200\r\n })\r\
\n }\r\n addEventListener(\"fetch\", event => {\r\n event.respondWith(handleRequest(event.request))\r\
\n })"
json_args: {}
active: true
schema:
properties:
name:
type: string
code:
type: string
json_args: {}
active:
type: boolean
type: object
required: true
responses:
"200":
content:
application/json:
example:
results:
id: 4184
name: Teste
language: javascript
code: "async function handleRequest(request) {\r\n return new\
\ Response(\"Hello World!\",\r\n {\r\n status:200\r\
\n })\r\n }\r\n addEventListener(\"fetch\", event\
\ => {\r\n event.respondWith(handleRequest(event.request))\r\
\n })"
json_args: {}
function_to_run: ""
initiator_type: edge_application
active: true
last_editor: [email protected]
modified: 2021-12-27T20:49:25.373356Z
reference_count: 0
schema_version: 3
schema:
$ref: '#/components/schemas/EdgeFunctionResponse'
description: Success
"400":
content:
application/json:
example:
name:
- This field may not be blank
active:
- This field is required.
code:
- This field is required.
language:
- This field is required.
schema:
$ref: '#/components/schemas/BadRequestResponse'
description: Invalid request
default:
content:
application/json:
example:
message: Sorry unable to perform operation.
schema:
$ref: "#/components/schemas/ErrorResponse"
description: Unexpected error
security:
- JWT: []
summary: edge_functions
tags:
- edge_functions
operationId: putFunction
components:
requestBodies:
PutEdgeFunctionRequest:
content:
application/json; version=3:
schema:
$ref: '#/components/schemas/PutEdgeFunctionRequest'
required: true
PatchEdgeFunctionRequest:
content:
application/json; version=3:
schema:
$ref: '#/components/schemas/PatchEdgeFunctionRequest'
required: true
CreateEdgeFunctionRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateEdgeFunctionRequest'
required: true
schemas:
ErrorModel:
properties:
code:
type: string
type: object
ErrorResponse:
properties:
detail:
type: string
type: object
Links:
example:
next: next
previous: previous
properties:
previous:
type: string
next:
type: string
type: object
Results:
example:
code: "function foo() { console.log('hello world');"
last_editor: [email protected]
name: MyFunction
active: true
modified: modified
language: javascript
json_args: '{"a": 1, "b": 2}'
id: 5
function_to_run: function_to_run
reference_count: 5
initiator_type: edge_application
properties:
id:
type: integer
format: int64
name:
type: string
language:
type: string
code:
type: string
json_args: {}
function_to_run:
type: string
initiator_type:
type: string
active:
type: boolean
last_editor:
type: string
modified:
type: string
reference_count:
type: integer
format: int64
type: object
ListEdgeFunctionResponse:
example:
schema_version: 1
count: 1
links:
next: next
previous: previous
total_pages: 6
results:
- code: code
last_editor: last_editor
name: name
active: true
modified: modified
language: language
json_args: '{}'
id: 5
function_to_run: function_to_run
reference_count: 5
initiator_type: initiator_type
- code: code
last_editor: last_editor
name: name
active: true
modified: modified
language: language
json_args: '{}'
id: 5
function_to_run: function_to_run
reference_count: 5
initiator_type: initiator_type
properties:
count:
type: integer
format: int64
total_pages:
type: integer
format: int64
schema_version:
type: integer
format: int64
links:
$ref: '#/components/schemas/Links'
results:
items:
$ref: '#/components/schemas/Results'
type: array
type: object
CreateEdgeFunctionRequest:
properties:
name:
type: string
language:
type: string
code:
type: string
json_args: {}
active:
type: boolean
type: object
BadRequestResponse:
properties:
name:
items:
type: string
type: array
active:
items:
type: string
type: array
code:
items:
type: string
type: array
language:
items:
type: string
type: array
type: object
EdgeFunctionResponse:
example:
schema_version: 1
results:
code: code
last_editor: last_editor
name: name
active: true
modified: modified
language: language
json_args: '{}'
id: 5
function_to_run: function_to_run
reference_count: 5
initiator_type: initiator_type
properties:
results:
$ref: '#/components/schemas/Results'
schema_version:
type: number
type: object
PutEdgeFunctionRequest:
properties:
name:
type: string
code:
type: string
json_args: {}
active:
type: boolean
initiator_type:
type: string
language:
type: string
type: object
PatchEdgeFunctionRequest:
properties:
name:
type: string
code:
type: string
json_args: {}
active:
type: boolean
type: object
securitySchemes:
JWT:
description: |
You must inform a token to auth.
Usage format: `Token <TOKEN>`
in: header
name: Authorization
type: apiKey