diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-06-13 09:47:17 +0200 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-06-23 13:12:59 +0200 |
commit | 9ecf638ba28ebcdecac69b04518aa67b576e30dc (patch) | |
tree | 7bafbba0d187385a04dcc92bf31c56377c96f278 /src | |
parent | ce4eb4d83311d71d05ccd925912c417bbf761b9c (diff) |
#915 Extend GET /repositories with param id
Add id parameter to the response. This is useful to identify
repositories that have several IPs.
Request:
GET /repositories
{
"repositories": [
{
"id": 1,
"ip": "192.168.56.10",
"name": "Repositorio (Default)"
}
]
}
Response:
200 OK
Related-to: d5e6dc0 ("#915 Add API GET /repositories")
Diffstat (limited to 'src')
-rw-r--r-- | src/rest.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1915,7 +1915,7 @@ static int og_cmd_get_software(json_t *element, struct og_msg_params *params, static const int og_cmd_get_repositories(char *buffer_reply) { - json_t *root, *repositories, *repository, *ip, *name; + json_t *root, *repositories, *repository, *id, *ip, *name; struct og_buffer og_buffer = { .data = buffer_reply, }; @@ -1930,16 +1930,19 @@ static const int og_cmd_get_repositories(char *buffer_reply) } result = dbi_conn_queryf(dbi->conn, - "SELECT ip, nombrerepositorio " + "SELECT idrepositorio, ip, nombrerepositorio " "FROM repositorios"); repositories = json_array(); while (dbi_result_next_row(result)) { repository = json_object(); + id = json_integer(dbi_result_get_ulonglong(result, + "idrepositorio")); ip = json_string(dbi_result_get_string(result, "ip")); name = json_string(dbi_result_get_string(result, "nombrerepositorio")); + json_object_set_new(repository, "id", id); json_object_set_new(repository, "ip", ip); json_object_set_new(repository, "name", name); json_array_append_new(repositories, repository); |