kong

package
v0.0.0-...-f0135d4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(req *http.Request, r *http.Response) error

CheckResponse looks at the response from a Kong API call and determines what type of error needs to be returned, if any.

func FromMap

func FromMap(configStruct interface{}, configMap map[string]interface{}) error

FromMap is used to marshal a map[string]interface{} to a more specific plugin struct definition by matching the json tags to the struct keys

Generally this is used when converting the returned plugin configuration information from map[string]interface{} to a more specific struct

i.e. map[string]interface -> ACLConfig

func SetJSONField

func SetJSONField(configStruct interface{}, mapKey string, mapValue interface{}) error

SetField is used to convert entries in a map to struct fields It matches map keys to json tags

func ToMap

func ToMap(config interface{}) map[string]interface{}

ToMap is used to marshal a specific plugin configuration to the more general map[string]interface{} expected by PluginsService.Post ToMap uses the `json:""` tags of the input struct to name the map keys.

ToMap also does not carry over empty fields from the original struct in the returned map[string]interface{}. This way the resulting map can safely be marshaled to JSON without nil fields.

Types

type ACLConfig

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

type Api

type Api struct {
	UpstreamURL            string   `json:"upstream_url,omitempty"`
	RequestPath            string   `json:"request_path,omitempty"`
	ID                     string   `json:"id,omitempty"`
	CreatedAt              int64    `json:"created_at,omitempty"`
	PreserveHost           bool     `json:"preserve_host,omitempty"`
	Name                   string   `json:"name,omitempty"`
	Hosts                  []string `json:"hosts,omitempty"`
	Uris                   []string `json:"uris"`
	StripUri               bool     `json:"strip_uri"`
	Retries                int      `json:"retries"`
	UpstreamConnectTimeout int      `json:"upstream_connect_timeout"`
	UpstreamSendTimeout    int      `json:"upstream_send_timeout"`
	UpstreamReadTimeout    int      `json:"upstream_read_timeout"`
	HttpsOnly              bool     `json:"https_only"`
	HttpIfTerminated       bool     `json:"http_if_terminated"`
}

Api represents an existing Kong api object

type ApiRequest

type ApiRequest struct {
	UpstreamURL            string   `json:"upstream_url,omitempty"`
	RequestPath            string   `json:"request_path,omitempty"`
	ID                     string   `json:"id,omitempty"`
	CreatedAt              int64    `json:"created_at,omitempty"`
	PreserveHost           bool     `json:"preserve_host,omitempty"`
	Name                   string   `json:"name,omitempty"`
	Hosts                  []string `json:"hosts,omitempty"`
	Uris                   []string `json:"uris"`
	StripUri               bool     `json:"strip_uri"`
	Retries                int      `json:"retries"`
	UpstreamConnectTimeout int      `json:"upstream_connect_timeout"`
	UpstreamSendTimeout    int      `json:"upstream_send_timeout"`
	UpstreamReadTimeout    int      `json:"upstream_read_timeout"`
	HttpsOnly              bool     `json:"https_only"`
	HttpIfTerminated       bool     `json:"http_if_terminated"`
}

ApiRequest represents a Kong api object for api creation.

type Apis

type Apis struct {
	Data   []*Api `json:"data,omitempty"`
	Total  int    `json:"total,omitempty"`
	Next   string `json:"next,omitempty"`
	Offset string `json:"offset,omitempty"`
}

Apis represents the object returned from Kong when querying for multiple api objects.

In cases where the number of objects returned exceeds the maximum, Next holds the URI for the next set of results. i.e. "http://localhost:8001/apis/?size=2&offset=4d924084-1adb-40a5-c042-63b19db421d1"

type ApisGetAllOptions

type ApisGetAllOptions struct {
	ID          string `url:"id,omitempty"`           // A filter on the list based on the apis id field.
	Name        string `url:"name,omitempty"`         // A filter on the list based on the apis name field.
	RequestHost string `url:"request_host,omitempty"` // A filter on the list based on the apis request_host field.
	RequestPath string `url:"request_path,omitempty"` // A filter on the list based on the apis request_path field.
	UpstreamURL string `url:"upstream_url,omitempty"` // A filter on the list based on the apis upstream_url field.
	Size        int    `url:"size,omitempty"`         // A limit on the number of objects to be returned.
	Offset      string `url:"offset,omitempty"`       // A cursor used for pagination. offset is an object identifier that defines a place in the list.
}

