Common Lisp Package: RPC4CL

README:

FUNCTION

Public

EMPTY-ARRAY

Return the special *empty-array* value

HANDLE-RPC-CALL (DATA &KEY (TIMEOUT 0))

Handle an incoming xml-rpc call by looking up the methodName and then calling the function with the multiple values in the decoded <params></params>. Then encode the result to its string representation and return it. Optionally throw an xml-rpc-fault with code 0 if timeout was reached before the end of the call.

RPC-CALL (URI USERNAME PASSWORD METHOD-NAME &REST PARAMS)

Call method-name with params. The encoded call is sent to uri and the decoded response parameters are returned as multiple values or in the case of a fault a xml-rpc-fault condition is raised. To make this function more ergonomic you should propbably wrap it up in your own which specifies uri, username and password as needed for you.

Private

ASSERT-METHOD (METHODNAME)

Make sure that a method exists by looking it up its name

BASE64-P (LIST)

We expect base64 encoded content to be denoted as a two element lisp with the first element being the keyword :base64 and the second being the base64 encoded string contents.

CAMEL-CRAZE (STRING)

Convet a string containing dashes to its camelCased representation. CAMEL-CASE becomes camelCase.

CAMEL-CRAZE-SYMBOL (SYMBOL)

Do camel-crazing on a symbol returning a string

DE-CAMEL-CRAZE (STRING)

Convert camelCase string to what we would expect for lisp symbol name suitable for find-symbol. camelCase becomes CAMEL-CASE. This is the reverse of camel-crazing something

DE-CAMEL-CRAZE-KEYWORD (STRING)

Decraze a string returning a keyword symbol

DECODE-ARRAY (ARRAY-DOM &AUX ARRAY)

Decode an array to a list

DECODE-METHOD-CALL-RESPONSE (DOCUMENT)

Decode a method call response and throw a xml-rpc-fault error if there is a fault in the response xml otherwise return the decoded params as multiple values.

DECODE-PARAMS (DOCUMENT &AUX PARAMS)

Decode all the params one by one and return as multiple values

DECODE-STRING (STRING)

Restore any escaped string values

DECODE-STRUCT (VAL &AUX STRUCT)

Decode a struct to a plist

DECODE-VALUE (VAL)

Decode the value by looking at the type node name

ENCODE-ARRAY (LIST)

Encode an XML-RPC array from a list if you want to encode an actual array/vector you should coerce it to list first.

ENCODE-DATE-TIME (TIMESTAMP)

I haven't read up on iso8601 and what it entails but this should at least be one valid format for encoding it.

ENCODE-METHOD-CALL (METHOD-NAME &REST PARAMS)

Create a complete XML document representing a method call to method-name with any number of params

ENCODE-METHOD-FAULT (E)

A XML-RPC fault is a struct with a faultCode and a faultString member inside a <fault> tag.

ENCODE-METHOD-RESPONSE (&REST PARAMS)

Encode the method response suitable for decoding by an XML-RPC client. In case an xml-rpc-fault is raised we encode it and return it.

ENCODE-PARAMS (&REST PARAMS)

Encode all arguments as a XML-RPC <params> tag

ENCODE-STRING (STRING)

Escape all & and < characters in a string with their respective HTML entities.

ENCODE-STRUCT (PLIST)

Encode a struct (being a plist) and convert the plist keys to their camelcrazed representation.

ENCODE-VALUE (THING)

Convert lisp values to the closest XML-RPC supported type. For complex data types we call out to their respective encoding routines.

FIND-XML-RPC-METHOD (NAME)

Find a method in *current-api* or :system

PLIST-KEYS (PLIST)

Return the keys of a plist

PLIST-P (POSSIBLE-PLIST)

Try to determine if possible-plist is a valid plist by making sure the list contains even pairs and that all keys are keywords.

PLIST-VALUES (PLIST)

Return the values of a plist

UTF8-LENGTH (STRING)

