clibdocker  0.1.0-alpha.0
A Docker API for C
Macros | Typedefs | Functions
docker_volumes.h File Reference

Docker volumes API. More...

#include <stdlib.h>
#include "docker_connection_util.h"
#include "docker_util.h"
Include dependency graph for docker_volumes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define free_docker_volume(vol)   json_object_put((json_object*) vol)
 free the docker volume object
 
#define docker_volume_name_get(vol)   get_attr_str((json_object*)vol, "Name")
 Get the name of the docker volume. More...
 
#define docker_volume_driver_get(vol)   get_attr_str((json_object*)vol, "Driver")
 Get the driver name of the docker volume. More...
 
#define docker_volume_mountpoint_vol_get(vol)   get_attr_str((json_object*)vol, "Mountpoint")
 Get the mount point of the docker volume. More...
 
#define docker_volume_go_scope_get(vol)   get_attr_str((json_object*)vol, "Scope")
 Get the scope of the docker volume. More...
 
#define docker_volume_creation_time_get(vol)   get_attr_time((json_object*)vol, "CreatedAt")
 Get the creation time of the docker volume. More...
 
#define docker_volume_labels_get(vol)   get_attr_json_object((json_object*)vol, "Labels")
 Get the volume labels array of the docker volume. More...
 
#define docker_volume_labels_foreach(vol)   json_object_object_foreach(docker_volume_labels_get(vol), key, val)
 Iterate over the volume labels with key and val. More...
 
#define docker_volume_options_get(vol)   get_attr_json_object((json_object*)vol, "Options")
 Get the options array of the docker volume. More...
 
#define docker_volume_options_foreach(vol)   json_object_object_foreach(docker_volume_options_get(vol), key, val)
 Iterate over the volume options with key and val. More...
 
#define free_docker_volume_list(volume_ls)   json_object_put(volume_ls)
 Free the docker volume list json object. More...
 
#define docker_volume_list_length(volume_ls)   json_object_array_length(volume_ls)
 Get the length of the docker volume list. More...
 
#define docker_volume_list_get_idx(volume_ls, i)   (docker_volume*) json_object_array_get_idx(volume_ls, i)
 Get the ith value of the docker volume list. More...
 
#define free_docker_warnings(warnings)   json_object_put(warnings)
 Free the docker warnings list. More...
 
#define docker_warnings_length(warnings)   json_object_array_length(warnings)
 Get the length of the docker volume warnings list. More...
 
#define docker_warnings_get_idx(warnings, i)   (char*) json_object_array_get_idx(warnings, i)
 Get the ith warning. More...
 

Typedefs

typedef json_object docker_volume
 The Docker Volume object. More...
 
typedef json_object docker_volume_list
 Represents Docker Volume List in json.
 
typedef json_object docker_volume_warnings
 The Docker Volume Warnings list json object. More...
 

Functions

d_err_t docker_volumes_list (docker_context *ctx, docker_volume_list **volumes, docker_volume_warnings **warnings, int filter_dangling, char *filter_driver, char *filter_label, char *filter_name)
 
d_err_t docker_volume_create (docker_context *ctx, docker_volume **volume, char *name, char *driver, int num_labels,...)
 
d_err_t docker_volume_inspect (docker_context *ctx, docker_volume **volume, char *name)
 
d_err_t docker_volume_delete (docker_context *ctx, const char *name, int force)
 
d_err_t docker_volumes_delete_unused (docker_context *ctx, arraylist **volumes_deleted, unsigned long *space_reclaimed, int num_label_filters,...)
 

Detailed Description

Docker volumes API.

Macro Definition Documentation

◆ docker_volume_creation_time_get

#define docker_volume_creation_time_get (   vol)    get_attr_time((json_object*)vol, "CreatedAt")

Get the creation time of the docker volume.

Parameters
voldocker volume
Returns
time_t creation time of the volume

◆ docker_volume_driver_get

#define docker_volume_driver_get (   vol)    get_attr_str((json_object*)vol, "Driver")

Get the driver name of the docker volume.

Parameters
voldocker volume
Returns
char* driver name of the volume

◆ docker_volume_go_scope_get

#define docker_volume_go_scope_get (   vol)    get_attr_str((json_object*)vol, "Scope")

Get the scope of the docker volume.

For possible values of scope refer to the docker api docs.

Parameters
voldocker volume
Returns
char* scope of the volume

◆ docker_volume_labels_foreach

#define docker_volume_labels_foreach (   vol)    json_object_object_foreach(docker_volume_labels_get(vol), key, val)

Iterate over the volume labels with key and val.

Iterate over every label, in every iteration, the key and val store the id and value of the label.

Parameters
voldocker volume

◆ docker_volume_labels_get

#define docker_volume_labels_get (   vol)    get_attr_json_object((json_object*)vol, "Labels")

Get the volume labels array of the docker volume.

The better was to get the volume labels is to use the helper funcitons for iteration over the volume labels.

Parameters
voldocker volume
Returns
json_object* labels of the volume

◆ docker_volume_list_get_idx

#define docker_volume_list_get_idx (   volume_ls,
 
)    (docker_volume*) json_object_array_get_idx(volume_ls, i)

