github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/client/checkpoint_list.go (about)

     1  package client
     2  
     3  import (
     4  	"encoding/json"
     5  	"net/http"
     6  	"net/url"
     7  
     8  	"github.com/docker/docker/api/types"
     9  	"golang.org/x/net/context"
    10  )
    11  
    12  // CheckpointList returns the checkpoints of the given container in the docker host
    13  func (cli *Client) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
    14  	var checkpoints []types.Checkpoint
    15  
    16  	query := url.Values{}
    17  	if options.CheckpointDir != "" {
    18  		query.Set("dir", options.CheckpointDir)
    19  	}
    20  
    21  	resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil)
    22  	if err != nil {
    23  		if resp.statusCode == http.StatusNotFound {
    24  			return checkpoints, containerNotFoundError{container}
    25  		}
    26  		return checkpoints, err
    27  	}
    28  
    29  	err = json.NewDecoder(resp.body).Decode(&checkpoints)
    30  	ensureReaderClosed(resp)
    31  	return checkpoints, err
    32  }