ApisGetAllOptions specifies optional filter parameters to the ApisService.GetAll method.

Additional information about filtering options can be found in the Kong documentation at: https://getkong.org/docs/0.9.x/admin-api/#list-apis

type ApisPluginsService

type ApisPluginsService service

ApisPluginsService handles communication with Kong's '/apis/{api id or name}/plugins' resource.

func (*ApisPluginsService) GetAll

GetAll lists all plugins attached to the specifed api. This query can be filtered by supplying the PluginsGetAllOptions struct.

Equivalent to GET/apis/{api}/plugins?uri=params&from=opt

func (*ApisPluginsService) Patch

func (s *ApisPluginsService) Patch(api string, plugin *Plugin) (*http.Response, error)

Patch modifies the configuration of the specified plugin object attached to the specified api. plugin.ID must be provided.

Equivalent to PATCH /apis/{apiName}/plugins/{pluginID}

func (*ApisPluginsService) Post

func (s *ApisPluginsService) Post(api string, plugin *Plugin) (*http.Response, error)

Post creates a new Kong plugin object attached to the specified api.

Equivalent to POST /apis/{apiName}/plugins

type ApisService

type ApisService struct {
	Plugins *ApisPluginsService
	// contains filtered or unexported fields
}

ApisService handles communication with Kong's '/apis' resource.

func (*ApisService) Delete

func (s *ApisService) Delete(api string) (*http.Response, error)

Delete deletes a single Kong api object, by name or id.

Equivalent to DELETE /apis/{name or id}

func (*ApisService) Get

func (s *ApisService) Get(api string) (*Api, *http.Response, error)

Get queries for a single Kong api object, by name or id.

Equivalent to GET /apis/{name or id}

func (*ApisService) GetAll

func (s *ApisService) GetAll(opt *ApisGetAllOptions) (*Apis, *http.Response, error)

GetAll queries for all Kong api objects. This query can be filtered by supplying the ApisGetAllOptions struct.

Equivalent to GET /apis?uri=params&from=opt

func (*ApisService) Patch

func (s *ApisService) Patch(api *ApiRequest) (*http.Response, error)

Patch updates an existing Kong api object. At least one of api.Name or api.ID must be specified in the passed *Api parameter.

Equivalent to PATCH /apis/{name or id}

func (*ApisService) Post

func (s *ApisService) Post(api *ApiRequest) (*http.Response, error)

Post creates a new Kong api object.

Equivalent to POST /apis

type Client

type Client struct {

	// Base URL for API requests.
	// BaseURL should always be specified with a trailing slash
	BaseURL *url.URL

	// Services used for talking to different parts of the Kong API
	Node      *NodeService
	Cluster   *ClusterService
	Apis      *ApisService
	Upstreams *UpstreamsService
	Targets   *TargetsService
	Consumers *ConsumersService
	Plugins   *PluginsService
	// contains filtered or unexported fields
}

Client manages communication with the Kong API. New client objects should be created using the NewClient function. The BaseURL field must be defined and pointed at an instance of the Kong Admin API.

Kong resources can be access using the Service objects. client.Apis.Get("id") -> GET /apis/id client.Consumers.Patch(consumer) -> PATCH /consumers/id

func NewClient

func NewClient(httpClient *http.Client, baseURLStr string) (*Client, error)

NewClient creates a new kong.Client object. This should be the primary way a kong.Client object is constructed.

If an httpClient object is specified it will be used instead of the default http.DefaultClient.

baseURLStr should point to an instance a Kong Admin API and must contain the trailing slash. i.e. http://kong:8001/

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do executes the actual REST call against Kong. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

The *http.Response object returned by Do should eventually get passed back to the caller. If Kong returns a status code outside of the 200 range, the caller can inspect the *http.Response to get more information. Additionally the err returned in this case will be of type ErrorResponse.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest is used to construct a new *http.Request object Generally speaking the returned *http.Request object will be used in a subsequent Client.Do to execute the actual REST call against Kong.

If body is provided, it will be JSON encoded and used as the request body.

type Cluster

type Cluster struct {
	Total int             `json:"total,omitemtpy"`
	Data  []ClusterMember `json:"data,omitempty"`
}

type ClusterMember

type ClusterMember struct {
	Address string `json:"address,omitempty"`
	Name    string `json:"name,omitempty"`
	Status  string `json:"status,omitempty"`
}

type ClusterService

type ClusterService service

