source: ogServer-Git/src/json.h

Last change on this file was 86ccc3c, checked in by Javier Sánchez Parra <jsanchez@…>, 22 months ago

#915 Add POST /repository/add

This method adds a new repository to the database.

Request:
POST /repository/add
{

"name": "Repository 1",
"ip": "192.168.56.10"

}

Response:
200 OK

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[04ca20e]1#ifndef _OG_JSON_H
2#define _OG_JSON_H
3
4#include <jansson.h>
5#include "schedule.h"
6
[87774ab]7int og_json_parse_string(const json_t *element, const char **str);
8int og_json_parse_string_copy(const json_t *element, char *str, size_t size);
9int og_json_parse_uint64(const json_t *element, uint64_t *integer);
10int og_json_parse_uint(const json_t *element, uint32_t *integer);
11int og_json_parse_bool(const json_t *element, bool *value);
[04ca20e]12
13#define OG_PARAM_PART_NUMBER                    (1UL << 0)
14#define OG_PARAM_PART_CODE                      (1UL << 1)
15#define OG_PARAM_PART_FILESYSTEM                (1UL << 2)
16#define OG_PARAM_PART_SIZE                      (1UL << 3)
17#define OG_PARAM_PART_FORMAT                    (1UL << 4)
18#define OG_PARAM_PART_DISK                      (1UL << 5)
19#define OG_PARAM_PART_OS                        (1UL << 6)
20#define OG_PARAM_PART_USED_SIZE                 (1UL << 7)
[12d8fff]21#define OG_PARAM_PART_DISK_TYPE                 (1UL << 8)
[04ca20e]22
23struct og_partition {
24        const char      *disk;
[12d8fff]25        const char      *disk_type;
[04ca20e]26        const char      *number;
27        const char      *code;
28        const char      *size;
29        const char      *filesystem;
30        const char      *format;
31        const char      *os;
32        const char      *used_size;
33};
34
[24e6fbf]35#define OG_DISK_MAX             4
36#define OG_PARTITION_MAX        (4 * OG_DISK_MAX)
[04ca20e]37
38int og_json_parse_partition(json_t *element, struct og_partition *part,
39                            uint64_t required_flags);
40
41#define OG_CLIENTS_MAX  4096
42
43struct og_sync_params {
44        const char      *sync;
45        const char      *diff;
46        const char      *remove;
47        const char      *compress;
48        const char      *cleanup;
49        const char      *cache;
50        const char      *cleanup_cache;
51        const char      *remove_dst;
52        const char      *diff_id;
53        const char      *diff_name;
54        const char      *path;
55        const char      *method;
56};
57
[33b0c6f]58#define OG_PARAM_SCOPE_ID       (1UL << 0)
59#define OG_PARAM_SCOPE_TYPE     (1UL << 1)
60
61struct og_scope {
62        uint32_t        id;
63        const char      *type;
64};
65
66int og_json_parse_scope(json_t *element, struct og_scope *scope,
67                        const uint64_t required_flags);
68
[04ca20e]69struct og_msg_params {
70        const char      *ips_array[OG_CLIENTS_MAX];
71        const char      *mac_array[OG_CLIENTS_MAX];
[06af0c2]72        const char      *netmask_array[OG_CLIENTS_MAX];
[04ca20e]73        unsigned int    ips_array_len;
74        const char      *wol_type;
75        char            run_cmd[4096];
76        const char      *disk;
77        const char      *partition;
78        const char      *repository;
79        const char      *name;
80        const char      *id;
81        const char      *code;
82        const char      *type;
83        const char      *profile;
84        const char      *cache;
85        const char      *cache_size;
[0212091]86        const char      *comment;
[04ca20e]87        bool            echo;
88        struct og_partition     partition_setup[OG_PARTITION_MAX];
89        struct og_sync_params sync_setup;
90        struct og_schedule_time time;
[e16f36c]91        struct og_image image;
[04ca20e]92        const char      *task_id;
93        uint64_t        flags;
94};
95
[88c8b52]96int og_json_parse_partition_setup(json_t *element, struct og_msg_params *params);
97int og_json_parse_create_image(json_t *element, struct og_msg_params *params);
98int og_json_parse_restore_image(json_t *element, struct og_msg_params *params);
99
[141b079]100struct og_cmd_json {
101        const char      *type;
102        json_t          *json;
103        uint32_t        flags;
104};
105
[1fdb7e6]106enum og_procedure_step_type {
107        OG_STEP_COMMAND         = 0,
108        OG_STEP_PROCEDURE,
[7325a86]109        OG_STEP_TASK,
[1fdb7e6]110};
111
112#define OG_PROCEDURE_STEPS_MAX  256
113
114struct og_procedure_step {
115        enum og_procedure_step_type     type;
116        uint32_t                        position;
117
118        union {
119                struct og_cmd_json      cmd;
120                struct {
121                        uint64_t        id;
122                } procedure;
123        };
124};
125
126struct og_procedure {
127        uint64_t                        id;
128        struct og_procedure_step        steps[OG_PROCEDURE_STEPS_MAX];
129        uint32_t                        num_steps;
130};
131
132int og_json_parse_procedure(json_t *element, struct og_procedure *proc);
133
[86ccc3c]134struct og_repository {
135        const char      *name;
136        const char      *ip;
137};
138
[04ca20e]139#endif
Note: See TracBrowser for help on using the repository browser.