api

package
v0.0.0-...-f62483c Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2016 License: Apache-2.0 Imports: 10 Imported by: 123

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(config Config) *Client

func (*Client) Auth

func (c *Client) Auth() error

func (*Client) Config

func (c *Client) Config() *Config

func (*Client) Delete

func (c *Client) Delete(url string, resp interface{}) error

func (*Client) Do

func (c *Client) Do(req *http.Request, ret interface{}) error

func (*Client) DoWithAuth

func (c *Client) DoWithAuth(method, url string, body, ret interface{}) error

func (*Client) Get

func (c *Client) Get(url string, resp interface{}) error

func (*Client) Patch

func (c *Client) Patch(url string, body, resp interface{}) error

func (*Client) Post

func (c *Client) Post(url string, body, resp interface{}) error

func (*Client) Put

func (c *Client) Put(url string, body, resp interface{}) error

type Config

type Config struct {
	User      User     `json:"user"`
	Alias     string   `json:"alias"`
	BaseURL   *url.URL `json:"-"`
	UserAgent string   `json:"agent,omitempty"`
}

func EnvConfig

func EnvConfig() (Config, error)

func FileConfig

func FileConfig(file string) (Config, error)

func NewConfig

func NewConfig(username, password string) (Config, error)

NewConfig takes credentials and returns a Config object that may be further customized. Defaults for Alias, BaseURL, and UserAgent will be taken from respective env vars.

func (Config) Valid

func (c Config) Valid() bool

type Customfields

type Customfields struct {
	ID           string `json:"id,omitempty"`
	Name         string `json:"name,omitempty"`
	Value        string `json:"value,omitempty"`
	Displayvalue string `json:"displayValue,omitempty"`
}

type HTTP

type HTTP interface {
	Get(url string, resp interface{}) error
	Post(url string, body, resp interface{}) error
	Put(url string, body, resp interface{}) error
	Patch(url string, body, resp interface{}) error
	Delete(url string, resp interface{}) error
	Config() *Config
}
type Link struct {
	Rel   string   `json:"rel,omitempty"`
	Href  string   `json:"href,omitempty"`
	ID    string   `json:"id,omitempty"`
	Name  string   `json:"name,omitempty"`
	Verbs []string `json:"verbs,omitempty"`
}
type Links []Link

func (Links) GetID

func (l Links) GetID(rel string) (bool, string)
func (l Links) GetLink(rel string) (bool, *Link)

type Token

type Token struct {
	Username string   `json:"userName"`
	Alias    string   `json:"accountAlias"`
	Location string   `json:"locationAlias"`
	Roles    []string `json:"roles"`
	Token    string   `json:"bearerToken"`
}

func (Token) Valid

func (t Token) Valid() bool

TODO: Add some real validation logic

type Update

type Update struct {
	Op     string      `json:"op"`
	Member string      `json:"member"`
	Value  interface{} `json:"value"`
}

type User

type User struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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