kong

package module
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MIT Imports: 8 Imported by: 0

README

marathon

Go Quality Report GoDoc

Library to manage Kong servers via API Calls

Getting started

  • API documentation is available via godoc.
  • Test code contains some small examples of the use of this library.

Installation

To install Kong package, you need to install Go and set your Go workspace first.

1 - The first need Go installed (version 1.13+ is required). Then you can use the below Go command to install Kong

$ go get -u github.com/dotWicho/kong

And then Import it in your code:

package main

import "github.com/dotWicho/kong"

Or

2 - Use as module in you project (go.mod file):

module myclient

go 1.13

require (
	github.com/dotWicho/kong v1.2.9
)

Contributing

Documentation

Index

Constants

View Source
const (
	// StatusURI is a Kong server status endpoint
	StatusURI string = "/status"
	// ServicesURI is a Kong server service endpoint on Kong version >= 0.13.x
	ServicesURI string = "/services"
	// RoutesURI is a Kong server routes endpoint on Kong version >= 0.13.x
	RoutesURI string = "/routes"
	// ApisURI is a Kong server apis endpoint on Kong version < 0.13.x
	ApisURI string = "/apis"
	// ConsumerURI is a Kong server consumer Key-Auth endpoint
	ConsumerURI string = "/consumer"
	// ConsumersURI is a Kong server consumers endpoint
	ConsumersURI string = "/consumers"
	// PluginsURI is a Kong server plugins endpoint
	PluginsURI string = "/plugins"
	// AclsURI is a Kong server plugins acls endpoint
	AclsURI string = "/acls"
	// KeyAuthURI is a Kong server key-auth consumers endpoint
	KeyAuthURI string = "key-auth"
	// KeyAuthsURI is a Kong server (>= v1.1.2) endpoint for GetConsumerByKey
	KeyAuthsURI string = "/key-auths"
	// RequestSize max request size
	RequestSize string = "1000"
)
View Source
const (
	Basic   Authentication = "basic-auth"
	JWT                    = "jwt"
	HMAC                   = "hmac-auth"
	KeyAuth                = "key-auth"
	LDAP                   = "ldap-auth"
	OAuth                  = "oauth2"
	Session                = "session"
)

Authentication enum datatype

Variables

Logger default

Functions

This section is empty.

Types

type ACL added in v1.3.4

type ACL struct {
	ID        string      `json:"id,omitempty"`
	Consumer  interface{} `json:"consumer,omitempty"`
	CreatedAt int64       `json:"created_at,omitempty"`
	Group     string      `json:"group,omitempty"`
	Tags      []string    `json:"tags,omitempty"`
}

ACL holds groups information of a consumer

type ACLBody added in v1.2.5

type ACLBody struct {
	HideGroupsHeader bool     `json:"hide_groups_header,omitempty"`
	Blacklist        []string `json:"blacklist,omitempty"`
	Whitelist        []string `json:"whitelist,omitempty"`
}

ACLBody holds config for acl plugin

type ACLConfig added in v1.2.0

type ACLConfig struct {
	HideGroupsHeader bool     `json:"hide_groups_header,omitempty"`
	Blacklist        []string `json:"blacklist,omitempty"`
	Whitelist        []string `json:"whitelist,omitempty"`
}

ACLConfig holds config for acl plugin

type ACLConsumer added in v1.3.4

type ACLConsumer struct {
	Data []ACL  `json:"data,omitempty"`
	Next string `json:"next,omitempty"`
}

ACLConsumer holds config for acls of a consumer

type API added in v1.2.9

type API struct {
	ID           string `json:"id,omitempty"`
	Name         string `json:"name,omitempty"`
	RequestPath  string `json:"request_path,omitempty"`
	Upstream     string `json:"upstream_url,omitempty"`
	StripPath    bool   `json:"strip_request_path,omitempty"`
	PreserveHost bool   `json:"preserve_host,omitempty"`
	Created      int64  `json:"created_at,omitempty"`
}

API representation

type APIList added in v1.2.9

type APIList struct {
	Data  []API  `json:"data,omitempty"`
	Next  string `json:"next,omitempty"`
	Total int    `json:"total,omitempty"`
}

APIList holds a list of Kong API

type Apis added in v1.2.0

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

Apis implements ApisOperations interface{}

func NewApis added in v1.2.0

func NewApis(kong *Client) *Apis

NewApis returns Apis implementation