func (*ClusterService) Delete

func (s *ClusterService) Delete(clusterMember *ClusterMember) (*http.Response, error)

func (*ClusterService) Get

func (s *ClusterService) Get() (*Cluster, *http.Response, error)

type ConflictError

type ConflictError ErrorResponse

ConflictError occurs when trying to create a resource that already exists. CheckResponse will return this type of error when Kong returns a 409 status code.

func (*ConflictError) Error

func (r *ConflictError) Error() string

type Consumer

type Consumer struct {
	ID        string `json:"id,omitempty"`
	Username  string `json:"username,omitempty"`
	CustomID  string `json:"custom_id,omitempty"`
	CreatedAt int    `json:"created_at,omitempty"`
}

Consumer represents a single Kong consumer object

type ConsumerACLConfig

type ConsumerACLConfig struct {
	ConsumerID string `json:"consumer_id,omitempty"`
	CreatedAt  int    `json:"created_at,omitempty"`
	Group      string `json:"group,omitempty"`
	ID         string `json:"id,omitempty"`
}

type ConsumerACLConfigs

type ConsumerACLConfigs struct {
	Data  []*ConsumerACLConfig `json:"data,omitempty"`
	Total int                  `json:"total,omitempty"`
}

type ConsumerJWTConfig

type ConsumerJWTConfig struct {
	Key          string `json:"key,omitempty"`
	Algorithm    string `json:"algorithm,omitempty"`
	RSAPublicKey string `json:"rsa_public_key,omitempty"`
	Secret       string `json:"secret,omitempty"`
	ID           string `json:"id,omitempty"`
	CreatedAt    int    `json:"created_at,omitempty"`
}

type ConsumerJWTConfigs

type ConsumerJWTConfigs struct {
	Data  []*ConsumerJWTConfig `json:"data,omitempty"`
	Total int                  `json:"total,omitemtpy"`
}

type ConsumerKeyAuthConfig

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

type ConsumerKeyAuthConfigs

type ConsumerKeyAuthConfigs struct {
	Data  []*ConsumerKeyAuthConfig `json:"data,omitempty"`
	Total int                      `json:"total,omitemtpy"`
}

type Consumers

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

Consumers represents the object returned from Kong when querying for multiple consumer objects.

In cases where the number of objects returned exceeds the maximum, Next holds the URI for the next set of results. i.e. "http://localhost:8001/consumers/?size=2&offset=4d924084-1adb-40a5-c042-63b19db421d1"

type ConsumersACLService

type ConsumersACLService service

func (*ConsumersACLService) Delete

func (s *ConsumersACLService) Delete(consumer, id string) (*http.Response, error)

func (*ConsumersACLService) GetAll

func (s *ConsumersACLService) GetAll(consumer string) (*ConsumerACLConfigs, *http.Response, error)

func (*ConsumersACLService) Post

func (s *ConsumersACLService) Post(consumer string, config *ConsumerACLConfig) (*http.Response, error)

type ConsumersGetAllOptions

type ConsumersGetAllOptions struct {
	ID       string `url:"id,omitempty"`        // A filter on the list based on the consumer id field.
	CustomID string `url:"custom_id,omitempty"` // A filter on the list based on the consumer custom_id field.
	Username string `url:"username,omitempty"`  // A filter on the list based on the consumer username field.
	Size     int    `url:"size,omitempty"`      // A limit on the number of objects to be returned.
	Offset   string `url:"offset,omitempty"`    // A cursor used for pagination. offset is an object identifier that defines a place in the list.
}

ConsumersGetAllOptions specifies optional filter parameters to the ConsumersService.GetAll method.

Additional information about filtering options can be found in the Kong documentation at: https://getkong.org/docs/0.9.x/admin-api/#list-consumers

type ConsumersJWTService

type ConsumersJWTService service

func (*ConsumersJWTService) Delete

func (s *ConsumersJWTService) Delete(consumer, id string) (*http.Response, error)

func (*ConsumersJWTService) GetAll

func (s *ConsumersJWTService) GetAll(consumer string) (*ConsumerJWTConfigs, *http.Response, error)

func (*ConsumersJWTService) Post

type ConsumersKeyAuthService

type ConsumersKeyAuthService service

func (*ConsumersKeyAuthService) Delete

func (s *ConsumersKeyAuthService) Delete(consumer, id string) (*http.Response, error)

func (*ConsumersKeyAuthService) GetAll

