Documentation ¶
Index ¶
- Variables
- type API
- type Client
- func (c *Client) APIHasPlugin(apiName string, pluginName string) (bool, error)
- func (c *Client) AddPlugin(apiName string, plugin *Plugin) error
- func (c *Client) CreateAPI(api *API) (*API, error)
- func (c *Client) CreateTarget(upstreamNameOrId string, target *Target) (*Target, error)
- func (c *Client) CreateUpstream(upstream *Upstream) (*Upstream, error)
- func (c *Client) DeleteAPI(nameOrID string) error
- func (c *Client) DeleteUpstream(nameOrId string) error
- func (c *Client) DisableTarget(upstreamNameOrId string, targetHost string) (*Target, error)
- func (c *Client) EnableTarget(upstreamNameOrId string, targetHost string) (*Target, error)
- func (c *Client) GetAPI(nameOrID string) (*API, error)
- func (c *Client) GetPlugin(pluginID string) (*Plugin, error)
- func (c *Client) GetUpstream(nameOrId string) (*Upstream, error)
- func (c *Client) ListApiPlugins(apiName string) (*PluginList, error)
- func (c *Client) ListTargets(upstreamNameOrId string) (*TargetList, error)
- func (c *Client) RemovePlugin(apiName string, pluginName string) error
- func (c *Client) UpdateAPI(api *API) (*API, error)
- func (c *Client) UpdatePlugin(apiName string, plugin *Plugin) error
- func (c *Client) UpdateUpstream(upstream *Upstream) (*Upstream, error)
- type Plugin
- type PluginList
- type Target
- type TargetList
- type Upstream
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound provides the error when a kong object can't be retrieved. ErrNotFound = errors.New("Failed to find the specified kong object") )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { ID string `json:"id,omitempty"` Name string `json:"name"` Hosts []string `json:"hosts,omitempty"` URIs []string `json:"uris,omitempty"` UpstreamURL string `json:"upstream_url"` StripURI *bool `json:"strip_uri,omitempty"` Methods []string `json:"methods,omitempty"` PreserveHost *bool `json:"preserve_host,omitempty"` Retries int64 `json:"retries,omitempty"` UpstreamConnectTimeout int64 `json:"upstream_connect_timeout,omitempty"` UpstreamSendTimeout int64 `json:"upstream_send_timeout,omitempty"` UpstreamReadTimeout int64 `json:"upstream_read_timeout,omitempty"` HTTPSOnly *bool `json:"https_only,omitempty"` HTTPIfTerminated *bool `json:"http_if_terminated,omitempty"` }
API represents a subset of the kong API object which provide the properties this integration utilises.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a client for interacting with the kong API gateway application.
func (*Client) APIHasPlugin ¶
APIHasPlugin lets us know whether the provided API has an instance of the provided plugin type.
func (*Client) AddPlugin ¶
AddPlugin deals with adding the provided plugin definition to the specified API.
func (*Client) CreateTarget ¶
CreateTarget deals with adding a new target to an existing upstream.
func (*Client) CreateUpstream ¶
CreateUpstream deals with creating a new upstream object which can be referenced by an API as an upstream URL.
func (*Client) DeleteUpstream ¶
DeleteUpstream deals with removing the upstream object with the specified name or ID.
func (*Client) DisableTarget ¶
DisableTarget creates a new target with the specified host with a weight of 0.
func (*Client) EnableTarget ¶
EnableTarget creates a new upstream with the weight set to 10 so the load balancer takes the upstream target into account. (Upstreams use history for targets so the latest created target gets used)
func (*Client) GetUpstream ¶
GetUpstream deals with retrieving the upstream with the specified name or ID.
func (*Client) ListApiPlugins ¶
func (c *Client) ListApiPlugins(apiName string) (*PluginList, error)
func (*Client) ListTargets ¶
func (c *Client) ListTargets(upstreamNameOrId string) (*TargetList, error)
ListTargets lists out all the targets for a specified upstream.
func (*Client) RemovePlugin ¶
RemovePlugin deals with removing the specified plugin from the specified API. This handles managing the current issue with Kong that it's docs say you can use the plugin name in a DELETE request but it is not the case. This retrieves the list of plugins and finds the one with the provided plugin name and gets the ID that way to prevent us having to manage some sort of data store in this app.
func (*Client) UpdateAPI ¶
UpdateAPI deals with updating the provided API assuming an API exists with the provided ID or name if it doesn't exist.
func (*Client) UpdatePlugin ¶
UpdatePlugin deals with updating an existing plugin with a new definition. The provided plugin definition is expected to be without specific created instance information such as Created, ID and APIID. We must resolve the UUID from the API + plugin name combination as the kong endpoint for updating plugins do not support plugin names as the path parameter eventhough the docs say otherwise.
type Plugin ¶
type Plugin struct { ID string `json:"id,omitempty"` APIID string `json:"api_id,omitempty"` Name string `json:"name"` Config map[string]interface{} `json:"config"` Enabled *bool `json:"enabled,omitempty"` Created int `json:"created_at,omitempty"` }
Plugin provides the data structure for a Plugin object to be attached to APIs.
type PluginList ¶
PluginList represents the data structure returned from kong when making a request to retrieve a list of plugins.
type Target ¶
type Target struct { ID string `json:"id,omitempty"` Target string `json:"target"` Weight int `json:"weight"` UpstreamID string `json:"upstream_id,omitempty"` Created int `json:"created_at,omitempty"` }
Target provides the kong Target object to be used in upstreams.
type TargetList ¶
TargetList provides the data structure for a list of upstream targets.