func (*Apis) AsMap added in v1.2.0

func (ka *Apis) AsMap() map[string]API

AsMap returns all Apis defined as a map

func (*Apis) AsRaw added in v1.2.1

func (ka *Apis) AsRaw() *API

AsRaw returns the current API

func (*Apis) Create added in v1.2.0

func (ka *Apis) Create(body API) *Apis

Create create an api

func (*Apis) Delete added in v1.2.0

func (ka *Apis) Delete(id string) error

Delete delete a given api

func (*Apis) Error added in v1.3.0

func (ka *Apis) Error() error

Error returns the current error if any

func (*Apis) Exist added in v1.2.0

func (ka *Apis) Exist(id string) bool

Exist checks if given api exist

func (*Apis) Get added in v1.2.0

func (ka *Apis) Get(id string) *Apis

Get returns a non nil API is exist

func (*Apis) GetACL added in v1.2.9

func (ka *Apis) GetACL() []string

GetACL returns context of a whitelist

func (*Apis) Plugins added in v1.2.0

func (ka *Apis) Plugins() map[string]Plugin

Plugins returns plugins for a given api

func (*Apis) Purge added in v1.2.0

func (ka *Apis) Purge() error

Purge flush all apis from Kong server

func (*Apis) RemoveAuthentication added in v1.2.0

func (ka *Apis) RemoveAuthentication(auth Authentication) error

RemoveAuthentication delete an entry on apis plugins with type provided

func (*Apis) RevokeACL added in v1.2.9

func (ka *Apis) RevokeACL(group string) error

RevokeACL delete an entry on apis plugins of type acl

func (*Apis) SetACL added in v1.2.9

func (ka *Apis) SetACL(groups []string) error

SetACL creates an entry on apis plugins of type acl

func (*Apis) SetAuthentication added in v1.2.0

func (ka *Apis) SetAuthentication(auth Authentication) error

SetAuthentication creates an entry on apis plugins with type provided

func (*Apis) Update added in v1.2.0

func (ka *Apis) Update(body API) *Apis

Update update a given api

type ApisOperations added in v1.2.5

type ApisOperations interface {
	Get(id string) *Apis
	Exist(id string) bool
	Create(body API) *Apis
	Update(body API) *Apis
	Delete(id string) error
	Purge() error

	Plugins() map[string]Plugin

	GetACL() []string
	SetACL(groups []string) error
	RevokeACL(group string) error
	SetAuthentication(auth Authentication) error
	RemoveAuthentication(auth Authentication) error

	AsMap() map[string]API
	AsRaw() *API

	Error() error
}

ApisOperations interface holds Kong Apis Methods

type Authentication added in v1.2.0

type Authentication string

Authentication just and alias for string to make an enum datatype

type BasicAuthentication added in v1.2.5

type BasicAuthentication struct {
	HideCredentials bool `json:"hide_credentials,omitempty"`
	Anonymous       bool `json:"anonymous,omitempty"`
}

BasicAuthentication represents config for simple username:password authentication

type BasicKeyAuth

type BasicKeyAuth struct {
	Data  []KeyAuthData `json:"data,omitempty"`
	Total int           `json:"total,omitempty"`
}

BasicKeyAuth holds responses when getting all basic auths for a consumer

type Client

type Client struct {
	Session *requist.Requist

	Info   *ClusterInfo
	Status *ClusterStatus

	Auth        string
	KongVersion int
	URL         string
	// contains filtered or unexported fields
}

Client Abstraction, implements all base operations against a Kong's server via a Requist instance

func New added in v1.0.9

func New(base string) *Client

New returns a new Client given a Kong server base url

func NewFromURL added in v1.0.9

func NewFromURL(base *url.URL) *Client

NewFromURL returns a new Client given a Kong server base url in url/URL type

func (*Client) CheckConnection

func (k *Client) CheckConnection() error

CheckConnection check for a valid connection against a Kong server

func (*Client) CheckStatus

func (k *Client) CheckStatus() (map[string]int, error)

CheckStatus returns some metrics from KongAPI server

func (*Client) DatabaseReachable added in v1.2.0

func (k *Client) DatabaseReachable() bool

DatabaseReachable returns availability of database of Kong API server

func (*Client) Hostname added in v1.2.0

func (k *Client) Hostname() string

Hostname returns the hostname of Kong API server

func (*Client) LuaVersion added in v1.2.0

func (k *Client) LuaVersion() string