Get the ith value of the docker volume list.

Parameters
volume_lsthe volume list object
iindex
Returns
docker_volume* ith volume

◆ docker_volume_list_length

#define docker_volume_list_length (   volume_ls)    json_object_array_length(volume_ls)

Get the length of the docker volume list.

Parameters
volume_lsthe volume list object
Returns
size_t length of the volume list

◆ docker_volume_mountpoint_vol_get

#define docker_volume_mountpoint_vol_get (   vol)    get_attr_str((json_object*)vol, "Mountpoint")

Get the mount point of the docker volume.

Parameters
voldocker volume
Returns
char* mount point of the volume

◆ docker_volume_name_get

#define docker_volume_name_get (   vol)    get_attr_str((json_object*)vol, "Name")

Get the name of the docker volume.

Parameters
voldocker volume
Returns
char* name of the volume

◆ docker_volume_options_foreach

#define docker_volume_options_foreach (   vol)    json_object_object_foreach(docker_volume_options_get(vol), key, val)

Iterate over the volume options with key and val.

Iterate over every option, in every iteration, the key and val store the id and value of the option.

Parameters
voldocker volume

◆ docker_volume_options_get

#define docker_volume_options_get (   vol)    get_attr_json_object((json_object*)vol, "Options")

Get the options array of the docker volume.

The better was to get the volume options is to use the helper funcitons for iteration over the volume options.

Parameters
voldocker volume
Returns
json_object* options of the volume

◆ docker_warnings_get_idx

#define docker_warnings_get_idx (   warnings,
 
)    (char*) json_object_array_get_idx(warnings, i)

Get the ith warning.

Parameters
warningsdocker volume warnings list
iindex
Returns
char* ith warning

◆ docker_warnings_length

#define docker_warnings_length (   warnings)    json_object_array_length(warnings)

Get the length of the docker volume warnings list.

Parameters
warningsdocker volume warnings list
Returns
size_t volume warnings list length

◆ free_docker_volume_list

#define free_docker_volume_list (   volume_ls)    json_object_put(volume_ls)

Free the docker volume list json object.

Parameters
volume_lsthe volume list object

◆ free_docker_warnings

#define free_docker_warnings (   warnings)    json_object_put(warnings)

Free the docker warnings list.

Parameters
warningsdocker volume warnings list

Typedef Documentation

◆ docker_volume

typedef json_object docker_volume

The Docker Volume object.

The docker volume object represents the JSON object, returned as part of a Docker API call.

To access members of the object use the getters of the form docker_volume_<member>_get(vol), where vol is the pointer to the volume object.

◆ docker_volume_warnings

typedef json_object docker_volume_warnings

The Docker Volume Warnings list json object.

Each warning is a string.

Function Documentation

◆ docker_volume_create()

d_err_t docker_volume_create ( docker_context ctx,
docker_volume **  volume,
char *  name,
char *  driver,
int  num_labels,
  ... 
)

Create a new volume by providing name, driver and an optional list of key/value pairs for labels

Parameters
ctxthe docker context
volumethe volume object to return
namename of the volume to create (cannot be NULL)
drivername of the driver to use
num_labelsthe number of labels to be attached.
...key/values char* key, char* value args pair for each label
Returns
error code

References docker_log_debug, make_docker_call(), and docker_context_t::url.

◆ docker_volume_delete()

d_err_t docker_volume_delete ( docker_context ctx,
const char *  name,
int  force 
)

Delete the given volume (identified by name).

Parameters
ctxthe docker context
namename of the volume to delete
forceforce delete if this value is 1
Returns
error code

References make_docker_call(), and docker_context_t::url.

◆ docker_volume_inspect()

d_err_t docker_volume_inspect ( docker_context ctx,
docker_volume **  volume,
char *  name 
)

Inspect an existing volume.

Parameters
ctxthe docker context
volumethe volume object to return
namename of the volume to inspect (cannot be NULL)
Returns
error code

◆ docker_volumes_delete_unused()

d_err_t docker_volumes_delete_unused ( docker_context ctx,
arraylist **  volumes_deleted,
unsigned long *  space_reclaimed,
int  num_label_filters,
  ... 
)

Delete unused volumes.

Parameters
ctxthe docker context
volumes_deletedarray_list with names of volumes deleted
space_reclaimednum bytes freed.
num_label_filtershow many label filters are there
...triples (int filter_not, char* label_name, char* label_value)
Returns
error code

References make_docker_call(), and docker_context_t::url.

◆ docker_volumes_list()

d_err_t docker_volumes_list ( docker_context ctx,
docker_volume_list **  volumes,
docker_volume_warnings **  warnings,
int  filter_dangling,
char *  filter_driver,
char *  filter_label,
char *  filter_name 
)

Get the list of volumes, matching the filters provided. (Any and all filters can be null/0.)

Parameters
ctxthe docker context
volumesthe list of docker_volume_item objects
warningsthe list of warnings
filter_dangling0 indicates false, anything else is true
filter_driverdriver filter
filter_labelfilter label
filter_namefilter name
Returns
error code.

References make_docker_call(), and docker_context_t::url.