Stats returns stats for the requested container.
(name string, request *v2.RequestOptions)
| 89 | |
| 90 | // Stats returns stats for the requested container. |
| 91 | func (c *Client) Stats(name string, request *v2.RequestOptions) (map[string]v2.ContainerInfo, error) { |
| 92 | u := c.statsURL(name) |
| 93 | ret := make(map[string]v2.ContainerInfo) |
| 94 | data := url.Values{ |
| 95 | "type": []string{request.IdType}, |
| 96 | "count": []string{strconv.Itoa(request.Count)}, |
| 97 | "recursive": []string{strconv.FormatBool(request.Recursive)}, |
| 98 | } |
| 99 | if request.MaxAge != nil { |
| 100 | data.Set("max_age", request.MaxAge.String()) |
| 101 | } |
| 102 | |
| 103 | u = fmt.Sprintf("%s?%s", u, data.Encode()) |
| 104 | if err := c.httpGetJSONData(&ret, nil, u, "stats"); err != nil { |
| 105 | return nil, err |
| 106 | } |
| 107 | return ret, nil |
| 108 | } |
| 109 | |
| 110 | func (c *Client) machineInfoURL() string { |
| 111 | return c.baseURL + path.Join("machine") |