LuaVersion returns version of LUA on Kong API server

func (*Client) New added in v1.0.9

func (k *Client) New(base *url.URL) *Client

New return a copy of Client changing just a base url

func (*Client) NodeID added in v1.2.0

func (k *Client) NodeID() string

NodeID returns node_id of Kong API server

func (*Client) SetBasicAuth

func (k *Client) SetBasicAuth(username, password string)

SetBasicAuth update user and pass

func (*Client) StatusCode

func (k *Client) StatusCode() int

StatusCode returns result code from last request

func (*Client) Version added in v1.2.0

func (k *Client) Version() string

Version returns version of Kong API server

type ClientCertificate

type ClientCertificate struct {
	ID string `json:"id,omitempty"`
}

ClientCertificate just hold client_certificate.id

type ClientOperations added in v1.2.5

type ClientOperations interface {
	New(base *url.URL) *Client
	StatusCode() int
	CheckConnection() error
	CheckStatus() (map[string]int, error)
	SetBasicAuth(username, password string)

	Version() string
	LuaVersion() string
	Hostname() string
	// contains filtered or unexported methods
}

ClientOperations interface define all Kong Methods

type ClusterInfo added in v1.2.0

type ClusterInfo struct {
	Configuration struct {
		AdminIP                string               `json:"admin_ip,omitempty"`
		AdminAccLogs           string               `json:"admin_acc_logs,omitempty"`
		AdminAccessLog         string               `json:"admin_access_log,omitempty"`
		AdminErrorLog          string               `json:"admin_error_log,omitempty"`
		AdminListen            interface{}          `json:"admin_listen,omitempty"`
		AdminListeners         []ListenerDefinition `json:"admin_listeners,omitempty"`
		AdminListenSsl         interface{}          `json:"admin_listen_ssl,omitempty"`
		AdminSslCertDefault    string               `json:"admin_ssl_cert_default,omitempty"`
		AdminSslCertKeyDefault string               `json:"admin_ssl_cert_key_default,omitempty"`
		AdminSslEnabled        bool                 `json:"admin_ssl_enabled,omitempty"`
		AdminPort              int                  `json:"admin_port,omitempty"`
		AnonymousReports       bool                 `json:"anonymous_reports,omitempty"`
		CassandraConsistency   string               `json:"cassandra_consistency,omitempty"`
		CassandraContactPoints []string             `json:"cassandra_contact_points,omitempty"`
		CassandraDataCenters   []string             `json:"cassandra_data_centers,omitempty"`
		CassandraKeyspace      string               `json:"cassandra_keyspace,omitempty"`
		CassandraPort          int                  `json:"cassandra_port,omitempty"`
		CassandraUsername      string               `json:"cassandra_username,omitempty"`
		ClusterControlPlane    string               `json:"cluster_control_plane,omitempty"`
		ClusterListen          interface{}          `json:"cluster_listen,omitempty"`
		ClusterListeners       []ListenerDefinition `json:"cluster_listeners,omitempty"`
		Database               string               `json:"database,omitempty"`
		KongEnv                string               `json:"kong_env,omitempty"`
		LoadedPlugins          map[string]bool      `json:"loaded_plugins,omitempty"`
		LogLevel               string               `json:"log_level,omitempty"`
		LuaPackageCpath        string               `json:"lua_package_cpath,omitempty"`
		LuaPackagePath         string               `json:"lua_package_path,omitempty"`
		LuaSslVerifyDepth      int                  `json:"lua_ssl_verify_depth,omitempty"`
		MemCacheSize           string               `json:"mem_cache_size,omitempty"`
		NginxAccLogs           string               `json:"nginx_acc_logs,omitempty"`
		NginxConf              string               `json:"nginx_conf,omitempty"`
		NginxDaemon            string               `json:"nginx_daemon,omitempty"`
		NginxErrLogs           string               `json:"nginx_err_logs,omitempty"`
		NginxKongConf          string               `json:"nginx_kong_conf,omitempty"`
		NginxKongStreamConf    string               `json:"nginx_kong_stream_conf,omitempty"`
		NginxOptimizations     bool                 `json:"nginx_optimizations,omitempty"`
		NginxPid               string               `json:"nginx_pid,omitempty"`
		NginxWorkerProcesses   string               `json:"nginx_worker_processes,omitempty"`
		PgDatabase             string               `json:"pg_database,omitempty"`
		PgHost                 string               `json:"pg_host,omitempty"`
		PgPassword             string               `json:"pg_password,omitempty"`
		PgPort                 int                  `json:"pg_port,omitempty"`
		PgSsl                  bool                 `json:"pg_ssl,omitempty"`
		PgSslVerify            bool                 `json:"pg_ssl_verify,omitempty"`
		PgUser                 string               `json:"pg_user,omitempty"`
		Plugins                interface{}          `json:"plugins,omitempty"`
		Prefix                 string               `json:"prefix,omitempty"`
		ProxyIP                string               `json:"proxy_ip,omitempty"`
		ProxyListen            interface{}          `json:"proxy_listen,omitempty"`
		ProxyListeners         []ListenerDefinition `json:"proxy_listeners,omitempty"`
		ProxyListenSsl         interface{}          `json:"proxy_listen_ssl,omitempty"`
		ProxyPort              int                  `json:"proxy_port,omitempty"`
		ProxySslIP             string               `json:"proxy_ssl_ip,omitempty"`
		ProxySslPort           int                  `json:"proxy_ssl_port,omitempty"`
		SslCert                string               `json:"ssl_cert,omitempty"`
		SslCertCsrDefault      string               `json:"ssl_cert_csr_default,omitempty"`
		SslCertDefault         string               `json:"ssl_cert_default,omitempty"`
		SslCertKey             string               `json:"ssl_cert_key,omitempty"`
		SslCertKeyDefault      string               `json:"ssl_cert_key_default,omitempty"`
		SslCipherSuite         string               `json:"ssl_cipher_suite,omitempty"`
		SslCiphers             string               `json:"ssl_ciphers,omitempty"`
		StatusAccessLog        string               `json:"status_access_log,omitempty"`
		StatusErrorLog         string               `json:"status_error_log,omitempty"`
		StatusListen           []string             `json:"status_listen,omitempty"`
		StatusListeners        interface{}          `json:"status_listeners,omitempty"`
		TrustedIPs             interface{}          `json:"trusted_ips,omitempty"`
		UpstreamKeepAlive      int                  `json:"upstream_keepalive,omitempty"`
	} `json:"configuration,omitempty"`
	Hostname   string `json:"hostname,omitempty"`
	LuaVersion string `json:"lua_version,omitempty"`
	NodeID     string `json:"node_id,omitempty"`
	Plugins    struct {
		AvailableOnServer map[string]bool `json:"available_on_server,omitempty"`
		EnabledInCluster  []string        `json:"enabled_in_cluster,omitempty"`
	} `json:"plugins,omitempty"`
	Tagline string `json:"tagline,omitempty"`
	Timers  struct {
		Pending int `json:"pending,omitempty"`
		Running int `json:"running,omitempty"`
	} `json:"timers,omitempty"`
	Version string `json:"version,omitempty"`
}

