client

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

Example REST API Client

This is an implementation of a cAdvisor REST API in Go. You can use it like this:

client, err := client.NewClient("http://192.168.59.103:8080/")

Obviously, replace the URL with the path to your actual cAdvisor REST endpoint.

MachineInfo
client.MachineInfo()

This method returns a cadvisor/v1.MachineInfo struct with all the fields filled in. Here is an example return value:

(*v1.MachineInfo)(0xc208022b10)({
 NumCores: (int) 4,
 MemoryCapacity: (int64) 2106028032,
 Filesystems: ([]v1.FsInfo) (len=1 cap=4) {
  (v1.FsInfo) {
   Device: (string) (len=9) "/dev/sda1",
   Capacity: (uint64) 19507089408
  }
 }
})

You can see the full specification of the MachineInfo struct in the source

ContainerInfo

Given a container name and a ContainerInfoRequest, will return all information about the specified container. See the ContainerInfoRequest struct in the source for the full specification.

request := v1.ContainerInfoRequest{NumStats: 10}
sInfo, err := client.ContainerInfo("/docker/d9d3eb10179e6f93a...", &request)

Returns a ContainerInfo struct

SubcontainersInfo

Given a container name and a ContainerInfoRequest, will recursively return all info about the container and all subcontainers contained within the container. See the ContainerInfoRequest struct in the source for the full specification.

request := v1.ContainerInfoRequest{NumStats: 10}
sInfo, err := client.SubcontainersInfo("/docker", &request)

Returns a ContainerInfo struct with the Subcontainers field populated.

Documentation

Overview

This is an implementation of a cAdvisor REST API in Go. To use it, create a client (replace the URL with your actual cAdvisor REST endpoint):

client, err := client.NewClient("http://192.168.59.103:8080/")

Then, the client interface exposes go methods corresponding to the REST endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents the base URL for a cAdvisor client.

func NewClient

func NewClient(url string) (*Client, error)

NewClient returns a new v1.3 client with the specified base URL.

func NewClientWithTimeout added in v0.26.0

func NewClientWithTimeout(url string, timeout time.Duration) (*Client, error)

NewClientWithTimeout returns a new v1.3 client with the specified base URL and http client timeout.

func (*Client) AllDockerContainers

func (self *Client) AllDockerContainers(query *v1.ContainerInfoRequest) (cinfo []v1.ContainerInfo, err error)

Returns the JSON container information for all Docker containers.

func (*Client) ContainerInfo

func (self *Client) ContainerInfo(name string, query *v1.ContainerInfoRequest) (cinfo *v1.ContainerInfo, err error)

ContainerInfo returns the JSON container information for the specified container and request.

func (*Client) DockerContainer

func (self *Client) DockerContainer(name string, query *v1.ContainerInfoRequest) (cinfo v1.ContainerInfo, err error)

Returns the JSON container information for the specified Docker container and request.

func (*Client) EventStaticInfo

func (self *Client) EventStaticInfo(name string) (einfo []*v1.Event, err error)

Returns all past events that satisfy the request

func (*Client) EventStreamingInfo

func (self *Client) EventStreamingInfo(name string, einfo chan *v1.Event) (err error)

Streams all events that occur that satisfy the request into the channel that is passed

func (*Client) MachineInfo

func (self *Client) MachineInfo() (minfo *v1.MachineInfo, err error)

MachineInfo returns the JSON machine information for this client. A non-nil error result indicates a problem with obtaining the JSON machine information data.

func (*Client) SubcontainersInfo

func (self *Client) SubcontainersInfo(name string, query *v1.ContainerInfoRequest) ([]v1.ContainerInfo, error)

Returns the information about all subcontainers (recursive) of the specified container (including itself).

Directories

Path Synopsis
Client library to programmatically access cAdvisor API.
Client library to programmatically access cAdvisor API.

Jump to

Keyboard shortcuts

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