func (*ConsumersKeyAuthService) Post

type ConsumersPlugins

type ConsumersPlugins struct {
	ACL     *ConsumersACLService
	JWT     *ConsumersJWTService
	KeyAuth *ConsumersKeyAuthService
}

type ConsumersService

type ConsumersService struct {
	Plugins *ConsumersPlugins
	// contains filtered or unexported fields
}

ConsumersService handles communication with Kong's '/consumers' resource.

func (*ConsumersService) Delete

func (s *ConsumersService) Delete(consumer string) (*http.Response, error)

ConsumersService.Delete deletes a single Kong consumer object, by name or id.

Equivalent to DELETE /consumers/{username or id}

func (*ConsumersService) Get

func (s *ConsumersService) Get(consumer string) (*Consumer, *http.Response, error)

ConsumersService.Get queries for a single Kong consumer object, by name or id.

Equivalent to GET /consumers/{name or id}

func (*ConsumersService) GetAll

ConsumersService.GetAll queries for all Kong consumer objects. This query can be filtered by supplying the ConsumersGetAllOptions struct.

Equivalent to GET /consumers?uri=params&from=opt

func (*ConsumersService) Patch

func (s *ConsumersService) Patch(consumer *Consumer) (*http.Response, error)

ConsumersService.Patch updates an existing Kong consumer object. At least one of consumer.Username or consumer.ID must be specified in the passed *Consumer parameter.

Equivalent to PATCH /consumers/{username or id}

func (*ConsumersService) Post

func (s *ConsumersService) Post(consumer *Consumer) (*http.Response, error)

ConsumersService.Post creates a new Kong consumer object.

Equivalent to POST /consumers

type CorrelationIDConfig

type CorrelationIDConfig struct {
	HeaderName     string `json:"header_name,omitempty"`
	Generator      string `json:"generator,omitempty"`
	EchoDownstream *bool  `json:"echo_downstream,omitempty"`
}

type EnabledPlugins

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

EnabledPlugins represents the list of Plugins returned when querying /plugins/enabled

type ErrorResponse

type ErrorResponse struct {
	Request     *http.Request  // HTTP request object used for the failed request
	Response    *http.Response // HTTP response that caused this error
	KongMessage string         `json:"message,omitempty"`
	KongError   string         `json:"error,omitempty"`
}

ErrorResponse is returned from Client.Do if Kong returns a status code outside the 200 range.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type FileLogConfig

type FileLogConfig struct {
	Path string `json:"path,omitempty"`
}

type HttpLogConfig

type HttpLogConfig struct {
	HttpEndpoint string `json:"http_endpoint,omitempty"`
	Method       string `json:"method,omitempty"`
	Timeout      int    `json:"timeout,omitempty"`
	KeepAlive    int    `json:"keepalive,omitempty"`
}

type JWTConfig

type JWTConfig struct {
	URIParamNames  []string `json:"uri_param_names,omitempty"`
	ClaimsToVerify []string `json:"claims_to_verify,omitempty"`
	KeyClaimName   string   `json:"key_claim_name,omitempty"`
	SecretIsBase64 *bool    `json:"secret_is_base64,omitempty"`
}

type KeyAuthenticationConfig

type KeyAuthenticationConfig struct {
	KeyNames        []string `json:"key_names,omitempty"`
	HideCredentials *bool    `json:"hide_credentials,omitempty"`
}

type Node

type Node struct {
	Configuration map[string]interface{} `json:"configuration,omitempty"`
	Hostname      string                 `json:"hostname,omitempty"`
	LuaVersion    string                 `json:"lua_version,omitempty"`
	Plugins       struct {
		AvailableOnServer map[string]bool `json:"available_on_server,omitempty"`
		EnabledInCluster  map[string]bool `json:"enabled_in_cluster,omitempty"`
	} `json:"plugins,omitempty"`
	PRNGSeeds map[string]int `json:"prng_seeds,omitempty"`
	Tagline   string         `json:"tagline,omitempty"`
	Timers    map[string]int `json:"timers,omitempty"`
	Version   string         `json:"version,omitempty"`
}

type NodeService

type NodeService service

func (*NodeService) Get

func (s *NodeService) Get() (*Node, *http.Response, error)

func (*NodeService) GetStatus

func (s *NodeService) GetStatus() (*Status, *http.Response, error)

type NotFoundError

type NotFoundError ErrorResponse