ClusterInfo holds all data for the endpoint / (root)

type ClusterStatus added in v1.0.0

type ClusterStatus struct {
	Database struct {
		Reachable bool `json:"reachable,omitempty"`
	} `json:"database,omitempty"`
	Server struct {
		ConnectionsWriting  int `json:"connections_writing,omitempty"`
		ConnectionsHandled  int `json:"connections_handled,omitempty"`
		ConnectionsAccepted int `json:"connections_accepted,omitempty"`
		ConnectionsReading  int `json:"connections_reading,omitempty"`
		ConnectionsActive   int `json:"connections_active,omitempty"`
		ConnectionsWaiting  int `json:"connections_waiting,omitempty"`
		TotalRequests       int `json:"total_requests,omitempty"`
	} `json:"server,omitempty"`
}

ClusterStatus holds all data for the endpoint /status

type Consumer added in v1.2.0

type Consumer struct {
	ID        string   `json:"id,omitempty"`
	Username  string   `json:"username,omitempty"`
	CreatedAt int64    `json:"created_at,omitempty"`
	CustomID  string   `json:"custom_id,omitempty"`
	Tags      []string `json:"tags,omitempty"`
}

Consumer holds request body for POST/PUT/PATCH schema://server:port/consumers/

type Consumers added in v1.2.0

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

Consumers implements ConsumersOperations interface{}

func NewConsumers added in v1.2.0

func NewConsumers(kong *Client) *Consumers

NewConsumers returns Consumers implementation

func (*Consumers) AsMap added in v1.2.0

func (kc *Consumers) AsMap() map[string]Consumer

