growthforecast

package module
v0.0.0-...-5ab68d4 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2014 License: MIT Imports: 7 Imported by: 0

README

go-growthforecast-client

Build Status

Coverage Status

GrowthForecast Client In Golang

import (
    "log"
    gf "github.com/lestrrat/go-growthforecast-client"
)

func main() {
    client := gf.NewClient("http://gf.mycompany.com")
    err := client.Post("service/section/graph", &Graph{ Number: 1 })
    if err != nil {
        log.Printf("Failed to post to GrowthForecast: %s", err)
    }
}

Auto-Generated API Docs

http://godoc.org/github.com/lestrrat/go-growthforecast-client

Documentation

Index

Constants

View Source
const (
	MODE_COUNT     string = "count"
	MODE_GAUGE            = "gauge"
	MODE_MODIFIED         = "modified"
	GMODE_GAUGE           = "gauge"
	GMODE_SUBTRACT        = "subtract"
	TYPE_AREA             = "AREA"
	TYPE_LINE1            = "LINE1"
	TYPE_LINE2            = "LINE2"
)
View Source
const (
	MODE_DEFAULT  = MODE_GAUGE
	GMODE_DEFAULT = GMODE_GAUGE
	TYPE_DEFAULT  = TYPE_AREA
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseGraph

type BaseGraph struct {
	GraphEssential
	Complex     bool   `json:"complex"`
	CreatedAt   string `json:"created_at,omitempty"`
	Description string `json:"description,omitempty"`
	Number      int    `json:"number"`
	Sort        int    `json:"sort"`
	Type        string `json:"type"`
	UpdatedAt   string `json:"updated_at,omitempty"`
}

type Client

type Client struct {
	BaseURL string
}

func NewClient

func NewClient(base string) *Client

NewClient() creates a new growthforecast.Client struct. You just need to pass it a base URL where all API endpoints will automatically be generated from.

client := growthforecast.NewClient("http://gf.mycompany.com")
g, err := client.GetGraphByPath("service/section/graph")
if err != nil {
    log.Fatalf("Error while fetching graph: %s", err)
}

// Add data to GrowthForecast!
client.Post("service/section/graph", &GraphData{ Number: 1 })

func (*Client) CreateComplex

func (self *Client) CreateComplex(graph *ComplexGraph) (*ComplexGraph, error)

func (*Client) CreateGraph

func (self *Client) CreateGraph(graph *Graph) (*Graph, error)

Sends a request to the GrowthForecast server to create a graph. Returns the new Graph created by this operation. This return value is useful to grab server generated parameters such as the grah ID.

func (*Client) GetComplex

func (self *Client) GetComplex(id int) (*ComplexGraph, error)

func (*Client) GetComplexByPath

func (self *Client) GetComplexByPath(path string) (*ComplexGraph, error)

func (*Client) GetComplexList

func (self *Client) GetComplexList() (ComplexList, error)

Fetches the list of ComplexGraphs registered in the GrowthForecast instance.

func (*Client) GetGraph

func (self *Client) GetGraph(id int) (*Graph, error)

func (*Client) GetGraphByPath

func (self *Client) GetGraphByPath(path string) (*Graph, error)

func (*Client) GetGraphList

func (self *Client) GetGraphList() (GraphList, error)

func (*Client) Post

func (self *Client) Post(path string, data *GraphData) error

type ComplexGraph

type ComplexGraph struct {
	BaseGraph
	Data  []ComplexGraphData `json:"data"`
	Sumup bool               `json:"sumup"`
}

func NewComplexGraph

func NewComplexGraph() *ComplexGraph

type ComplexGraphData

type ComplexGraphData struct {
	Gmode   string `json:"gmode"`
	Stack   bool   `json:"stack"`
	Type    string `json:"type"`
	GraphId int    `json:"graph_id"`
}

type ComplexList

type ComplexList []GraphEssential

type Graph

type Graph struct {
	BaseGraph
	Adjust    string `json:"adjust"`
	AdjustVal string `json:"adjustval"`
	Color     string `json:"color"`
	Gmode     string `json:"gmode"`
	Llimit    int    `json:"llmit"`
	MD5       string `json:"md5"`
	Meta      string `json:"meta"`
	Mode      string `json:"mode"`
	Stype     string `json:"stype"`
	Sllimit   int    `json:"sllimit"`
	Sulimit   int    `json:"sulimit"`
	Ulimit    int    `json:"ulimit"`
	Unit      string `json:"unit"`
}

func NewGraph

func NewGraph() *Graph

type GraphData

type GraphData struct {
	Number int    `json:"number"`
	Color  string `json:"color"`
	Mode   string `json:"mode"`
}

type GraphEssential

type GraphEssential struct {
	GraphName   string `json:"graph_name"`
	Id          int    `json:"id,omitempty"`
	SectionName string `json:"section_name"`
	ServiceName string `json:"service_name"`
}

func (*GraphEssential) GetPath

func (self *GraphEssential) GetPath() string

type GraphList

type GraphList []GraphEssential

Jump to

Keyboard shortcuts

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