aboutsummaryrefslogtreecommitdiff
path: root/oneliners.api-client.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-08-23 20:16:42 -0500
committerColin Okay <colin@cicadas.surf>2022-08-23 20:16:42 -0500
commit5a16537d72931db14ca9f7a67c7b8def7d3f51bb (patch)
tree84c551fd2f5ad0e11228b68d50dd71676e4dbc5a /oneliners.api-client.lisp
parenta371f89f8fefa20a823ce77e1c6a9ffc4a2f5cfd (diff)
[add] new generated api client code; updated client.lisp
Diffstat (limited to 'oneliners.api-client.lisp')
-rw-r--r--oneliners.api-client.lisp552
1 files changed, 151 insertions, 401 deletions
diff --git a/oneliners.api-client.lisp b/oneliners.api-client.lisp
index e135973..f8baa8e 100644
--- a/oneliners.api-client.lisp
+++ b/oneliners.api-client.lisp
@@ -1,437 +1,187 @@
-(defpackage #:lazybones-client.shared
- (:intern #:req-string)
- (:export #:*host* #:*body* #:*headers* #:*cookies*))
+;;;; DO NOT EDIT! THIS FILE HAS BEEN GENERATED BY LAZYBONES-CLIENT
+
(defpackage #:ONELINERS.API-CLIENT
- (:use :cl :lazybones-client.shared)
- (:export #:*host* #:*body* #:*headers* #:*cookies* #:request-with
- #:GET--ONELINERS
-#:GET--ONELINERS-ALL-FLAGGED
-#:GET--ONELINERS-NEWEST
-#:PUT--ONELINER-ENTRY-FLAG
-#:GET--ONELINER-ENTRY
-#:PATCH--ONELINER-ENTRY-EDIT
-#:PUT--ONELINER-ONELINER-LOCKED
-#:POST--ONELINER
-#:DELETE--ONELINER-ONELINER
-#:POST--INVITE
-#:DELETE--ACCESS-ACCESS
-#:POST--ACCESS
-#:POST--INVITE-REDEEM-CODE
-#:PUT--CONTRIBUTOR-WHO-SIGNATURE
-#:PUT--CONTRIBUTOR-WHO-PASSWORD
-#:PUT--CONTRIBUTOR-WHO-LOCKED
-#:GET--CONTRIBUTOR-WHO
-#:POST--SNAPSHOT))
+ (:use :cl)
+ (:export
+ #:get-oneliners
+ #:get-oneliners/all-flagged
+ #:get-oneliners/newest
+ #:put-oneliner/entry/flag
+ #:get-oneliner/entry
+ #:patch-oneliner/entry/edit
+ #:put-oneliner/oneliner/locked
+ #:post-oneliner
+ #:delete-oneliner/oneliner
+ #:post-invite
+ #:delete-access/access
+ #:post-access
+ #:post-invite/redeem/code
+ #:put-contributor/who/signature
+ #:put-contributor/who/password
+ #:put-contributor/who/locked
+ #:get-contributor/who
+ #:post-snapshot))
(in-package :ONELINERS.API-CLIENT)
-
-(defvar *host* nil
- "The host to which the client will send its requests.")
-
- (defvar *body* nil
- "Body passed to client post, put, and patch requests")
-
- (defvar *cookies* nil
- "An instance of CL-COOKIE:COOKIE-JAR.")
-
- (defvar *headers* nil
- "A liist of (header-name . header-value) pairs.")
-
- (defmacro request-with ((&key host body headers content-type cookies) &body forms)
- "Make a request in a specific context.
-
-HOST is a string, the hostname where the request will be sent. Defaults
-to *HOST*.
-
-BODY should be a string, an alist, or a pathname. Default to *BODY*
-
-HEADERS should be an ALIST of (header-name . header-value) string
-pairs. Defaults to *HEADERS*.
-
-CONTENT-TYPE is a convenience for supplying just the Content-Type
-header.
-
-COOKIES should be an instance of CL-COOKIE:COOKIE-JAR. Defaults to
-*COOKIES*.
-"
- (let ((content-type-var (gensym))
- (http-error-var (gensym)))
- `(let ((*host* (or ,host *host*))
- (*body* (or ,body *body*))
- (*headers* (or ,headers *headers*))
- (*cookies* (or ,cookies *cookies*))
- (,content-type-var ,content-type))
- (when ,content-type-var
- (push (cons "Content-Type" ,content-type-var) *headers*))
- (handler-case (progn ,@forms)
- (dex:http-request-failed (,http-error-var)
- (format *error-output* "~a -- ~a"
- (dex:response-status ,http-error-var)
- (dex:response-body ,http-error-var)))))))
-
-
-(DEFUN GET--ONELINERS (&KEY TAGS LIMIT NOTFLAGGED NEWEST ONLYFLAGGED)
+(defun get-oneliners
+ (TAGS LIMIT NOTFLAGGED %host &key %headers %cookies)
"A search endpoint returning a JSON encoded array of Oneliner
Entries. TAGS cannot be empty. Returns a [Search
Result](#search-result) object."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliners")
- (WHEN (OR TAGS LIMIT NOTFLAGGED NEWEST ONLYFLAGGED)
- (LIST "?"
- (IF TAGS
- (CONCATENATE 'STRING (SYMBOL-NAME 'TAGS) "="
- (FORMAT NIL "~a" TAGS))
- "")
- (IF LIMIT
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'LIMIT) "="
- (FORMAT NIL "~a" LIMIT))
- "")
- (IF NOTFLAGGED
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'NOTFLAGGED)
- "=" (FORMAT NIL "~a" NOTFLAGGED))
- "")
- (IF NEWEST
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'NEWEST) "="
- (FORMAT NIL "~a" NEWEST))
- "")
- (IF ONLYFLAGGED
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'ONLYFLAGGED)
- "=" (FORMAT NIL "~a" ONLYFLAGGED))
- ""))))))
- (DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ (dexador:get
+ (format nil "~a/api/oneliners?~@[TAGS=~a~]~@[&LIMIT=~a~]~@[&NOTFLAGGED=~a~]" %host TAGS LIMIT NOTFLAGGED)
+ :cookie-jar %cookies
+ :headers %headers))
-
-(DEFUN GET--ONELINERS-ALL-FLAGGED (&KEY LIMIT)
+(defun get-oneliners/all-flagged
+ (LIMIT %host &key %headers %cookies)
"A search endpoint returning all of the flagged oneliners. If LIMIT
is present, only that many are returned."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliners/all-flagged")
- (WHEN (OR LIMIT)
- (LIST "?"
- (IF LIMIT
- (CONCATENATE 'STRING (SYMBOL-NAME 'LIMIT) "="
- (FORMAT NIL "~a" LIMIT))
- ""))))))
- (DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
-
+ (dexador:get
+ (format nil "~a/api/oneliners/all-flagged?~@[LIMIT=~a~]" %host LIMIT)
+ :cookie-jar %cookies
+ :headers %headers))
-(DEFUN GET--ONELINERS-NEWEST (&KEY LIMIT)
+(defun get-oneliners/newest
+ (LIMIT %host &key %headers %cookies)
"A search endpoint returning the LIMIT newest oneliners."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliners/newest")
- (WHEN (OR LIMIT)
- (LIST "?"
- (IF LIMIT
- (CONCATENATE 'STRING (SYMBOL-NAME 'LIMIT) "="
- (FORMAT NIL "~a" LIMIT))
- ""))))))
- (DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ (dexador:get
+ (format nil "~a/api/oneliners/newest?~@[LIMIT=~a~]" %host LIMIT)
+ :cookie-jar %cookies
+ :headers %headers))
-
-(DEFUN PUT--ONELINER-ENTRY-FLAG (ENTRY &KEY TOKEN VALUE)
+(defun put-oneliner/entry/flag
+ (ENTRY TOKEN VALUE %host &key %content-type %body %headers %cookies)
"Flag / Unflag the oneliner for review."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliner/~a/flag" ENTRY)
- (WHEN (OR TOKEN VALUE)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- "")
- (IF VALUE
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'VALUE) "="
- (FORMAT NIL "~a" VALUE))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN GET--ONELINER-ENTRY (ENTRY)
+ (dexador:put
+ (format nil "~a/api/oneliner/~a/flag?~@[TOKEN=~a~]~@[&VALUE=~a~]" %host ENTRY TOKEN VALUE)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun get-oneliner/entry
+ (ENTRY %host &key %headers %cookies)
"Gets a oneliner by id."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliner/~a" ENTRY) NIL)))
- (DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ (dexador:get
+ (format nil "~a/api/oneliner/~a?" %host ENTRY )
+ :cookie-jar %cookies
+ :headers %headers))
-
-(DEFUN PATCH--ONELINER-ENTRY-EDIT (ENTRY &KEY TOKEN)
+(defun patch-oneliner/entry/edit
+ (ENTRY TOKEN %host &key %content-type %body %headers %cookies)
"Edit the fields of a oneliner."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliner/~a/edit" ENTRY)
- (WHEN (OR TOKEN)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:PATCH LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:PATCH LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN PUT--ONELINER-ONELINER-LOCKED (ONELINER &KEY TOKEN VALUE)
+ (dexador:patch
+ (format nil "~a/api/oneliner/~a/edit?~@[TOKEN=~a~]" %host ENTRY TOKEN)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun put-oneliner/oneliner/locked
+ (ONELINER TOKEN VALUE %host &key %content-type %body %headers %cookies)
"Sets the locked value of the specified oneliner"
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliner/~a/locked" ONELINER)
- (WHEN (OR TOKEN VALUE)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- "")
- (IF VALUE
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'VALUE) "="
- (FORMAT NIL "~a" VALUE))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN POST--ONELINER (&KEY TOKEN)
+ (dexador:put
+ (format nil "~a/api/oneliner/~a/locked?~@[TOKEN=~a~]~@[&VALUE=~a~]" %host ONELINER TOKEN VALUE)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun post-oneliner
+ (TOKEN %host &key %content-type %body %headers %cookies)
"Make a new [oneliner](#oneliner)."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliner")
- (WHEN (OR TOKEN)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN DELETE--ONELINER-ONELINER (ONELINER &KEY TOKEN)
+ (dexador:post
+ (format nil "~a/api/oneliner?~@[TOKEN=~a~]" %host TOKEN)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun delete-oneliner/oneliner
+ (ONELINER TOKEN %host &key %headers %cookies)
"Delete a oneliner."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/oneliner/~a" ONELINER)
- (WHEN (OR TOKEN)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (DEXADOR:DELETE LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ (dexador:delete
+ (format nil "~a/api/oneliner/~a?~@[TOKEN=~a~]" %host ONELINER TOKEN)
+ :cookie-jar %cookies
+ :headers %headers))
-
-(DEFUN POST--INVITE (&KEY TOKEN)
+(defun post-invite
+ (TOKEN %host &key %content-type %body %headers %cookies)
"On success, return an object containing a new [invite token](#invite-token)."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/invite")
- (WHEN (OR TOKEN)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN DELETE--ACCESS-ACCESS (ACCESS &KEY TOKEN)
+ (dexador:post
+ (format nil "~a/api/invite?~@[TOKEN=~a~]" %host TOKEN)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun delete-access/access
+ (ACCESS TOKEN %host &key %headers %cookies)
"Revoke access of CONTRIBUTOR"
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/access/~a" ACCESS)
- (WHEN (OR TOKEN)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (DEXADOR:DELETE LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ (dexador:delete
+ (format nil "~a/api/access/~a?~@[TOKEN=~a~]" %host ACCESS TOKEN)
+ :cookie-jar %cookies
+ :headers %headers))
-
-(DEFUN POST--ACCESS ()
+(defun post-access
+ ( %host &key %content-type %body %headers %cookies)
"Authenticate a contributor and reply with an [API token](#access-token)"
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/access") NIL)))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN POST--INVITE-REDEEM-CODE (CODE)
+ (dexador:post
+ (format nil "~a/api/access?" %host )
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun post-invite/redeem/code
+ (CODE %host &key %content-type %body %headers %cookies)
"Redeem an [invite code](#invite-code) and create a new [contributor](#new-contributor-post-body)"
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/invite/redeem/~a" CODE) NIL)))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN PUT--CONTRIBUTOR-WHO-SIGNATURE (WHO &KEY TOKEN)
+ (dexador:post
+ (format nil "~a/api/invite/redeem/~a?" %host CODE )
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun put-contributor/who/signature
+ (WHO TOKEN %host &key %content-type %body %headers %cookies)
"Update a [contributor's](#contributor) signature."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/contributor/~a/signature" WHO)
- (WHEN (OR TOKEN)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN PUT--CONTRIBUTOR-WHO-PASSWORD (WHO &KEY VALUE REPEATED CURRENT TOKEN)
+ (dexador:put
+ (format nil "~a/api/contributor/~a/signature?~@[TOKEN=~a~]" %host WHO TOKEN)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun put-contributor/who/password
+ (WHO VALUE REPEATED CURRENT TOKEN %host &key %content-type %body %headers %cookies)
"Change a contributor's password. CURRENT is the current
password. VALUE is the new password. REPEATED must match VALUE. TOKEN
is an API Access token."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/contributor/~a/password" WHO)
- (WHEN (OR VALUE REPEATED CURRENT TOKEN)
- (LIST "?"
- (IF VALUE
- (CONCATENATE 'STRING (SYMBOL-NAME 'VALUE) "="
- (FORMAT NIL "~a" VALUE))
- "")
- (IF REPEATED
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'REPEATED)
- "=" (FORMAT NIL "~a" REPEATED))
- "")
- (IF CURRENT
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'CURRENT) "="
- (FORMAT NIL "~a" CURRENT))
- "")
- (IF TOKEN
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN PUT--CONTRIBUTOR-WHO-LOCKED (WHO &KEY VALUE TOKEN)
+ (dexador:put
+ (format nil "~a/api/contributor/~a/password?~@[VALUE=~a~]~@[&REPEATED=~a~]~@[&CURRENT=~a~]~@[&TOKEN=~a~]" %host WHO VALUE REPEATED CURRENT TOKEN)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun put-contributor/who/locked
+ (WHO VALUE TOKEN %host &key %content-type %body %headers %cookies)
"Admin users may lock a particular contributor, preventing that
contributor for making edits or adding new oneliners."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/contributor/~a/locked" WHO)
- (WHEN (OR VALUE TOKEN)
- (LIST "?"
- (IF VALUE
- (CONCATENATE 'STRING (SYMBOL-NAME 'VALUE) "="
- (FORMAT NIL "~a" VALUE))
- "")
- (IF TOKEN
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
-(DEFUN GET--CONTRIBUTOR-WHO (WHO)
+ (dexador:put
+ (format nil "~a/api/contributor/~a/locked?~@[VALUE=~a~]~@[&TOKEN=~a~]" %host WHO VALUE TOKEN)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))
+
+(defun get-contributor/who
+ (WHO %host &key %headers %cookies)
"Return a [contributor](#contributor) data object."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/contributor/~a" WHO) NIL)))
- (DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
-
+ (dexador:get
+ (format nil "~a/api/contributor/~a?" %host WHO )
+ :cookie-jar %cookies
+ :headers %headers))
-(DEFUN POST--SNAPSHOT (&KEY TOKEN)
+(defun post-snapshot
+ (TOKEN %host &key %content-type %body %headers %cookies)
"Snapshot the datastore. Do this after upgrade"
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/snapshot")
- (WHEN (OR TOKEN)
- (LIST "?"
- (IF TOKEN
- (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ (dexador:post
+ (format nil "~a/api/snapshot?~@[TOKEN=~a~]" %host TOKEN)
+ :content %body
+ :cookie-jar %cookies
+ :headers (if %content-type (cons (cons "Content-Type" %content-type) %headers) %headers)))