rest-procs.tcl

Support for some REST APIs

This file defines the following Objects and Classes: ::xo::REST[i]

Location:
packages/xooauth/tcl/rest-procs.tcl
Author:
Gustaf Neumann

Procedures in this file

Detailed information

Class ::xo::REST (public)

 ::nx::Class ::xo::REST[i]

The client_id/client_secret identifies the registered "app" for which later app-tokens are used to issue action via the REST interface.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method body (protected)

 <instance of xo::REST[i]> body [ -content_type content_type ] \
    [ -vars vars ]

Build a body based on the provided variable names. The values are retrieved via uplevel calls.

Switches:
-content_type
(defaults to "application/json; charset=utf-8") (optional)
-vars
(optional)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method expect_status_code (protected)

 <instance of xo::REST[i]> expect_status_code r status_codes
Parameters:
r
status_codes

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method init (protected)

 <instance of xo::REST[i]> init

Make sure, we have the nsv array for application tokens defined.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method json_to_dict (protected)

 <instance of xo::REST[i]> json_to_dict json_string

Convert JSON to a Tcl dict and add it to the result dict.

Parameters:
json_string

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method pp (public)

 <instance of xo::REST[i]> pp [ -list ] [ -prefix prefix ] dict

Simple pretty-print function which is based on the conventions of the dict structures as returned from Microsoft Graph API. Multi-valued results are returned in a dict member named "value", which are printed indented and space separated.

Switches:
-list
(optional)
-prefix
(optional)
Parameters:
dict

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method request (protected)

 <instance of xo::REST[i]> request -method method  \
    [ -content_type content_type ] [ -token token ] [ -vars vars ] \
    -url url 
Switches:
-method
(required)
-content_type
(defaults to "application/json; charset=utf-8") (optional)
-token
(optional)
-vars
(optional)
-url
(required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method typed_list_to_json (protected)

 <instance of xo::REST[i]> typed_list_to_json triples

Convert a list of triples (name, type, value) into json/bson notation. In case, there is mongodb support, use it, otherwise use a simple approximation. The "type" element of the triple is used to determine value formatting, such as e.g. quoting.

Parameters:
triples

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method typed_value_to_json (protected)

 <instance of xo::REST[i]> typed_value_to_json type value
Parameters:
type
value

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

xo::REST method with_json_result (protected)

 <instance of xo::REST[i]> with_json_result rvar
Parameters:
rvar

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
[ show source ]