Documentation
¶
Index ¶
- Constants
- Variables
- type ACLConfig
- type AclBody
- type AclResponse
- type Api
- type ApiList
- type Apis
- func (ka *Apis) AsMap() (map[string]Api, error)
- func (ka *Apis) AsRaw() *Api
- func (ka *Apis) Create(body Api) *Apis
- func (ka *Apis) CreatePlugin(body Plugin) (*Plugin, error)
- func (ka *Apis) Delete(id string) error
- func (ka *Apis) DeletePlugin(id string) error
- func (ka *Apis) Exist(id string) bool
- func (ka *Apis) Get(id string) *Apis
- func (ka *Apis) GetAcl() []string
- func (ka *Apis) Plugins() (map[string]Plugin, error)
- func (ka *Apis) Purge() error
- func (ka *Apis) RemoveAuthentication(auth Authentication) error
- func (ka *Apis) RevokeAcl(group string) error
- func (ka *Apis) SetAcl(groups []string) error
- func (ka *Apis) SetAuthentication(auth Authentication) error
- func (ka *Apis) Update(body Api) *Apis
- type Authentication
- type BasicKeyAuth
- type Client
- func (k *Client) CheckConnection() error
- func (k *Client) CheckStatus() (map[string]int, error)
- func (k *Client) DatabaseReachable() bool
- func (k *Client) Hostname() string
- func (k *Client) LuaVersion() string
- func (k *Client) New(base *url.URL) *Client
- func (k *Client) NodeID() string
- func (k *Client) SetBasicAuth(username, password string)
- func (k *Client) StatusCode() int
- func (k *Client) Version() string
- type ClientCertificate
- type ClusterInfo
- type ClusterStatus
- type Consumer
- type Consumers
- func (kc *Consumers) AsMap() map[string]Consumer
- func (kc *Consumers) AsRaw() *Consumer
- func (kc *Consumers) ByKey(key string) *Consumer
- func (kc *Consumers) Create(body Consumer) *Consumers
- func (kc *Consumers) CreateAcl(group string) error
- func (kc *Consumers) CreateKeyAuth() error
- func (kc *Consumers) Delete(id string) error
- func (kc *Consumers) DeleteAcl(group string) error
- func (kc *Consumers) DeleteKeyAuth(key string) error
- func (kc *Consumers) Exist(id string) bool
- func (kc *Consumers) Get(id string) *Consumers
- func (kc *Consumers) GetKeyAuth() (map[string]KeyAuthData, error)
- func (kc *Consumers) Purge() error
- func (kc *Consumers) SetKeyAuth(key string) error
- func (kc *Consumers) Update(body Consumer) *Consumers
- type ConsumersList
- type EnabledPlugins
- type FailureMessage
- type KeyAuthData
- type ListenerDefinition
- type Plugin
- type PluginList
- type PluginsCreateBody
- type Route
- type RouteList
- type Routes
- func (kr *Routes) AsMap() map[string]Route
- func (kr *Routes) AsRaw() *Route
- func (kr *Routes) Create(body Route) *Routes
- func (kr *Routes) CreatePlugin(body Plugin) *Plugin
- func (kr *Routes) Delete(id string) error
- func (kr *Routes) DeletePlugin(id string) error
- func (kr *Routes) Exist(id string) bool
- func (kr *Routes) Get(id string) *Routes
- func (kr *Routes) Plugins() map[string]Plugin
- func (kr *Routes) Purge() error
- func (kr *Routes) Update(body Route) *Routes
- type Service
- type ServiceList
- type ServiceRelation
- type Services
- func (ks *Services) AsMap() map[string]Service
- func (ks *Services) AsRaw() *Service
- func (ks *Services) Create(body Service) *Services
- func (ks *Services) CreatePlugin(body Plugin) *Plugin
- func (ks *Services) CreateRoute(body Route) *Route
- func (ks *Services) Delete(id string) error
- func (ks *Services) DeletePlugin(id string) error
- func (ks *Services) DeleteRoute(id string) error
- func (ks *Services) Exist(id string) bool
- func (ks *Services) Get(id string) *Services
- func (ks *Services) Plugins() map[string]Plugin
- func (ks *Services) Purge() error
- func (ks *Services) Routes() map[string]Route
- func (ks *Services) Update(body Service) *Services
Constants ¶
const ( Basic Authentication = "basic-auth" JWT = "jwt" HMAC = "hmac-auth" KeyAuth = "key-auth" LDAP = "ldap-auth" OAuth = "oauth2" Session = "session" )
Variables ¶
var Logger *logger.StandardLogger = logger.NewLogger(true)
Logger default
Functions ¶
This section is empty.
Types ¶
type AclBody ¶ added in v1.2.0
type AclBody struct {
Group string `json:"group,omitempty"`
}
ConsumerAclBody used to set acl for a consumer
type AclResponse ¶ added in v1.2.0
type AclResponse struct {
ID string `json:"id,omitempty"`
Group string `json:"group,omitempty"`
Created int64 `json:"created_at,omitempty"`
ConsumerId int64 `json:"consumer_id,omitempty"`
}
ConsumerAclResponse holds responses for a request to set acl to a consumer
type Api ¶ added in v1.2.0
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"`
}
Kong Apis representation
type ApiList ¶ added in v1.2.0
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 apis interface{}
func (*Apis) CreatePlugin ¶ added in v1.2.0
CreatePlugin create a plugin on an api
func (*Apis) DeletePlugin ¶ added in v1.2.0
DeletePlugin delete a plugin from an api
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) SetAuthentication ¶ added in v1.2.0
func (ka *Apis) SetAuthentication(auth Authentication) error
SetAuthentication creates an entry on apis plugins with type provided
type Authentication ¶ added in v1.2.0
type Authentication string
type BasicKeyAuth ¶
type BasicKeyAuth struct {
Data []KeyAuthData `json:"data,omitempty"`
Total int `json:"total,omitempty"`
}
BasicKeyAuth holds 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 NewFromURL ¶ added in v1.0.9
NewFromURL returns a new Client given a Kong server base url in url/URL type
func (*Client) CheckConnection ¶
CheckConnection check for a valid connection against a Kong server
func (*Client) CheckStatus ¶
CheckStatus returns some metrics from KongAPI server
func (*Client) DatabaseReachable ¶ added in v1.2.0
DatabaseReachable returns availability of database of Kong API server
func (*Client) LuaVersion ¶ added in v1.2.0
LuaVersion returns version of LUA on Kong API server
func (*Client) SetBasicAuth ¶
SetBasicAuth update user and pass
func (*Client) StatusCode ¶
StatusCode returns result code from last request
type ClientCertificate ¶
type ClientCertificate struct {
ID string `json:"id,omitempty"`
}
ClientCertificate holds certificate id
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 []string `json:"admin_listen,omitempty"`
AdminListeners []ListenerDefinition `json:"admin_listeners,omitempty"`
AdminListenSsl []string `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 []string `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 []string `json:"plugins,omitempty"`
Prefix string `json:"prefix,omitempty"`
ProxyIP string `json:"proxy_ip,omitempty"`
ProxyListen []string `json:"proxy_listen,omitempty"`
ProxyListeners []ListenerDefinition `json:"proxy_listeners,omitempty"`
ProxyListenSsl []string `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"`
}
ConsumersCreateBody 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 consumers interface{}
func NewConsumers ¶ added in v1.2.0
NewConsumers returns Consumers implementation
func (*Consumers) ByKey ¶ added in v1.2.0
GetConsumerByKey returns a consumer from its basic auth apikey
func (*Consumers) CreateKeyAuth ¶ added in v1.2.0
NewConsumerKeyAuth create a new basic auth key for a consumer
func (*Consumers) DeleteKeyAuth ¶ added in v1.2.0
DeleteConsumerKeyAuth remove basic auth key for a consumer
func (*Consumers) GetKeyAuth ¶ added in v1.2.0
func (kc *Consumers) GetKeyAuth() (map[string]KeyAuthData, error)
GetConsumerKeyAuth return all basic auth of a consumer
func (*Consumers) SetKeyAuth ¶ added in v1.2.0
SetConsumerKeyAuth set a key for a 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"`
}
ConsumersListResponse holds responses when getting all consumers ( GET schema://server:port/consumers/ )
type EnabledPlugins ¶ added in v1.2.0
type EnabledPlugins struct {
EnabledPlugins []string `json:"enabled_plugins"`
}
EnabledPluginsResponse 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 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 ListenerDefinition ¶ added in v1.2.0
type ListenerDefinition struct {
Backlog bool `json:"backlog=%d+,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 Plugin ¶ added in v1.2.0
type Plugin struct {
ID string `json:"id"`
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"`
}
Plugins 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"`
}
PluginsListResponse holds responses when getting all plugins of a consumers/apis/services or routes
type PluginsCreateBody ¶
type PluginsCreateBody struct {
Name string `json:"name,omitempty"`
Config interface{} `json:"config,omitempty"`
Enabled bool `json:"enabled,omitempty"`
}
PluginsCreateBody used to send a request body for create plugins
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"`
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 Routes ¶ added in v1.2.0
type Routes struct {
// contains filtered or unexported fields
}
Services implements services interface{}
func (*Routes) CreatePlugin ¶ added in v1.2.0
CreatePlugin create a plugin on a route
func (*Routes) DeletePlugin ¶ added in v1.2.0
DeletePlugin delete a plugin from a route
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"`
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"`
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"`
}
type Services ¶ added in v1.2.0
type Services struct {
// contains filtered or unexported fields
}
Services implements services interface{}
func NewServices ¶ added in v1.2.0
NewApis returns Services implementation
func (*Services) CreatePlugin ¶ added in v1.2.0
CreatePlugin create a plugin on a service
func (*Services) CreateRoute ¶ added in v1.2.0
CreateRoute create a route on a service
func (*Services) DeletePlugin ¶ added in v1.2.0
DeletePlugin delete a plugin from a service
func (*Services) DeleteRoute ¶ added in v1.2.0
DeleteRoute delete a route from a service