api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RxAPIKey is the regexp a valid API key should match.
	RxAPIKey = regexp.MustCompile("^[A-Za-z0-9]{22}$")

	// RxServer is the regexp a valid server name should match.
	RxServer = regexp.MustCompile("^[A-Za-z0-9_.-]{1,64}$")
)

Functions

This section is empty.

Types

type ReqQuick

type ReqQuick struct {
	Data pgmetrics.Model `json:"data"`
}

ReqQuick is the request structure for RestV1.Quick.

func (*ReqQuick) IsValid

func (r *ReqQuick) IsValid() bool

IsValid returns true if this the fields in this object look valid.

type ReqReport added in v1.1.0

type ReqReport struct {
	APIKey string          `json:"apikey"`
	Server string          `json:"server"`
	Data   pgmetrics.Model `json:"data"`
}

ReqReport is the request structure for RestV1.Report.

func (*ReqReport) IsValid added in v1.1.0

func (r *ReqReport) IsValid() bool

IsValid returns true if this the fields in this object look valid.

type RespQuick

type RespQuick struct {
	URL  string `json:"url"`
	Code string `json:"code"`
}

RespQuick is the response structure for RestV1.Quick.

type RespReport added in v1.1.0

type RespReport struct {
}

RespReport is the response structure for RestV1.Report.

type RestV1

type RestV1 interface {
	Quick(ctx context.Context, req ReqQuick) (resp RespQuick, code int)
	Report(ctx context.Context, req ReqReport) (resp RespReport, code int)
}

RestV1 is the interface definition of the public REST API, v1.

type RestV1Client

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

RestV1Client is a client for RestV1 servers.

func NewRestV1Client

func NewRestV1Client(base string, timeout time.Duration, retries int) *RestV1Client

NewRestV1Client creates a new client to talk to the specified base URL and with the given timeout.

func (*RestV1Client) Quick

func (c *RestV1Client) Quick(req ReqQuick) (resp RespQuick, err error)

Quick calls RestV1.Quick

func (*RestV1Client) Report added in v1.1.0

func (c *RestV1Client) Report(req ReqReport) (resp RespReport, err error)

Report calls RestV1.Report

type RestV1ClientError added in v1.1.0

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

RestV1ClientError represents errors because of non-2xx HTTP response code.

func (*RestV1ClientError) Code added in v1.1.0

func (e *RestV1ClientError) Code() int

Code returns the HTTP response status code.

func (*RestV1ClientError) Error added in v1.1.0

func (e *RestV1ClientError) Error() string

Error returns a human-readable error message.

Jump to

Keyboard shortcuts

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