29 #ifndef DOCKER_CONNECTION_UTIL_H_ 
   30 #define DOCKER_CONNECTION_UTIL_H_ 
   36 #include <coll_arraylist.h> 
   37 #include <coll_arraylist_map.h> 
   41 #include <json-c/json_object.h> 
   42 #include <json-c/json_tokener.h> 
   43 #include <json-c/linkhash.h> 
   44 #include <curl/curl.h> 
   50 #define DOCKER_API_VERSION_1_39 "1.39" 
   55 #define DOCKER_DEFAULT_UNIX_SOCKET "/var/run/docker.sock" 
   60 #define DOCKER_NPIPE_URL_PREFIX "npipe://" 
   65 #define DOCKER_DEFAULT_WINDOWS_NAMED_PIPE "npipe:////./pipe/docker_engine" 
   70 #define DOCKER_DEFAULT_LOCALHOST_URL "http://localhost:2375/" 
   73 #define DOCKER_DEFAULT_SOCKET DOCKER_DEFAULT_WINDOWS_NAMED_PIPE 
   76 #if defined(unix) || defined(__unix__) || defined(__unix) 
   77 #define DOCKER_DEFAULT_SOCKET DOCKER_DEFAULT_UNIX_SOCKET 
   83 #define HEADER_JSON "Content-Type: application/json" 
   88 #define HEADER_TAR "Content-Type: application/x-tar" 
  112 MODULE_API 
bool is_npipe(
char* url);
 
  127     NONE = 0, CONTAINER = 1, IMAGE = 2, SYSTEM = 3, NETWORK = 4, VOLUME = 5
 
  284     const char* 
id, 
const char* method);
 
  495 #define NPIPE_READ_BUFSIZE 1024 
Some common declarations.
 
void docker_call_request_data_set(docker_call *dcall, char *request_data)
Set the docker request data.
Definition: docker_connection_util.c:387
 
void docker_call_request_data_len_set(docker_call *dcall, size_t request_data_len)
Set the docker request data length.
Definition: docker_connection_util.c:405
 
d_err_t make_docker_context_default_local(docker_context **ctx)
Definition: docker_connection_util.c:165
 
void() docker_result_handler_fn(struct docker_context_t *ctx, docker_result *result)
Defines a docker result handler function.
Definition: docker_connection_util.h:136
 
void docker_call_request_method_set(docker_call *dcall, char *method)
Set the docker request HTTP method.
Definition: docker_connection_util.c:353
 
docker_result_handler_fn * docker_context_result_handler_get(docker_context *ctx)
Get the docker context result handler function.
Definition: docker_connection_util.c:189
 
size_t docker_call_request_data_len_get(docker_call *dcall)
Get the docker request data length.
Definition: docker_connection_util.c:413
 
char * docker_call_content_type_header_get(docker_call *dcall)
Get the docker request content type header.
Definition: docker_connection_util.c:378
 
status_callback * docker_call_status_cb_get(docker_call *dcall)
Get the docker call callback function.
Definition: docker_connection_util.c:465
 
void() status_callback(char *msg, void *cbargs, void *client_cbargs)
Status callback function type. This is used to get a status callback from docker calls.
Definition: docker_connection_util.h:229
 
size_t docker_call_response_data_length(docker_call *dcall)
Get the docker response data length.
Definition: docker_connection_util.c:431
 
d_err_t docker_call_exec(docker_context *ctx, docker_call *dcall, json_object **response)
Execute the Docker Call i.e. send the request to the server and get response.
Definition: docker_connection_util.c:743
 
bool is_npipe(char *url)
Check if the given string input is an NPIPE URL.
Definition: docker_connection_util.c:78
 
struct docker_context_t docker_context
A docker context for a specific docker server.
 
d_err_t free_docker_context(docker_context **ctx)
Definition: docker_connection_util.c:219
 
void free_docker_call(docker_call *dcall)
Free the docker call object.
Definition: docker_connection_util.c:520
 
void docker_call_content_type_header_set(docker_call *dcall, char *content_type_header)
Set the docker call content type header.
Definition: docker_connection_util.c:370
 
void docker_call_cb_args_set(docker_call *dcall, void *cb_args)
Set the docker call callback function callback args.
Definition: docker_connection_util.c:474
 
void docker_api_cleanup()
Definition: docker_connection_util.c:114
 
char * docker_call_response_data_get(docker_call *dcall)
Get the docker response data.
Definition: docker_connection_util.c:422
 
char * npipe_url_only(char *url)
Get the docker api url part of the npipe url. Removes the npipe:// prefix from the url.
Definition: docker_connection_util.c:90
 
docker_object_type
Docker Object type in the Docker API call JSON.
Definition: docker_connection_util.h:126
 
int docker_call_params_add_boolean(docker_call *dcall, char *param, int value)
Add a string key/boolean value pair to the docker call parameters.
Definition: docker_connection_util.c:543
 
