kong

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2017 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAPI

func FindAPI(a string, list []Data) (bool, int)

FindAPI finds item in existing apis

func GetKongAdminURL

func GetKongAdminURL(namespace string) string

Types

type API

type API struct {
	Name     string `json:"name"`
	Upstream string `json:"upstream_url"`
	Hosts    string `json:"hosts"`
}

API represents the object required to create an API in Kong

type APIPluginData

type APIPluginData struct {
	ID        string `json:"id"`
	APIId     string `json:"api_id"`
	Name      string `json:"name"`
	Enabled   bool   `json:"enabled"`
	CreatedAt int    `json:"created_at"`
}

APIPluginData represents data response from /apis/{name}/plugins/

func RemovePlugin

func RemovePlugin(s []APIPluginData, id string) []APIPluginData

RemovePlugin takes an item out of the data array

type APIPlugins

type APIPlugins struct {
	Total int             `json:"total"`
	Data  []APIPluginData `json:"data"`
}

APIPlugins represents response from /apis/{name}/plugins/

type APIS

type APIS struct {
	Data  []Data `json:"data"`
	Total int    `json:"total"`
}

APIS represents a result from GET /apis

type Consumer

type Consumer struct {
	Username string `json:"username"`
	CustomID string `json:"custom_id"`
}

Consumer represents a user of the API

func RemoveConsumer

func RemoveConsumer(s []Consumer, username string) []Consumer

RemoveConsumer takes an item out of the data array

type ConsumerTPR

type ConsumerTPR struct {
	Username    string `json:"username"`
	CustomID    string `json:"custom_id"`
	MaxNumCreds int    `json:"maxNumCreds"`
}

ConsumerTPR represents a user of the API

func FindConsumer

func FindConsumer(a string, list []ConsumerTPR) (bool, ConsumerTPR)

FindConsumer finds item in existing consumers

type Consumers

type Consumers struct {
	Data  []Consumer `json:"data"`
	Total int        `json:"total"`
}

Consumers is the call to /consumers

type Data

type Data struct {
	ID                     string        `json:"id"`
	Name                   string        `json:"name"`
	CreatedAt              time.Duration `json:"created_at"`
	Hosts                  []string      `json:"hosts"`
	HTTPIfTerminated       bool          `json:"http_if_terminated"`
	HTTPSOnly              bool          `json:"https_only"`
	PreserveHost           bool          `json:"preserve_host"`
	Retries                int           `json:"retries"`
	StripURI               bool          `json:"strip_uri"`
	UpstreamConnectTimeout int           `json:"upstream_connect_timeout"`
	UpstreamReadTimeout    int           `json:"upstream_read_timeout"`
	UpstreamSendTimeout    int           `json:"upstream_send_timeout"`
	UpstreamURL            string        `json:"upstream_url"`
}

Data represents an api

func RemoveAPI

func RemoveAPI(s []Data, i int) []Data

RemoveAPI takes an item out of the data array

type JWTCred

type JWTCred struct {
	ConsumerID string `json:"consumer_id"`
	Algorithm  string `json:"algorithm"`
	CreatedAt  int    `json:"created_at"`
	ID         string `json:"id"`
	Key        string `json:"key"`
	Secret     string `json:"secret"`
}

JWTCred represents jwt cred object

type JWTCreds

type JWTCreds struct {
	Data  []JWTCred `json:"data"`
	Total int       `json:"total"`
}

JWTCreds represents jwt plugin response

type KeyCred

type KeyCred struct {
	ConsumerID string `json:"consumer_id"`
	CreatedAt  int    `json:"created_at"`
	ID         string `json:"id"`
	Key        string `json:"key"`
}

KeyCred represents jwt cred object

type KeyCreds

type KeyCreds struct {
	Data  []KeyCred `json:"data"`
	Total int       `json:"total"`
}

KeyCreds represents key auth plugin response

type Kong

type Kong struct {
	KongAdminURL string
	// contains filtered or unexported fields
}

Kong struct

func New

func New(namespace string) (*Kong, error)

New creates an instance of Kong

func (*Kong) ConsumerExists

func (k *Kong) ConsumerExists(username string) bool

ConsumerExists checks if a consumer exists already

func (*Kong) CreateAPI

func (k *Kong) CreateAPI(api Data) error

CreateAPI creates a new Kong api

func (*Kong) CreateConsumer

func (k *Kong) CreateConsumer(consumer ConsumerTPR) error

CreateConsumer creates a consumer

func (*Kong) DeleteAPI

func (k *Kong) DeleteAPI(name string) error

DeleteAPI deletes a Kong api

func (*Kong) DeleteConsumer

func (k *Kong) DeleteConsumer(consumer Consumer) error

DeleteConsumer deletes a consumer

func (*Kong) DeletePlugin

func (k *Kong) DeletePlugin(apiName, pluginID string) error

DeletePlugin deletes Kong plugin

func (*Kong) EnablePlugin

func (k *Kong) EnablePlugin(plugin Plugin)

EnablePlugin enables a plugin

func (*Kong) GetAPIs

func (k *Kong) GetAPIs() APIS

GetAPIs creates a new Kong api

func (*Kong) GetConsumers

func (k *Kong) GetConsumers() Consumers

GetConsumers gets list of consumers

func (*Kong) GetJWTPluginCreds

func (k *Kong) GetJWTPluginCreds(username string) JWTCreds

GetJWTPluginCreds gets creds for

func (*Kong) GetKeyPluginCreds

func (k *Kong) GetKeyPluginCreds(username string) KeyCreds

GetKeyPluginCreds gets creds for

func (*Kong) GetPlugins

func (k *Kong) GetPlugins() APIPlugins

GetPlugins gets list of plugins enabled by api

func (*Kong) IsPluginExisting

func (k *Kong) IsPluginExisting(plugin Plugin) (bool, APIPluginData)

IsPluginExisting determines if a plugin is already existing

func (*Kong) Ready

func (k *Kong) Ready(timeout chan bool, ready chan bool)

Ready creates a new Kong api

func (*Kong) UpdateAPI

func (k *Kong) UpdateAPI(name, upstream string, hosts []string) error

UpdateAPI creates a new Kong api

func (*Kong) UpdatePlugin

func (k *Kong) UpdatePlugin(plugin Plugin, ID string)

UpdatePlugin updates a plugin

type Plugin

type Plugin struct {
	// Name of the plugin
	Name string `json:"name"`

	// Array of config items to setup plugin
	Config map[string]string `json:"config"`

	// Apis to apply the plugin
	Apis []string `json:"apis"`

	// Consumers define what users can access the API
	Consumers []Consumer `json:"consumers"`
}

Plugin identifies a kong plugin

Jump to

Keyboard shortcuts

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