Skip to content

Commit

Permalink
Add doxygen-compatible comments to new API functions and tweak parame…
Browse files Browse the repository at this point in the history
…ter nomenclature.
  • Loading branch information
ciaran2 committed Dec 14, 2022
1 parent 6d7c4b1 commit bec8598
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
34 changes: 31 additions & 3 deletions inc/docker.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,37 @@ char *docker_buffer(DOCKER *docker_client);
CURLcode docker_delete(DOCKER *docker_client, char *url);
CURLcode docker_post(DOCKER *docker_client, char *url, char *data);
CURLcode docker_get(DOCKER *docker_client, char *url);
CURLcode docker_delete_with_http_status(DOCKER *docker_client, char *url, long *http_status);
CURLcode docker_post_with_http_status(DOCKER *docker_client, char *url, char *data, long *http_status);
CURLcode docker_get_with_http_status(DOCKER *docker_client, char *url, long *http_status);

/**
* @brief Send a DELETE request to the Docker API and optionally capture the HTTP status code.
*
* @param[in] client Docker client context.
* @param[in] url API endpoint where the request is to be sent.
* @param[out] out_http_status HTTP status code returned by the API. Accepts NULL for cases when the status code is not desired.
* @return Curl error code (CURLE_OK on success).
*/
CURLcode docker_delete_with_http_status(DOCKER *docker_client, char *url, long *out_http_status);

/**
* @brief Send a POST request to the Docker API and optionally capture the HTTP status code.
*
* @param[in] client Docker client context.
* @param[in] url API endpoint where the request is to be sent.
* @param[in] data POST request body.
* @param[out] out_http_status HTTP status code returned by the API. Accepts NULL for cases when the status code is not desired.
* @return Curl error code (CURLE_OK on success).
*/
CURLcode docker_post_with_http_status(DOCKER *docker_client, char *url, char *data, long *out_http_status);

/**
* @brief Send a GET request to the Docker API and optionally capture the HTTP status code.
*
* @param[in] client Docker client context.
* @param[in] url API endpoint where the request is to be sent.
* @param[out] out_http_status HTTP status code returned by the API. Accepts NULL for cases when the status code is not desired.
* @return Curl error code (CURLE_OK on success).
*/
CURLcode docker_get_with_http_status(DOCKER *docker_client, char *url, long *out_http_status);

#ifdef __cplusplus
}
Expand Down
12 changes: 6 additions & 6 deletions src/docker.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,33 @@ CURLcode docker_get(DOCKER *client, char *url) {
return docker_get_with_http_status(client, url, NULL);
}

CURLcode docker_delete_with_http_status(DOCKER *client, char *url, long *http_status) {
CURLcode docker_delete_with_http_status(DOCKER *client, char *url, long *out_http_status) {
init_curl(client);

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(client->curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(client->curl, CURLOPT_CUSTOMREQUEST, "DELETE");
CURLcode response = perform(client, url, http_status);
CURLcode response = perform(client, url, out_http_status);
curl_slist_free_all(headers);

return response;
}

CURLcode docker_post_with_http_status(DOCKER *client, char *url, char *data, long *http_status) {
CURLcode docker_post_with_http_status(DOCKER *client, char *url, char *data, long *out_http_status) {
init_curl(client);

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(client->curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(client->curl, CURLOPT_POSTFIELDS, (void *)data);
CURLcode response = perform(client, url, http_status);
CURLcode response = perform(client, url, out_http_status);
curl_slist_free_all(headers);

return response;
}

CURLcode docker_get_with_http_status(DOCKER *client, char *url, long *http_status) {
CURLcode docker_get_with_http_status(DOCKER *client, char *url, long *out_http_status) {
init_curl(client);
return perform(client, url, http_status);
return perform(client, url, out_http_status);
}

0 comments on commit bec8598

Please sign in to comment.