models

package
v0.0.0-...-6de1e96 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2016 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB()

func FindBy

func FindBy(col string, field []interface{}, val interface{}, limit int) map[int]map[string]interface{}

func FindByID

func FindByID(col string, id int) map[string]interface{}

func InitDB

func InitDB(DBDir string)

Types

type Api

type Api struct {
	Name     string   `json:"name"`
	Route    string   `json:"route"`
	Backends []string `json:"backends"`
	Groups   []string `json:"groups"`
	// contains filtered or unexported fields
}

func FindAllApis

func FindAllApis() []*Api

FindAllApis returns all apis

func FindApiBy

func FindApiBy(field string, value string) *Api

FindApiBy returns api matching provided field->value

func FindApiByID

func FindApiByID(id int) *Api

FindApiByID returns api by ID

func GetApiFromInterface

func GetApiFromInterface(id int, a map[string]interface{}) *Api

GetApiFromInterface converts an map[string]interface{} (from tiedot) to a api struct

func NewApi

func NewApi(name, route string, backends []string) (*Api, error)

NewApi returns a new Api. It checks if given route or name are already used.

func (*Api) Delete

func (a *Api) Delete() error

Delete removes api from database

func (*Api) Save

func (a *Api) Save() (int, error)

Save saves api in database

func (*Api) UpdateFromForm

func (a *Api) UpdateFromForm(form map[string][]string)

UpdateFromForm update api from form values

type Consumer

type Consumer struct {
	Username  string         `json:"username"`
	ApiKey    string         `json:"apikey"`
	RateLimit map[string]int `json:"ratelimit"`
	Groups    []string       `json:"groups"`
	// contains filtered or unexported fields
}

func FindAllConsumers

func FindAllConsumers() []*Consumer

FindAllConsumers returns all consumers

func FindConsumerBy

func FindConsumerBy(field string, value string) *Consumer

FindConsumerBy returns consumer matching provided field->value

func FindConsumerByID

func FindConsumerByID(id int) *Consumer

func GetConsumerFromInterface

func GetConsumerFromInterface(id int, c map[string]interface{}) *Consumer

GetConsumerFromInterface converts an map[string]interface{} (from tiedot) to a Consumer struct

func NewConsumer

func NewConsumer(username, apiKey string) (*Consumer, error)

NewConsumer creates new consumer. It generates an apikey if none is given.

func (*Consumer) Delete

func (c *Consumer) Delete() error

Delete removes consumer from database

func (*Consumer) GetId

func (c *Consumer) GetId() int

func (*Consumer) Save

func (c *Consumer) Save() (int, error)

Save consumer in database Insert a new document if the id == 0

func (*Consumer) UpdateFromForm

func (c *Consumer) UpdateFromForm(form map[string][]string)

UpdateFromForm update consumer from form values

Jump to

Keyboard shortcuts

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