rest-procs.tcl

Support for some REST APIs

This file defines the following Objects and Classes: ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::xo::REST[i], ::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.

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 (optional, defaults to "application/json; charset=utf-8")
-vars (optional)

Testcases:
No testcase defined.

xo::REST method expect_status_code (protected)

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

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.

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 (required)

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 (required)

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 (optional, defaults to "application/json; charset=utf-8")
-token (optional)
-vars (optional)
-url (required)

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 (required)

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 (required)
value (required)

Testcases:
No testcase defined.

xo::REST method with_json_result (protected)

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

Testcases:
No testcase defined.
[ show source ]