;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; REST API bindings for paste.sr.ht ;;; ;;; Copyright (c) 2019, Evan Hanson ;;; ;;; See LICENSE for details. ;;; (declare (module (topham builds)) (export job manifest start)) (import (chicken format) (chicken keyword) (chicken type) (topham)) (define-inline (make-crud path #!optional (body '())) `((#:service "builds" #:path ,path) . ,body)) (define-inline (make-job #!rest args) (keyword-arguments->alist args)) ;; ;; https://man.sr.ht/builds.sr.ht/api.md#get-apijobsidmanifest ;; (: manifest (integer -> (list-of pair))) (define (manifest id) (make-crud (format "/api/jobs/~A/manifest" id))) ;; ;; https://man.sr.ht/builds.sr.ht/api.md#post-apijobsidstart ;; (: start (integer -> (list-of pair))) (define (start id) (make-crud (format "/api/jobs/~A/start" id))) ;; ;; https://man.sr.ht/builds.sr.ht/api.md#get-apijobsid ;; https://man.sr.ht/builds.sr.ht/api.md#post-apijobs ;; (: job (#!optional integer #!rest any -> (list-of pair))) (define (job #!optional id #!rest details) (cond ((integer? id) (make-crud (format "/api/jobs/~A" id))) ((get-keyword #:manifest (cons id details)) (make-crud "/api/jobs" (apply make-job id details))) (else (signal-condition '(topham) '(arity) '(exn location job message "job id or #:manifest must be given")))))