d_err_t docker_context_result_handler_set(docker_context *ctx, docker_result_handler_fn *result_handler_fn)
Definition: docker_connection_util.c:180
 
char * docker_call_request_method_get(docker_call *dcall)
Get the docker request HTTP method.
Definition: docker_connection_util.c:361
 
char * docker_call_get_svc_url(docker_call *dcall)
Get the docker request service url.
Definition: docker_connection_util.c:608
 
void docker_call_client_cb_args_set(docker_call *dcall, void *client_cb_args)
Set the docker call client callback args.
Definition: docker_connection_util.c:491
 
int docker_call_http_code_get(docker_call *dcall)
Get the docker response HTTP code.
Definition: docker_connection_util.c:440
 
d_err_t docker_context_client_args_set(docker_context *ctx, void *client_args)
Set the client args for the docker context.
Definition: docker_connection_util.c:198
 
void * docker_call_cb_args_get(docker_call *dcall)
Get the docker call callback function callback args.
Definition: docker_connection_util.c:482
 
char * docker_call_get_url(docker_call *dcall)
Get the docker request HTTP url.
Definition: docker_connection_util.c:555
 
void * docker_call_client_cb_args_get(docker_call *dcall)
Get the docker call client callback args.
Definition: docker_connection_util.c:499
 
void * docker_context_client_args_get(docker_context *ctx)
Get the client args for the docker context.
Definition: docker_connection_util.c:207
 
int docker_call_params_add(docker_call *dcall, char *param, char *value)
Add a string key/value pair to the docker call parameters.
Definition: docker_connection_util.c:534
 
struct docker_call_t docker_call
internal datastructure representing a Docker Call object.
 
bool is_unix_socket(char *url)
Check if the given string input is a UNIX socket URL.
Definition: docker_connection_util.c:66
 
char * docker_call_request_data_get(docker_call *dcall)
Get the docker request data.
Definition: docker_connection_util.c:396
 
void docker_call_http_code_set(docker_call *dcall, int http_code)
Set the docker respose HTTP code.
Definition: docker_connection_util.c:449
 
d_err_t docker_api_init()
Definition: docker_connection_util.c:103
 
d_err_t make_docker_context_url(docker_context **ctx, const char *url)
Definition: docker_connection_util.c:119
 
void docker_call_status_cb_set(docker_call *dcall, status_callback *status_callback)
Set the docker call callback function.
Definition: docker_connection_util.c:457
 
d_err_t make_docker_call(docker_call **dcall, char *site_url, docker_object_type object, const char *id, const char *method)
Create a new generic Docker API Call object.
Definition: docker_connection_util.c:306
 
bool is_http_url(char *url)
Check if the given string input is a HTTP(s) URL.
Definition: docker_connection_util.c:54
 
enum _config_error d_err_t
Definition: docker_result.h:60
 
internal datastructure representing a Docker Call object.
Definition: docker_connection_util.h:237
 
status_callback * status_cb
the status callback method
Definition: docker_connection_util.h:264
 
docker_object_type object
docker object type enum value
Definition: docker_connection_util.h:240
 
void * cb_args
callback args for internal usage
Definition: docker_connection_util.h:265
 
coll_al_map * params
docker request parameters map
Definition: docker_connection_util.h:243
 
size_t size
used size of the storage
Definition: docker_connection_util.h:260
 
size_t flush_end
size of storage already flushed
Definition: docker_connection_util.h:261
 
size_t capacity
total capacity of internal response storage
Definition: docker_connection_util.h:259
 
int http_error_code
http response code
Definition: docker_connection_util.h:255
 
char * memory
internal memory used for response
Definition: docker_connection_util.h:258
 
void * client_cb_args
callback args provided by client
Definition: docker_connection_util.h:266
 
char * id
docker object id if applicable
Definition: docker_connection_util.h:241
 
char * content_type_header
http request content type header value
Definition: docker_connection_util.h:247
 
char * request_data
http request data
Definition: docker_connection_util.h:250
 
char * site_url
site url
Definition: docker_connection_util.h:239
 
char * request_method
http request method
Definition: docker_connection_util.h:246
 
char * method
docker api request method
Definition: docker_connection_util.h:242
 
size_t request_data_len
http request data length
Definition: docker_connection_util.h:251
 
A docker context for a specific docker server.
Definition: docker_connection_util.h:141
 
docker_result_handler_fn * result_handler_fn
Result handler for all responses.
Definition: docker_connection_util.h:144
 
void * client_args
Client args passed to callback functions.
Definition: docker_connection_util.h:145
 
char * api_version
API version expected.
Definition: docker_connection_util.h:143
 
char * url
Url of the docker server.
Definition: docker_connection_util.h:142
 
Definition: docker_result.h:93