Determine content-length for an UTF-8 string using babel for portability.

XML-RPC-EXCHANGE (URI XML &OPTIONAL USERNAME PASSWORD &AUX (CONTENT-LENGTH (UTF8-LENGTH XML)))

Use drakma to perform an HTTP POST request with the supplied xml in the body and optionally with basic auth if username and password are non-nil.

XML-RPC-METHOD-DOCUMENTATION (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

XML-RPC-METHOD-EQUALP (A B)

Method are equal if their functions match

XML-RPC-METHOD-FUNCTION (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

XML-RPC-METHOD-NAME (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Undocumented

COPY-XML-RPC-METHOD (INSTANCE)

ELEMENTS (NODE)

FIND-ELEMENT (NODE NAME)

FIRST-ELEMENT (NODE)

MAKE-XML-RPC-METHOD (&KEY ((NAME DUM0) NIL) ((FUNCTION DUM1) NIL) ((DOCUMENTATION DUM2) NIL))

SYSTEM.GET-CAPABILITIES (&REST NO-SUCH-PARAMETERS)

SYSTEM.LIST-METHODS (&REST NO-SUCH-PARAMETERS)

SYSTEM.METHOD-HELP (METHOD-NAME &REST NO-SUCH-PARAMETERS)

SYSTEM.METHOD-SIGNATURE (METHOD &REST NO-SUCH-PARAMETERS)

SYSTEM.MULTICALL (CALLS &REST NO-SUCH-PARAMETERS)

SETFXML-RPC-METHOD-DOCUMENTATION (NEW-VALUE INSTANCE)

SETFXML-RPC-METHOD-FUNCTION (NEW-VALUE INSTANCE)

SETFXML-RPC-METHOD-NAME (NEW-VALUE INSTANCE)

XML-RPC-METHOD-P (OBJECT)

MACRO

Public

DEFINE-RPC-CALL (API-NAME (CALL-NAME &REST PARAMETERS) &BODY BODY)

Usage: (define-rpc-call :my-api (plus :int a :int b) (+ a b)) Defines a function, call-name which when called verifies its parameters and number of parameters and throws appropriate xml-rpc faults before executing it's body. For 'sloppy' code the :any type may be used but then you better make sure yourself that you've got the expected type.

DEFINE-RPC-CALL-HELP (API-NAME (CALL-NAME) DOCUMENTATION)

Define documentation that will be returned through system.methodHelp

WITH-API ((API-NAME) &BODY BODY)

Bind *current-api* to api-name for future reference.

Private

WITH-TIMEOUT ((SECONDS) &BODY BODY)

Execute `body` for no more than `seconds` time. If `seconds` is exceeded, then a [timeout-error][] will be signaled. If `seconds` is nil, then the body will be run normally until it completes or is interrupted.

GENERIC-FUNCTION

Public

Undocumented

ADD-CALL (MULTICALL METHOD-NAME &REST PARAMS)

PERFORM-CALLS (MULTICALL)

Private

Undocumented

FAULT-CODE-OF (CONDITION)

FAULT-STRING-OF (CONDITION)

SLOT-ACCESSOR

Private

Undocumented

CALLS-OF (OBJECT)

SETFCALLS-OF (NEW-VALUE OBJECT)

PASSWORD-OF (OBJECT)

URI-OF (OBJECT)

USERNAME-OF (OBJECT)

VARIABLE

Public

*DEBUG*

Setting this variable to t will result in debug information emitted on *standard-output* while calling xml-rpc-call

Private

*EMPTY-ARRAY*

Unique value used to represent an empty array

Undocumented

*XML-RPC-INTERFACES*

CLASS

Public

MULTICALL

A stack for multiple calls using system.multicall

Private

Undocumented

XML-RPC-METHOD

CONDITION

Public

XML-RPC-FAULT

Condition thrown in the event of an XML-RPC fault

XML-RPC-PARSE-ERROR

Condition thrown in the event of an XML-RPC parse error