int pakfire_buildservice_build(struct pakfire_buildservice* service, const char* upload,
const char* repo, const char** arches, int flags) {
struct pakfire_xfer* xfer = NULL;
+ struct json_object* request = NULL;
int r;
// Create a new xfer
if (r)
goto ERROR;
+ // Create a new request object
+ r = pakfire_json_new_object(&request);
+ if (r < 0)
+ goto ERROR;
+
// Add the upload parameter
- r = pakfire_xfer_add_param(xfer, "upload", "%s", upload);
- if (r)
+ r = pakfire_json_add_string(request, "upload", upload);
+ if (r < 0)
goto ERROR;
// Add the repo parameter
if (repo) {
- r = pakfire_xfer_add_param(xfer, "repo", "%s", repo);
- if (r)
+ r = pakfire_json_add_string(request, "repo", repo);
+ if (r < 0)
goto ERROR;
}
// Add any arches
if (arches) {
- for (const char** arch = arches; *arch; arch++) {
- r = pakfire_xfer_add_param(xfer, "arch", "%s", *arch);
- if (r)
- goto ERROR;
- }
+ r = pakfire_json_add_string_array(request, "arches", (char**)arches);
+ if (r < 0)
+ goto ERROR;
}
// Disable tests?
- if (flags & PAKFIRE_BUILDSERVICE_DISABLE_TESTS) {
- r = pakfire_xfer_add_param(xfer, "disable_test_builds", "%s", "yes");
- if (r)
- goto ERROR;
- }
+ r = pakfire_json_add_boolean(request, "disable_test_builds",
+ flags & PAKFIRE_BUILDSERVICE_DISABLE_TESTS);
+ if (r < 0)
+ goto ERROR;
// Send the request
- r = pakfire_xfer_run_api_request(xfer, NULL, NULL);
- if (r)
+ r = pakfire_xfer_run_api_request(xfer, request, NULL);
+ if (r < 0)
goto ERROR;
ERROR:
int pakfire_buildservice_create_repo(struct pakfire_buildservice* service,
const char* distro, const char* name, const char* description, struct json_object** p) {
struct pakfire_xfer* xfer = NULL;
+ struct json_object* request = NULL;
struct json_object* response = NULL;
int r;
if (r)
goto ERROR;
+ // Create the request
+ r = pakfire_json_new_object(&request);
+ if (r < 0)
+ goto ERROR;
+
// Set name
- r = pakfire_xfer_add_param(xfer, "name", "%s", name);
+ r = pakfire_json_add_string(request, "name", name);
if (r)
goto ERROR;
// Set description
if (description) {
- r = pakfire_xfer_add_param(xfer, "description", "%s", description);
+ r = pakfire_json_add_string(request, "description", description);
if (r)
goto ERROR;
}
// Send the request
- r = pakfire_xfer_run_api_request(xfer, NULL, &response);
+ r = pakfire_xfer_run_api_request(xfer, request, &response);
if (r)
goto ERROR;
ERROR:
if (xfer)
pakfire_xfer_unref(xfer);
+ if (request)
+ json_object_put(request);
if (response)
json_object_put(response);