clibdocker  0.1.0-alpha.0
A Docker API for C
Data Structures | Macros | Typedefs | Enumerations | Functions
docker_result.h File Reference

Docker Results. More...

#include "docker_common.h"
#include <time.h>
Include dependency graph for docker_result.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  docker_result_t
 

Macros

#define DOCKER_PARAM_TRUE   1
 
#define DOCKER_PARAM_FALSE   0
 
#define HTTP_GET_STR   "GET"
 
#define HTTP_POST_STR   "POST"
 
#define HTTP_DELETE_STR   "DELETE"
 

Typedefs

typedef enum _config_error d_err_t
 
typedef struct docker_result_t docker_result
 

Enumerations

enum  _config_error {
  E_UNKNOWN_ERROR = 1 , E_SUCCESS = 0 , E_INVALID_INPUT = -1 , E_FILE_NOT_FOUND = -2 ,
  E_ALLOC_FAILED = -3 , E_PING_FAILED = -4 , E_CONNECTION_FAILED = -5
}
 

Functions

d_err_t new_docker_result (docker_result **result)
 
void free_docker_result (docker_result *result)
 
docker_resultdocker_result_clone (docker_result *result)
 Clone the given docker_result object. More...
 
d_err_t docker_result_get_error_code (docker_result *result)
 Get the result error code. For possible values of the error code see the enum d_err_t. More...
 
time_t docker_result_get_start_time (docker_result *result)
 Get the start time of the operation which produced this result. More...
 
time_t docker_result_get_end_time (docker_result *result)
 Get the end time of the operation which produces this result. More...
 
char * docker_result_get_url (docker_result *result)
 Get the url for the docker API call performed by this operation. More...
 
char * docker_result_get_method (docker_result *result)
 Get the HTTP method used for the docker API call performed by this operation. More...
 
char * docker_result_get_request_json_str (docker_result *result)
 Get the JSON request string sent to the docker API endpoint. More...
 
char * docker_result_get_response_json_str (docker_result *result)
 Get the JSON response string received from the docker API endpoint. More...
 
long docker_result_get_http_error_code (docker_result *result)
 Get the HTTP error code returned by the docker API call. More...
 
char * docker_result_get_message (docker_result *result)
 Get the message string received from docker API call. This is usually part of the JSON response. It is extracted for convenience. More...
 
int is_ok (docker_result *result)
 
void docker_simple_error_handler_print (docker_result *res)
 
void docker_simple_error_handler_log (docker_result *res)
 

Detailed Description

Docker Results.

Macro Definition Documentation

◆ DOCKER_PARAM_FALSE

#define DOCKER_PARAM_FALSE   0

False value for boolean type

◆ DOCKER_PARAM_TRUE

#define DOCKER_PARAM_TRUE   1

True value for boolean type

◆ HTTP_DELETE_STR

#define HTTP_DELETE_STR   "DELETE"

HTTP DELETE Method string

◆ HTTP_GET_STR

#define HTTP_GET_STR   "GET"

HTTP GET Method string

◆ HTTP_POST_STR

#define HTTP_POST_STR   "POST"

HTTP POST Method string

Typedef Documentation

◆ d_err_t

typedef enum _config_error d_err_t

Error code enum for the Docker API calls

◆ docker_result

Internal struct docker_result_t typedef to docker_result

The universal result object for docker API calls in this library. This struct and associated methods provide ways to extract success/failure state of the API Call, and messages associated with any error.

The struct must be inspected before the result values of the API calls are used to ensure safe access.

Also the result object must be freed using free_docker_result, as soon as it is no longer needed.

Enumeration Type Documentation

◆ _config_error

(Internal name) Error code enum for the Docker API calls

Function Documentation

◆ docker_result_clone()

docker_result* docker_result_clone ( docker_result result)

Clone the given docker_result object.

Parameters
resultdocker result object
Returns
docker_result* clone of the given object (can be NULL)

References new_docker_result().

◆ docker_result_get_end_time()

time_t docker_result_get_end_time ( docker_result result)

Get the end time of the operation which produces this result.

Parameters
result
Returns
time_t end time

References docker_result_t::end_time.

◆ docker_result_get_error_code()

d_err_t docker_result_get_error_code ( docker_result result)

Get the result error code. For possible values of the error code see the enum d_err_t.

Parameters
result
Returns
d_err_t error code

References docker_result_t::error_code.

◆ docker_result_get_http_error_code()

long docker_result_get_http_error_code ( docker_result result)

Get the HTTP error code returned by the docker API call.

Parameters
result
Returns
long HTTP error code

References docker_result_t::http_error_code.

◆ docker_result_get_message()

char* docker_result_get_message ( docker_result result)

Get the message string received from docker API call. This is usually part of the JSON response. It is extracted for convenience.

Parameters
result
Returns
char* docker API response message

References docker_result_t::message.

◆ docker_result_get_method()

char* docker_result_get_method ( docker_result result)

Get the HTTP method used for the docker API call performed by this operation.

Parameters
result
Returns
char* HTTP method

References docker_result_t::method.

◆ docker_result_get_request_json_str()

char* docker_result_get_request_json_str ( docker_result result)

Get the JSON request string sent to the docker API endpoint.

Parameters
result
Returns
char* request JSON string

References docker_result_t::request_json_str.

◆ docker_result_get_response_json_str()

char* docker_result_get_response_json_str ( docker_result result)

Get the JSON response string received from the docker API endpoint.

Parameters
result
Returns
char* response JSON string

References docker_result_t::response_json_str.

◆ docker_result_get_start_time()

time_t docker_result_get_start_time ( docker_result result)

Get the start time of the operation which produced this result.

Parameters
result
Returns
time_t start time

References docker_result_t::start_time.

◆ docker_result_get_url()

char* docker_result_get_url ( docker_result result)

Get the url for the docker API call performed by this operation.

Parameters
result
Returns
char* docker API url

References docker_result_t::url.

◆ docker_simple_error_handler_log()

void docker_simple_error_handler_log ( docker_result res)

A simple error handler suitable for programs which just want to log the error (if any).

References docker_log_debug, docker_log_error, docker_result_t::error_code, docker_result_t::http_error_code, is_ok(), docker_result_t::message, and docker_result_t::url.

◆ docker_simple_error_handler_print()

void docker_simple_error_handler_print ( docker_result res)

A simple error handler suitable for programs which just want to log the error (if any).

References docker_result_t::error_code, docker_result_t::http_error_code, is_ok(), docker_result_t::message, and docker_result_t::url.

◆ free_docker_result()

void free_docker_result ( docker_result result)

Utility method to create docker result, should be used by all API implementations to create the result object to return.

Makes a copy of all provided data so that they can be freed after creation of the result. Frees all internal memory used in the docker_result, should be called for all result objects as soon as they are no longer needed.

Frees all internal memory used in the docker_result, should be called for all result objects as soon as they are no longer needed.

References docker_result_t::message, docker_result_t::request_json_str, docker_result_t::response_json_str, and docker_result_t::url.

◆ is_ok()

int is_ok ( docker_result result)

Check if the error_code is E_SUCCESS

References docker_result_t::error_code.

Referenced by docker_simple_error_handler_log(), and docker_simple_error_handler_print().

◆ new_docker_result()

d_err_t new_docker_result ( docker_result **  result)

Utility method to create docker result, should be used by all API implementations to create the result object to return.

Referenced by docker_result_clone().