Documentation ¶
Overview ¶
Package sdc is the Sysdig Cloud API client for Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL // User agent for client. UserAgent string // Security API token. Token string // Services used for communicating with the API. Data DataService // contains filtered or unexported fields }
Client manages communication with Sysdig Cloud API.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)
NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.
type ClientOpt ¶
ClientOpt are options for New.
func SetBaseURL ¶
SetBaseURL is a client option for setting the base URL.
func SetUserAgent ¶
SetUserAgent is a client option for setting the user agent.
type DataService ¶
type DataServiceOp ¶
type DataServiceOp struct {
// contains filtered or unexported fields
}
DataServiceOp handles communication with Data methods of the Sysdig Cloud API.
func (*DataServiceOp) Get ¶
func (s *DataServiceOp) Get(ctx context.Context, gdr *GetDataRequest) (*GetDataResponse, *Response, error)
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response // Error message Message string `json:"message"` // RequestID returned from the API, useful to contact support. RequestID string `json:"request_id"` }
An ErrorResponse reports the error caused by an API request.
TODO: I made this up, it needs to be structured matching actual API responses.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type GetDataRequest ¶
type GetDataRequest struct { Metrics []Metric `json:"metrics"` DataSourceType string `json:"dataSourceType,omitempty"` Start int `json:"start,omitempty"` End int `json:"end,omitempty"` Last int `json:"last,omitempty"` Filter string `json:"filter,omitempty"` Paging string `json:"paging,omitempty"` Sampling int `json:"sampling,omitempty"` }
func (*GetDataRequest) WithFilter ¶
func (gdr *GetDataRequest) WithFilter(filter string) *GetDataRequest
func (*GetDataRequest) WithMetric ¶
func (gdr *GetDataRequest) WithMetric(id string, aggregation *MetricAggregation) *GetDataRequest
type GetDataResponse ¶
type GetDataResponse struct { // A list of time samples. Samples []TimeSample `json:"data"` Start Timestamp `json:"start"` End Timestamp `json:"end"` }
func (*GetDataResponse) FirstValue ¶
func (gdr *GetDataResponse) FirstValue() (json.RawMessage, error)
type Metric ¶
type Metric struct { ID string `json:"id"` Aggregations MetricAggregation `json:"aggregations,omitempty"` }
type MetricAggregation ¶
type MetricDefinition ¶
type MetricDefinition struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` CanMonitor bool `json:"canMonitor"` Hidden bool `json:"hidden"` GroupBy []string `json:"groupBy"` Namespaces []string `json:"namespaces"` // Possible values: // - "%" (percentage) // - "byte" // - "date" // - "double" // - "int" // - "number" // - "relativeTime" // - "string" Type string `json:"type"` // Possible values: // - "counter" // - "gauge" // - "none", e.g.: id=kubernetes.service.name // - "segmentBy", e.g.: id=host, id=port MetricType string `json:"metricType"` }
type Metrics ¶
type Metrics map[string]*MetricDefinition
type Response ¶
Response is a Sysdig Cloud response. This wraps the standard http.Response returned from Sysdig Cloud.
type TimeSample ¶
type TimeSample struct { Time Timestamp `json:"t"` Values []json.RawMessage `json:"d"` }