AsMap returns all defined Consumers in a map

func (*Consumers) AsRaw added in v1.2.3

func (kc *Consumers) AsRaw() *Consumer

AsRaw returns current Consumer

func (*Consumers) ByKey added in v1.2.0

func (kc *Consumers) ByKey(key string) *Consumer

ByKey returns a consumer from its basic auth apikey

func (*Consumers) Create added in v1.2.0

func (kc *Consumers) Create(body Consumer) *Consumers

Create create a consumer

func (*Consumers) CreateKeyAuth added in v1.2.0

func (kc *Consumers) CreateKeyAuth() error

CreateKeyAuth create a new basic auth key for a consumer

func (*Consumers) Delete added in v1.2.0

func (kc *Consumers) Delete(id string) error

Delete deletes a given consumer

func (*Consumers) DeleteKeyAuth added in v1.2.0

func (kc *Consumers) DeleteKeyAuth(key string) error

DeleteKeyAuth remove basic auth key for a consumer

func (*Consumers) Error added in v1.3.0

func (kc *Consumers) Error() error

Error returns the current error if any

func (*Consumers) Exist added in v1.2.0

func (kc *Consumers) Exist(id string) bool

Exist checks if given consumer exist

func (*Consumers) Get added in v1.2.0

func (kc *Consumers) Get(id string) *Consumers

Get returns a Consumer if exist

func (*Consumers) GetACL added in v1.2.9

func (kc *Consumers) GetACL() []string

GetACL returns context of a whitelist

func (*Consumers) GetKeyAuth added in v1.2.0

func (kc *Consumers) GetKeyAuth() map[string]KeyAuthData

GetKeyAuth return all basic auth of a consumer

func (*Consumers) Plugins added in v1.2.5

func (kc *Consumers) Plugins() map[string]Plugin

Plugins returns plugins for a given service

func (*Consumers) Purge added in v1.2.0

func (kc *Consumers) Purge() error

Purge flush all consumers from Kong server

func (*Consumers) RevokeACL added in v1.2.9

func (kc *Consumers) RevokeACL(group string) error

RevokeACL removes a group from a consumer

func (*Consumers) SetACL added in v1.2.9

func (kc *Consumers) SetACL(groups []string) error

SetACL assign a group to a consumer

func (*Consumers) SetKeyAuth added in v1.2.0

func (kc *Consumers) SetKeyAuth(key string) error

SetKeyAuth set a key for a consumer

func (*Consumers) Update added in v1.2.0

func (kc *Consumers) Update(body Consumer) *Consumers

Update update a given consumer

type ConsumersList added in v1.2.0

type ConsumersList struct {
	Data  []Consumer `json:"data,omitempty"`
	Next  string     `json:"next,omitempty"`
	Total int        `json:"total,omitempty"`
}

