api

package
v0.0.0-...-921a2ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2014 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDockerAPIVersion = "1.13"
	DefaultTimeoutSeconds   = 60
	StreamHeaderSizeBytes   = 8
)
View Source
const (
	Images     = 1
	Containers = 2
	Misc       = 3
)

modules

Variables

View Source
var InsertFileAPI = ModuleAPI{
	Module:  Images,
	Version: []string{"1.11", "1.12"},
	ReqUrl:  "/images/%s/insert",

	ResType: "application/json",
	ReqType: "",
	Method:  "post",
}
View Source
var InspectImageAPI = ModuleAPI{
	Module:  Images,
	Version: []string{"1.11", "1.12", "1.13"},
	ReqUrl:  "/images/%s/json",

	ResType: "application/json",
	ReqType: "",
	Method:  "get",
}
View Source
var ListImagesAPI = ModuleAPI{
	Module:  Images,
	Version: []string{"1.11", "1.12", "1.13"},
	ReqUrl:  "/images/json",

	ResType: "application/json",
	ReqType: "",
	Method:  "get",
}

Functions

func GetGeneralStatusError

func GetGeneralStatusError(code int, module int) (res string)

func ParseStruct2Json

func ParseStruct2Json(opts interface{}) (string, error)

Struct to JSON

func ParseStruct2MultiMap

func ParseStruct2MultiMap(opts interface{}) map[string][]string

Struct to Multi-value Map

func ParseStruct2QueryString

func ParseStruct2QueryString(opts interface{}) string

Struct to query string

Types

type APIError

type APIError struct {
	ErrorMessage string
	StatusCode   int
	Explanation  string
}

func (APIError) Error

func (err APIError) Error() string

func (APIError) IsClientError

func (err APIError) IsClientError() bool

func (APIError) IsServerError

func (err APIError) IsServerError() bool

type DClient

type DClient struct {
	// contains filtered or unexported fields
}

func NewDClient

func NewDClient(endpoint, version string, timeout int) (*DClient, error)

create a new DClient with the given endpoint and version, with additional timeout param

func (*DClient) Do

func (client *DClient) Do(module ModuleAPI, param interface{}, urlParam string) (str_result []byte, err error)

param for ?param urlParam for /path/%s/..../ I checkout the docker's doc, I found url only require one param, so I make this args... silly but useful : )

func (*DClient) InspectImage

func (client *DClient) InspectImage(name string, image *InspectImageAPI_Resp) (err error)

func (*DClient) ListImages

func (client *DClient) ListImages(param ListImagesAPI_Query, images *[]ListImagesAPI_Resp) (err error)

func (*DClient) Ping

func (c *DClient) Ping() (bool, error)

Ping

type InspectImageAPI_Resp

type InspectImageAPI_Resp struct {
	Created         string
	Container       string
	ContainerConfig struct {
		Hostname     string
		User         string
		Memory       int
		MemorySwap   int
		AttachStdin  bool
		AttachStdout bool
		AttachStderr bool
		PortSpecs    string
		Tty          bool
		OpenStdin    bool
		StdinOnce    bool
		Env          []string
		Cmd          []string
		Dns          []string
		Image        string
		Volumes      []string
		VolumesFrom  string
		WorkingDir   string
	}
	Id     string
	Parent string
	Size   int
}

type ListImagesAPI_Query

type ListImagesAPI_Query struct {
	All     bool                `json:"all"`
	Filters map[string][]string `json:"filters,omitempty"`
}

type ListImagesAPI_Resp

type ListImagesAPI_Resp struct {
	ID          string   `json:"Id"`
	RepoTags    []string `json:",omitempty"`
	Created     int64
	Size        int64
	VirtualSize int64
	ParentId    string `json:",omitempty"`
	Repository  string `json:",omitempty"`
	Tag         string `json:",omitempty"`
}

type ModuleAPI

type ModuleAPI struct {
	Module  int      //	container | images | misc
	Version []string // supported version ["1.11","1.12"]
	ReqUrl  string   // path for API /images/%s/insert

	ResType string // application/json  or  application/vnd.docker.raw-stream  or  application/octet-stream  or  nothing
	ReqType string // application/json  or  nothing
	Method  string //get post delete
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址