NotFoundError occurs when trying to access a resource that does not exist. CheckResponse will return this type of error when Kong returns a 404 status code.

func (*NotFoundError) Error

func (r *NotFoundError) Error() string

type Plugin

type Plugin struct {
	ID         string                 `json:"id,omitempty"`
	Name       string                 `json:"name,omitempty"`
	CreatedAt  int                    `json:"created_at,omitempty"`
	Enabled    *bool                  `json:"enabled,omitempty"`
	ApiID      string                 `json:"api_id,omitempty"`
	ConsumerID string                 `json:"consumer_id,omitempty"`
	Config     map[string]interface{} `json:"config,omitempty"`
}

Plugin represents a single Kong plugin object.

Because there are a myriad of structures for the Kong plugin config's, Plugin.Config is the generic map[string]interface{}. Helper method's exist on the more specific Plugin definitions to convert them to/from this struct.

type Plugins

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

Plugins represents the object returned from Kong when querying for multiple plugin objects.

In cases where the number of objects returned exceeds the maximum, Next holds the URI for the next set of results. i.e. "http://localhost:8001/plugins?size=2&offset=4d924084-1adb-40a5-c042-63b19db421d1"

type PluginsGetAllOptions

type PluginsGetAllOptions struct {
	ID         string `url:"id,omitempty"`          // A filter on the list based on the id field.
	Name       string `url:"name,omitempty"`        // A filter on the list based on the name field.
	ApiID      string `url:"api_id,omitempty"`      // A filter on the list based on the api_id field.
	ConsumerID string `url:"consumer_id,omitempty"` // A filter on the list based on the consumer_id field.
	Size       int    `url:"size,omitempty"`        // A limit on the number of objects to be returned.
	Offset     string `url:"offset,omitempty"`      // A cursor used for pagination. offset is an object identifier that defines a place in the list.

}

PluginsGetAllOptions specifies optional filter parameters to the PluginsService.GetAll method.

Additional information about filtering options can be found in the Kong documentation at: https://getkong.org/docs/0.9.x/admin-api/#list-all-plugins

type PluginsService

type PluginsService service

PluginsService handles communication with Kong's '/plugins' resource

func (*PluginsService) Delete

func (s *PluginsService) Delete(api string, plugin string) (*http.Response, error)

PluginsService.Delete deletes a single Kong plugin object attached to a specifc api. Accepts either api name or id. Only accepts plugin id.

Equivalent to DELETE /apis/{name or id}/plugins/{id}

func (*PluginsService) Get

func (s *PluginsService) Get(id string) (*Plugin, *http.Response, error)

PluginsService.Get queries for a single Kong plugin object by id

Equivalent to GET /plugins/{id}

func (*PluginsService) GetAll

PluginsService.GetAll queries for all Kong plugins objects. This query can be filtered by supplying the PluginsGetAllOptions struct.

Equivalent to GET /plugins?uri=params&from=opt

func (*PluginsService) GetEnabled

func (s *PluginsService) GetEnabled() (*EnabledPlugins, *http.Response, error)

PluginsService.GetEnabled queries for the list of all enabled Kong plugins.

func (*PluginsService) GetSchema

func (s *PluginsService) GetSchema(name string) (map[string]interface{}, *http.Response, error)

PluginsService.GetSchema queries for the schema of a particular Kong plugin.

Equivalent to GET /plugins/schema/{name}

func (*PluginsService) Patch

func (s *PluginsService) Patch(api string, plugin *Plugin) (*http.Response, error)

PluginsService.Patch updates an existing Kong plugin object for a specific api. Accepts either api name or id.

Equivalent to PATCH /apis/{name or id}/plugins/{id}

func (*PluginsService) Post

func (s *PluginsService) Post(plugin *Plugin) (*http.Response, error)

PluginsService.Post creates a new Kong plugin object. Which consumer and api objects the plugin gets applied to depend on the values of ConsumerID and ApiID on the passed plugin object.

For more info see: https://getkong.org/docs/0.9.x/admin-api/#add-plugin

type RateLimitingConfig

type RateLimitingConfig struct {
	Second        int    `json:"second,omitempty"`
	Minute        int    `json:"minute,omitempty"`
	Hour          int    `json:"hour,omitempty"`
	Day           int    `json:"day, omitempty"`
	Month         int    `json:"month,omitempty"`
	Year          int    `json:"year, omitempty"`
	LimitBy       string `json:"limit_by,omitempty"`
	Policy        string `json:"policy,omitempty"`
	FaultTolerant *bool  `json:"fault_tolerant,omitempty"`
	RedisHost     string `json:"redis_host,omitempty"`
	RedisPort     string `json:"redis_port,omitempty"`
	RedisPassword string `json:"redis_password,omitempty"`
	RedisTimeout  int    `json:"redis_timeout,omitempty"`
}