ConsumersList holds responses when getting all consumers ( GET schema://server:port/consumers/ )

type ConsumersOperations added in v1.2.5

type ConsumersOperations interface {
	Get(id string) *Consumers
	Exist(id string) bool
	Create(body Consumer) *Consumers
	Update(body Consumer) *Consumers
	Delete(id string) error
	Purge() error

	GetKeyAuth() map[string]KeyAuthData
	SetKeyAuth(key string) error
	CreateKeyAuth() error
	DeleteKeyAuth(key string) error
	ByKey(key string) *Consumer

	Plugins() map[string]Plugin

	GetACL() []string
	SetACL(groups []string) error
	RevokeACL(group string) error

	AsMap() map[string]Consumer
	AsRaw() *Consumer

	Error() error
}

ConsumersOperations interface holds Kong Consumers Methods

type EnabledPlugins added in v1.2.0

type EnabledPlugins struct {
	EnabledPlugins []string `json:"enabled_plugins"`
}

EnabledPlugins used when request the plugins enabled on a Kong server

type FailureMessage

type FailureMessage struct {
	Message string `json:"message,omitempty"`
}

FailureMessage all failed request match with this datatype

type HMACAuthentication added in v1.2.5

type HMACAuthentication struct {
	ClockSkew           int  `json:"clock_skew,omitempty"`
	HideCredentials     bool `json:"hide_credentials,omitempty"`
	Anonymous           bool `json:"anonymous,omitempty"`
	ValidateRequestBody bool `json:"validate_request_body,omitempty"`
	EnforceHeaders      bool `json:"enforce_headers,omitempty"`
	Algorithms          bool `json:"algorithms,omitempty"`
}

HMACAuthentication represents config for HMAC authentication

type JWTAuthentication added in v1.2.5

type JWTAuthentication struct {
	URIParamNames     []string `json:"uri_param_names,omitempty"`
	CookieNames       []string `json:"cookie_names,omitempty"`
	HeaderNames       []string `json:"header_names,omitempty"`
	SecretIsBase64    bool     `json:"secret_is_base64,omitempty"`
	Anonymous         string   `json:"anonymous,omitempty"`
	RunOnPreflight    bool     `json:"run_on_preflight,omitempty"`
	MaximumExpiration int      `json:"maximum_expiration,omitempty"`
}

JWTAuthentication represents config for JWT authentication

type KeyAuthData

type KeyAuthData struct {
	CreatedAt  int64  `json:"created_at,omitempty"`
	ConsumerID string `json:"consumer_id,omitempty"`
	Key        string `json:"key,omitempty"`
	ID         string `json:"id,omitempty"`
}

KeyAuthData holds response when getting basic auth for a consumer

type KeyAuthentication added in v1.2.5

type KeyAuthentication struct {
	KeyNames        []string `json:"key_names,omitempty"`
	KeyInBody       bool     `json:"key_in_body,omitempty"`
	Anonymous       string   `json:"anonymous,omitempty"`
	RunOnPreflight  bool     `json:"run_on_preflight,omitempty"`
	HideCredentials bool     `json:"hide_credentials,omitempty"`
}

KeyAuthentication represents config for KeyAuth (apikey) authentication

type ListenerDefinition added in v1.2.0

type ListenerDefinition struct {
	Backlog       bool   `json:"backlog,omitempty"`
	Bind          bool   `json:"bind,omitempty"`
	Deferred      bool   `json:"deferred,omitempty"`
	HTTP2         bool   `json:"http2,omitempty"`
	IP            string `json:"ip,omitempty"`
	Listener      string `json:"listener,omitempty"`
	Port          int    `json:"port,omitempty"`
	ProxyProtocol bool   `json:"proxy_protocol,omitempty"`
	Reuseport     bool   `json:"reuseport,omitempty"`
	Ssl           bool   `json:"ssl,omitempty"`
}

ListenerDefinition holds all data for a Listen Port definition

type OAuth2Authentication added in v1.2.5

type OAuth2Authentication struct {
	Scopes                  []string `json:"scopes,omitempty"`
	MandatoryScope          bool     `json:"mandatory_scope,omitempty"`
	EnableAuthorizationCode bool     `json:"enable_authorization_code,omitempty"`
	HashSecret              bool     `json:"hash_secret,omitempty"`
	HideCredentials         bool     `json:"hide_credentials,omitempty"`
}

OAuth2Authentication represents config for OAuth (OAuth2) authentication

type Plugin added in v1.2.0

type Plugin struct {
	ID        string      `json:"id,omitempty"`
	Name      string      `json:"name,omitempty"`
	Enabled   bool        `json:"enabled,omitempty"`
	Created   int64       `json:"created_at,omitempty"`
	Config    interface{} `json:"config,omitempty"`
	API       interface{} `json:"api_id,omitempty"`
	Service   interface{} `json:"service,omitempty"`
	Consumer  interface{} `json:"consumer,omitempty"`
	Route     interface{} `json:"route,omitempty"`
	Protocols interface{} `json:"protocols,omitempty"`
	Tags      interface{} `json:"tags,omitempty"`
}

Plugin holds responses for a request of create or update a plugin

type PluginList added in v1.2.0

type PluginList struct {
	Data  []Plugin `json:"data,omitempty"`
	Next  string   `json:"next,omitempty"`
	Total int      `json:"total,omitempty"`
}

PluginList holds responses when getting all plugins of a consumers/apis/services or routes

type Plugins added in v1.2.5

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

Plugins implements PluginsOperations interface{}

func NewPlugins added in v1.2.5

func NewPlugins(parent interface{}, kong *Client) *Plugins

NewPlugins returns Plugins implementation

func (*Plugins) AsMap added in v1.2.5

func (p *Plugins) AsMap() map[string]Plugin

AsMap returns as Map all plugins defined

func (*Plugins) AsRaw added in v1.2.5

func (p *Plugins) AsRaw() *Plugin

AsRaw returns the current plugin

func (*Plugins) Create added in v1.2.5

func (p *Plugins) Create(body Plugin) *Plugins

Create a plugin into a Consumer, Route, Apis or Service

func (*Plugins) Delete added in v1.2.5

func (p *Plugins) Delete(id string) error

Delete a plugin from a Consumer, Route, Apis or Service

func (*Plugins) Error added in v1.2.8

func (p *Plugins) Error() error

Error returns the current error if any

func (*Plugins) Get added in v1.2.5

func (p *Plugins) Get(id string) *Plugins

Get returns a non nil Plugins is exist

func (*Plugins) IDByName added in v1.2.9

func (p *Plugins) IDByName(name string) string

IDByName returns plugin ID based on its Name

type PluginsOperations added in v1.2.5

type PluginsOperations interface {
	Get(id string) *Plugins
	Create(body Plugin) *Plugins
	Delete(id string) error

	IDByName(name string) string

	AsMap() map[string]Plugin
	AsRaw() *Plugin

	Error() error
	// contains filtered or unexported methods
}

PluginsOperations interface holds Kong Plugins Methods

type Route added in v1.2.0

type Route struct {
	ID                      string           `json:"id,omitempty"`
	Name                    string           `json:"name,omitempty"`
	Protocols               []string         `json:"protocols,omitempty"`
	Methods                 []string         `json:"methods,omitempty"`
	Hosts                   []string         `json:"hosts,omitempty"`
	Paths                   []string         `json:"paths,omitempty"`
	Headers                 []string         `json:"headers,omitempty"`
	HTTPSRedirectStatusCode int              `json:"https_redirect_status_code,omitempty"`
	RegexPriority           int              `json:"regex_priority,omitempty"`
	StripPath               bool             `json:"strip_path,omitempty"`
	PreserveHost            bool             `json:"preserve_host,omitempty"`
	PathHandling            string           `json:"path_handling,omitempty"`
	Tags                    []string         `json:"tags,omitempty"`
	Service                 *ServiceRelation `json:"service,omitempty"`
	CreatedAt               int              `json:"created_at,omitempty"`
	UpdatedAt               int              `json:"updated_at,omitempty"`
}

Route represents a Kong Route

type RouteList added in v1.2.0

type RouteList struct {
	Data []Route `json:"data"`
	Next string  `json:"next"`
}

RouteList define an Array of Route

type Routes added in v1.2.0

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

Routes implements RoutesOperations interface{}

func NewRoutes added in v1.2.0

func NewRoutes(service *Service, kong *Client) *Routes

NewRoutes returns Routes implementation

func (*Routes) AsMap added in v1.2.0

func (kr *Routes) AsMap() map[string]Route

AsMap returns as Map all routes defined

func (*Routes) AsRaw added in v1.2.3

func (kr *Routes) AsRaw() *Route

AsRaw returns the current route

func (*Routes) Create added in v1.2.0

func (kr *Routes) Create(body Route) *Routes

Create create a route

func (*Routes) Delete added in v1.2.0

func (kr *Routes) Delete(id string) error

Delete erase a given route

func (*Routes) Error added in v1.2.8

func (kr *Routes) Error() error

Error returns the current error if any

func (*Routes) Exist added in v1.2.0

func (kr *Routes) Exist(id string) bool

Exist checks if a given route exists

func (*Routes) Get added in v1.2.0

func (kr *Routes) Get(id string) *Routes

Get returns a non nil Route is exist

func (*Routes) Plugins added in v1.2.0

func (kr *Routes) Plugins() map[string]Plugin

Plugins list all plugins of a given route

func (*Routes) Purge added in v1.2.0

func (kr *Routes) Purge() error

Purge flush all routes

func (*Routes) Update added in v1.2.0

func (kr *Routes) Update(body Route) *Routes

Update updates a given route

type RoutesOperations added in v1.2.5

type RoutesOperations interface {
	Get(id string) *Routes
	Exist(id string) bool
	Create(body Route) *Routes
	Update(body Route) *Routes
	Delete(id string) error
	Purge() error

	Plugins() map[string]Plugin

	AsMap() map[string]Route
	AsRaw() *Route

	Error() error
	// contains filtered or unexported methods
}

RoutesOperations interface holds Kong Routes Methods

type Service

type Service struct {
	ID                string             `json:"id,omitempty"`
	Name              string             `json:"name,omitempty"`
	CreatedAt         int                `json:"created_at,omitempty"`
	UpdatedAt         int                `json:"updated_at,omitempty"`
	Retries           int                `json:"retries,omitempty"`
	URL               string             `json:"url,omitempty"`
	Protocol          string             `json:"protocol,omitempty"`
	Host              string             `json:"host,omitempty"`
	Port              int                `json:"port,omitempty"`
	Path              string             `json:"path,omitempty"`
	ConnectTimeout    int                `json:"connect_timeout,omitempty"`
	WriteTimeout      int                `json:"write_timeout,omitempty"`
	ReadTimeout       int                `json:"read_timeout,omitempty"`
	Tags              []string           `json:"tags,omitempty"`
	ClientCertificate *ClientCertificate `json:"client_certificate,omitempty"`
}

Service represents a Kong Service

type ServiceList added in v1.2.0

type ServiceList struct {
	Data  []Service `json:"data"`
	Next  string    `json:"next"`
	Total int       `json:"total"`
}

ServiceList define an Array of Service

type ServiceRelation added in v1.2.0

type ServiceRelation struct {
	ID string `json:"id,omitempty"`
}

ServiceRelation just used to hold service.id

type Services added in v1.2.0

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

Services implements ServicesOperations interface{}

func NewServices added in v1.2.0

func NewServices(kong *Client) *Services

NewServices returns a new Services client

func (*Services) AsMap added in v1.2.0

func (ks *Services) AsMap() map[string]Service

AsMap returns as Map all services defined

func (*Services) AsRaw added in v1.2.3

func (ks *Services) AsRaw() *Service

AsRaw returns the current service

func (*Services) Create added in v1.2.0

func (ks *Services) Create(body Service) *Services

Create create a service

func (*Services) CreateRoute added in v1.2.0

func (ks *Services) CreateRoute(body Route) *Route

CreateRoute create a route on a service

func (*Services) Delete added in v1.2.0

func (ks *Services) Delete(id string) error

Delete deletes a given service

func (*Services) DeleteRoute added in v1.2.0

func (ks *Services) DeleteRoute(id string) error

DeleteRoute delete a route from a service

func (*Services) Error added in v1.2.8

func (ks *Services) Error() error

Error returns the current error if any

func (*Services) Exist added in v1.2.0

func (ks *Services) Exist(id string) bool

Exist checks if a given services exists

func (*Services) Get added in v1.2.0

func (ks *Services) Get(id string) *Services

Get returns a non nil Service is exist

func (*Services) GetACL added in v1.2.9

func (ks *Services) GetACL() []string

GetACL returns context of a whitelist

func (*Services) Plugins added in v1.2.0

func (ks *Services) Plugins() map[string]Plugin

Plugins returns plugins for a given service

func (*Services) Purge added in v1.2.0

func (ks *Services) Purge() error

Purge flush all services from Kong server

func (*Services) RemoveAuthentication added in v1.2.5

func (ks *Services) RemoveAuthentication(auth Authentication) error

RemoveAuthentication delete an entry on apis plugins with type provided

func (*Services) RevokeACL added in v1.2.9

func (ks *Services) RevokeACL(group string) error

RevokeACL delete an entry on services plugins of type acl

func (*Services) Routes added in v1.2.0

func (ks *Services) Routes() map[string]Route

Routes returns routes for a given service

func (*Services) SetACL added in v1.2.9

func (ks *Services) SetACL(groups []string) error

SetACL creates an entry on services plugins of type acl

func (*Services) SetAuthentication added in v1.2.5

func (ks *Services) SetAuthentication(auth Authentication) error

SetAuthentication creates an entry on service plugins with type provided

func (*Services) Update added in v1.2.0

func (ks *Services) Update(body Service) *Services

Update updates a given service

type ServicesOperations added in v1.2.5

type ServicesOperations interface {
	Get(id string) *Services
	Exist(id string) bool
	Create(body Service) *Services
	Update(body Service) *Services
	Delete(id string) error
	Purge() error

	Routes() map[string]Route
	CreateRoute(body Route) *Route
	DeleteRoute(id string) error

	Plugins() map[string]Plugin

	GetACL() []string
	SetACL(groups []string) error
	RevokeACL(group string) error
	SetAuthentication(auth Authentication) error
	RemoveAuthentication(auth Authentication) error

	AsMap() map[string]Service
	AsRaw() *Service

	Error() error
	// contains filtered or unexported methods
}

ServicesOperations interface holds Kong Services Methods

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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