2
2
{% load url from future %}
3
3
4
4
{% block content %}
5
- < h2 > Play with the API</ h2 >
6
-
7
- < div class ="row ">
8
- < div class ="span5 ">
9
- < form class ="form-horizontal " id =" idForm ">
10
- < div class ="control -group ">
11
- < label class ="control-label " for =" idEndpoint "> API endpoint</ label >
12
- < div class ="controls ">
13
- < select id ="idEndpoint " class ="span3 ">
14
- {% for endpoint in endpoints %}
15
- < option > {{ endpoint.url }}</ option >
16
- {% endfor %}
17
- </ select >
18
- </ div >
19
- </ div >
20
- < div class ="control -group ">
21
- < label class ="control-label " for =" idLookup "> pk (if needed)</ label >
22
- < div class ="controls ">
23
- < input type ="text " id ="idLookup " class ="span3 ">
24
- </ div >
25
- </ div >
26
- < div class ="control -group ">
27
- < label class ="control-label " for =" idToken "> Access Token</ label >
28
- < div class ="controls ">
29
- < input type ="text " id ="idToken " class ="span3 ">
30
- < span class ="help-block ">
31
- If you have not registered an Application, try using this builtin token: < em > test_access_token</ em >
32
- </ span >
33
- </ div >
34
- </ div >
35
- < div class ="control -group ">
36
- < label class ="control-label " for =" idData "> Payload</ label >
37
- < div class ="controls ">
38
- < textarea rows ="3 " id ="idData " class ="span3 "> </ textarea >
39
- < span class ="help-block ">
40
- Use JSON format, e.g. < em > {"param":"value"}</ em >
41
- </ span >
42
- </ div >
43
- </ div >
44
- < div class ="control-group ">
45
- < button type ="submit " class ="btn btn-inverse " id ="idGET "> GET</ button >
46
- < button type ="submit " class ="btn btn-primary " id ="idPOST "> POST</ button >
47
- < button type ="submit " class ="btn btn-warning " id ="idPUT "> PUT</ button >
48
- < button type ="submit " class ="btn btn-danger " id ="idDELETE "> DELETE</ button >
49
- </ div >
50
- </ form >
5
+ < h2 > Play with the API</ h2 >
6
+
7
+ < div class ="row ">
8
+ < div class ="col-sm-5 ">
9
+ < form id =" idForm " class ="form-horizontal " role =" form ">
10
+ < div class ="form -group ">
11
+ < label class ="col-sm-4 control-label "> API endpoint</ label >
12
+ < div class ="col-sm-8 ">
13
+ < select id ="idEndpoint " class ="form-control ">
14
+ {% for endpoint in endpoints %}
15
+ < option > {{ endpoint.url }}</ option >
16
+ {% endfor %}
17
+ </ select >
18
+ </ div >
19
+ </ div >
20
+ < div class ="form -group ">
21
+ < label class ="col-sm-4 control-label "> pk (if needed)</ label >
22
+ < div class ="col-sm-8 ">
23
+ < input type ="text " id ="idLookup " class ="form-control ">
24
+ </ div >
25
+ </ div >
26
+ < div class ="form -group ">
27
+ < label class ="col-sm-4 control-label "> Access Token</ label >
28
+ < div class ="col-sm-8 ">
29
+ < input type ="text " id ="idToken " class ="form-control ">
30
+ < span class ="help-block ">
31
+ If you have not registered an Application, try using this builtin token: < em > test_access_token</ em >
32
+ </ span >
33
+ </ div >
34
+ </ div >
35
+ < div class ="form -group ">
36
+ < label class ="col-sm-4 control-label "> Payload</ label >
37
+ < div class ="col-sm-8 ">
38
+ < textarea rows ="3 " id ="idData " class ="form-control "> </ textarea >
39
+ < span class ="help-block ">
40
+ Use JSON format, e.g. < em > {"param":"value"}</ em >
41
+ </ span >
42
+ </ div >
43
+ </ div >
44
+ < div class ="control-group ">
45
+ < button type ="submit " class ="btn btn-success " id ="idGET "> GET</ button >
46
+ < button type ="submit " class ="btn btn-primary " id ="idPOST "> POST</ button >
47
+ < button type ="submit " class ="btn btn-warning " id ="idPUT "> PUT</ button >
48
+ < button type ="submit " class ="btn btn-danger " id ="idDELETE "> DELETE</ button >
49
+ </ div >
50
+ </ form >
51
51
</ div >
52
- < div class ="span7 ">
53
- < p > Response: < span id ="idStatus "> </ span > </ p >
54
- < pre id ="idResponse "> </ pre >
52
+ < div class ="col-sm-7 ">
53
+ < p > Response: < span id ="idStatus "> </ span > </ p >
54
+ < pre id ="idResponse "> </ pre >
55
55
</ div >
56
- </ div >
57
-
58
- < h2 > API Cheat Sheet</ h2 >
59
-
60
- < div class ="row "> < div class ="span12 ">
61
-
62
- < h3 > GET /system_info</ h3 >
63
- < p > Show simple system informations, this resource is not protected in any way.</ p >
64
- < p > < strong > Authentication:</ strong > none</ p >
65
-
66
- < h3 > GET /applications</ h3 >
67
- < p > Retrieve the list of Applications present in the playground</ p >
68
- < p > < strong > Authentication:</ strong > none</ p >
69
-
70
- < h3 > POST /applications</ h3 >
71
- < p > Create a new Application</ p >
72
- < p > < strong > Authentication:</ strong > OAuth2, scopes required: can_create_application</ p >
73
- < p > Parameters:</ p >
74
- < ul >
56
+ </ div >
57
+
58
+ < h2 > API Cheat Sheet</ h2 >
59
+ < div class ="row ">
60
+ < div class ="col-sm-12 ">
61
+ < h3 > GET /system_info</ h3 >
62
+ < p > Show simple system informations, this resource is not protected in any way.</ p >
63
+ < p > < strong > Authentication:</ strong > none</ p >
64
+
65
+ < h3 > GET /applications</ h3 >
66
+ < p > Retrieve the list of Applications present in the playground</ p >
67
+ < p > < strong > Authentication:</ strong > none</ p >
68
+
69
+ < h3 > POST /applications</ h3 >
70
+ < p > Create a new Application</ p >
71
+ < p > < strong > Authentication:</ strong > OAuth2, scopes required: can_create_application</ p >
72
+ < p > Parameters:</ p >
73
+ < ul >
75
74
< li > name (optional) - Friendly name for the Application</ li >
76
75
< li > client_id (optional) - The client identifier issued to the client during the registration</ li >
77
76
< li > client_secret (optional) - Confidential secret issued to the client duringthe registration</ li >
78
77
< li > client_type (required, values: [public,private]) - Confidential secret issued to the client duringthe registration</ li >
79
78
< li > authorization_grant_type (required, values: [authorization-code,implicit,passwordl,client-credentials,all-in-one]) - Authorization flow</ li >
80
- </ ul >
81
-
82
- < h3 > GET /applications/:lookup</ h3 >
83
- < p > Retrieve Application detail</ p >
84
- < p > < strong > Authentication:</ strong > OAuth2</ p >
79
+ </ ul >
85
80
86
- < h3 > PUT /applications/:lookup</ h3 >
87
- < p > Update Application details</ p >
88
- < p > < strong > Authentication:</ strong > OAuth2</ p >
89
- < p > Parameters: same as application creation</ p >
81
+ < h3 > GET /applications/:lookup</ h3 >
82
+ < p > Retrieve Application detail</ p >
83
+ < p > < strong > Authentication:</ strong > OAuth2</ p >
90
84
91
- < h3 > DELETE /applications/:lookup</ h3 >
92
- < p > Delete application</ p >
93
- < p > < strong > Authentication:</ strong > OAuth2</ p >
85
+ < h3 > PUT /applications/:lookup</ h3 >
86
+ < p > Update Application details</ p >
87
+ < p > < strong > Authentication:</ strong > OAuth2</ p >
88
+ < p > Parameters: same as application creation</ p >
94
89
95
- </ div > </ div >
96
- {% endblock %}
90
+ < h3 > DELETE /applications/:lookup</ h3 >
91
+ < p > Delete application</ p >
92
+ < p > < strong > Authentication:</ strong > OAuth2</ p >
93
+ </ div >
94
+ </ div >
95
+ {% endblock content %}
97
96
98
97
99
98
{% block javascript %}
100
- < script type ="text/javascript ">
101
- ( function ( ) {
102
-
103
- $ ( '#idForm' ) . submit ( function ( ) {
104
- return false ;
105
- } ) ;
106
-
107
- var showMsg = function ( status , msg ) {
108
- $ ( '#idStatus' ) . html ( status ) ;
109
- $ ( '#idResponse' ) . text ( '' ) . text ( msg ) ;
110
- } ;
111
-
112
- var getUrl = function ( ) {
113
- var url = $ ( '#idEndpoint' ) . val ( ) ;
114
- url = url . replace ( 'lookup' , $ ( '#idLookup' ) . val ( ) ) ;
115
- return url ;
116
- } ;
117
-
118
- var callAPI = function ( url , reqType , token , data ) {
119
- if ( typeof ( token ) === 'undefined' ) token = '' ;
120
- if ( typeof ( data ) === 'undefined' ) data = '' ;
121
-
122
- var req = $ . ajax ( {
123
- url : url ,
124
- type : reqType ,
125
- contentType : 'application/json' ,
126
- data : data ,
127
- beforeSend : function ( request ) {
128
- request . setRequestHeader ( "Authorization" , "Bearer " + token ) ;
129
- }
130
- } ) ;
131
-
132
- req . done ( function ( data , textStatus , jqXHR ) {
133
- var status = 'HTTP ' + jqXHR . status ;
134
- showMsg ( status , JSON . stringify ( data , null , 4 ) ) ;
135
- } ) ;
136
-
137
- req . fail ( function ( jqXHR ) {
138
- var status = 'HTTP ' + jqXHR . status ;
139
- showMsg ( status , "Request failed: " + jqXHR . statusText ) ;
140
- } ) ;
141
- } ;
142
-
143
- $ ( '#idGET' ) . click ( function ( ) {
144
- var token = $ ( "#idToken" ) . val ( ) ;
145
- callAPI ( getUrl ( ) , 'GET' , token ) ;
146
- } ) ;
147
-
148
- $ ( '#idPOST' ) . click ( function ( ) {
149
- var token = $ ( "#idToken" ) . val ( ) ;
150
- var data = $ ( "#idData" ) . val ( ) ;
151
- callAPI ( getUrl ( ) , 'POST' , token , data ) ;
152
- } ) ;
153
-
154
- $ ( '#idPUT' ) . click ( function ( ) {
155
- var token = $ ( "#idToken" ) . val ( ) ;
156
- var data = $ ( "#idData" ) . val ( ) ;
157
- callAPI ( getUrl ( ) , 'PUT' , token , data ) ;
158
- } ) ;
159
-
160
- $ ( '#idDELETE' ) . click ( function ( ) {
161
- var token = $ ( "#idToken" ) . val ( ) ;
162
- callAPI ( getUrl ( ) , 'DELETE' , token ) ;
163
- } ) ;
164
-
165
- } ) ( ) ;
166
- </ script >
99
+ < script type ="text/javascript ">
100
+ ( function ( ) {
101
+
102
+ $ ( '#idForm' ) . submit ( function ( ) {
103
+ return false ;
104
+ } ) ;
105
+
106
+ var showMsg = function ( status , msg ) {
107
+ $ ( '#idStatus' ) . html ( status ) ;
108
+ $ ( '#idResponse' ) . text ( '' ) . text ( msg ) ;
109
+ } ;
110
+
111
+ var getUrl = function ( ) {
112
+ var url = $ ( '#idEndpoint' ) . val ( ) ;
113
+ url = url . replace ( 'lookup' , $ ( '#idLookup' ) . val ( ) ) ;
114
+ return url ;
115
+ } ;
116
+
117
+ var callAPI = function ( url , reqType , token , data ) {
118
+ if ( typeof ( token ) === 'undefined' ) token = '' ;
119
+ if ( typeof ( data ) === 'undefined' ) data = '' ;
120
+
121
+ var req = $ . ajax ( {
122
+ url : url ,
123
+ type : reqType ,
124
+ contentType : 'application/json' ,
125
+ data : data ,
126
+ beforeSend : function ( request ) {
127
+ request . setRequestHeader ( "Authorization" , "Bearer " + token ) ;
128
+ }
129
+ } ) ;
130
+
131
+ req . done ( function ( data , textStatus , jqXHR ) {
132
+ var status = 'HTTP ' + jqXHR . status ;
133
+ showMsg ( status , JSON . stringify ( data , null , 4 ) ) ;
134
+ } ) ;
135
+
136
+ req . fail ( function ( jqXHR ) {
137
+ var status = 'HTTP ' + jqXHR . status ;
138
+ showMsg ( status , "Request failed: " + jqXHR . statusText ) ;
139
+ } ) ;
140
+ } ;
141
+
142
+ $ ( '#idGET' ) . click ( function ( ) {
143
+ var token = $ ( "#idToken" ) . val ( ) ;
144
+ callAPI ( getUrl ( ) , 'GET' , token ) ;
145
+ } ) ;
146
+
147
+ $ ( '#idPOST' ) . click ( function ( ) {
148
+ var token = $ ( "#idToken" ) . val ( ) ;
149
+ var data = $ ( "#idData" ) . val ( ) ;
150
+ callAPI ( getUrl ( ) , 'POST' , token , data ) ;
151
+ } ) ;
152
+
153
+ $ ( '#idPUT' ) . click ( function ( ) {
154
+ var token = $ ( "#idToken" ) . val ( ) ;
155
+ var data = $ ( "#idData" ) . val ( ) ;
156
+ callAPI ( getUrl ( ) , 'PUT' , token , data ) ;
157
+ } ) ;
158
+
159
+ $ ( '#idDELETE' ) . click ( function ( ) {
160
+ var token = $ ( "#idToken" ) . val ( ) ;
161
+ callAPI ( getUrl ( ) , 'DELETE' , token ) ;
162
+ } ) ;
163
+
164
+ } ) ( ) ;
165
+ </ script >
167
166
{% endblock javascript %}
0 commit comments