type RequestSizeLimitingConfig

type RequestSizeLimitingConfig struct {
	AllowedPayloadSize int `json:"allowed_payload_size,omitempty"`
}

type Status

type Status struct {
	Database map[string]int `json:"database,omitempty"`
	Server   map[string]int `json:"server,omitempty"`
}

type Target

type Target struct {
	Target     string `json:"target"`
	ID         string `json:"id,omitempty"`
	CreatedAt  int64  `json:"created_at,omitempty"`
	Weight     int    `json:"weight,omitempty"`
	UpstreamID string `json:"upstream_id,omitempty"`
}

Target represents a single Kong target object.

type TargetCount

type TargetCount struct {
	Total int `json:"total"`
}

TargetCount represents the number of targets on an upstream

type Targets

type Targets struct {
	Data   []*Target `json:"data,omitempty"`
	Total  int       `json:"total,omitempty"`
	Next   string    `json:"next,omitempty"`
	Offset string    `json:"offset,omitempty"`
}

Targets represents the object returned from Kong when querying for multiple target objects.

In cases where the number of objects returned exceeds the maximum, Next holds the URI for the next set of results. i.e. "http://localhost:8001/targets/?size=2&offset=4d924084-1adb-40a5-c042-63b19db421d1"

type TargetsService

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

TargetsService handles communication with Kong's '/upstreams/{name or id}/targets' resource.

func (*TargetsService) Delete

func (s *TargetsService) Delete(upstream string, target string) (*http.Response, error)

Delete deletes a single Kong target object, by target (host/port combination)

Equivalent to DELETE /upstreams/{name or id}/targets/{target}

func (*TargetsService) GetAllActive

func (s *TargetsService) GetAllActive(upstream string) (*Targets, *http.Response, error)

GetAllActive lists all the active targets attached to the specified upstream.

Equivalent to GET/upstreams/{name or id}/targets/active

func (*TargetsService) Post

func (s *TargetsService) Post(upstream string, target *Target) (*http.Response, error)

Post creates a new Kong target object.

Equivalent to POST /upstreams/{name or id}/targets

type Upstream

type Upstream struct {
	Name      string `json:"name"`
	ID        string `json:"id,omitempty"`
	CreatedAt int64  `json:"created_at,omitempty"`
	Slots     int    `json:"slots,omitempty"`
	Orderlist []int  `json:"orderliste,omitempty"`
}

Upstream represents a single Kong upstream object.

type Upstreams

type Upstreams struct {
	Data   []*Upstream `json:"data,omitempty"`
	Total  int         `json:"total,omitempty"`
	Next   string      `json:"next,omitempty"`
	Offset string      `json:"offset,omitempty"`
}

Upstreams represents the object returned from Kong when querying for multiple upstream objects.

In cases where the number of objects returned exceeds the maximum, Next holds the URI for the next set of results. i.e. "http://localhost:8001/upstreams/?size=2&offset=4d924084-1adb-40a5-c042-63b19db421d1"

type UpstreamsService

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

UpstreamsService handles communication with Kong's '/upstreams' resource.

func (*UpstreamsService) Delete

func (s *UpstreamsService) Delete(upstream string) (*http.Response, error)

Delete deletes a single Kong upstream object, by name or id.

Equivalent to DELETE /upstreams/{name or id}

func (*UpstreamsService) Get

func (s *UpstreamsService) Get(upstream string) (*Upstream, *http.Response, error)

Get queries for a single Kong upstream object, by name or id.

Equivalent to GET /upstreams/{name or id}

func (*UpstreamsService) Patch

func (s *UpstreamsService) Patch(upstream *Upstream) (*http.Response, error)

Patch updates an existing Kong upstream object. At least one of upstream.Name or upstream.ID must be specified in the passed *Upstream parameter.

Equivalent to PATCH /upstreams/{name or id}

func (*UpstreamsService) Post

func (s *UpstreamsService) Post(upstream *Upstream) (*http.Response, error)

Post creates a new Kong upstream object.

Equivalent to POST /upstreams

Jump to

Keyboard shortcuts

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