Mercurial > sci
diff lib/apic.h @ 27:dae2de19ca5d
misc: switch to JSON everywhere
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 03 Aug 2022 15:18:09 +0200 |
parents | 2cb228f23f53 |
children |
line wrap: on
line diff
--- a/lib/apic.h Tue Aug 02 13:24:13 2022 +0200 +++ b/lib/apic.h Wed Aug 03 15:18:09 2022 +0200 @@ -1,75 +1,56 @@ #ifndef SCI_APIC_H #define SCI_APIC_H -#include <sys/types.h> - #include <jansson.h> -#include "config.h" - #define APIC_ERR_MAX 128 -struct job; -struct jobresult; -struct project; -struct worker; - struct apic { - json_t *doc; char error[APIC_ERR_MAX]; long status; }; extern struct apiconf { - char baseurl[SCI_URL_MAX]; + char baseurl[512]; } apiconf; /* Generic HTTP commands using JSON. */ /* Perform GET request. */ -int +json_t * apic_get(struct apic *, const char *, ...); /* Perform POST request with JSON body. */ -int +json_t * apic_post(struct apic *, const json_t *, const char *, ...); -/* - * Commands to fetch, create, delete or update data. - * - * Any of the following commands need to keep apic structure alive as long as - * data objects are being used because they reference JSON values directly from - * the HTTP response. - */ +/* --- */ int -apic_job_add(struct apic *, struct job *); +apic_job_add(struct apic *, json_t *); -ssize_t -apic_job_todo(struct apic *, struct job *, size_t, const char *); +json_t * +apic_job_todo(struct apic *, const char *); int -apic_jobresult_add(struct apic *, struct jobresult *); +apic_jobresult_add(struct apic *, json_t *); int -apic_project_save(struct apic *, struct project *); +apic_project_save(struct apic *, json_t *); -ssize_t -apic_project_list(struct apic *, struct project *, size_t); +json_t * +apic_project_list(struct apic *); -int -apic_project_find(struct apic *, struct project *, const char *); +json_t * +apic_project_find(struct apic *, const char *); int -apic_worker_save(struct apic *, struct worker *); - -ssize_t -apic_worker_list(struct apic *, struct worker *, size_t); +apic_worker_save(struct apic *, json_t *); -int -apic_worker_find(struct apic *, struct worker *, const char *); +json_t * +apic_worker_list(struct apic *); -void -apic_finish(struct apic *); +json_t * +apic_worker_find(struct apic *, const char *); #endif /* !SCI_APIC_H */