gokong

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: MIT Imports: 12 Imported by: 0

README

Build Status

GoKong

A kong go client fully tested with no mocks!!

GoKong

GoKong is a easy to use api client for kong. The difference with the gokong library is all of its tests are written against a real running kong running inside a docker container, yep that's right you won't see a horrible mock anywhere!!

Importing

To add gokong via go get:

go get github.com/kevholditch/gokong

To add gokong via govendor:

govendor fetch github.com/kevholditch/gokong

Usage

Import gokong

import (
  "github.com/kevholditch/gokong"
)

To create a default config for use with the client:

config := gokong.NewDefaultConfig()

NewDefaultConfig creates a config with the host address set to the value of the env variable KONG_ADMIN_ADDR. If the env variable is not set then the address is defaulted to http://localhost:8001.

You can of course create your own config with the address set to whatever you want:

config := gokong.Config{HostAddress:"http://localhost:1234"}

Getting the status of the kong server:

kongClient := gokong.NewClient(gokong.NewDefaultConfig())
status, err := kongClient.Status().Get()

Gokong is fluent so we can combine the above two lines into one:

status, err := gokong.NewClient(gokong.NewDefaultConfig()).Status().Get()

APIs

Create a new API (for more information on the API fields see the Kong documentation:

apiRequest := &gokong.ApiRequest{
	Name:                   "Example",
	Hosts:                  []string{"example.com"},
	Uris:                   []string{"/example"},
	Methods:                []string{"GET", "POST"},
	UpstreamUrl:            "http://localhost:4140/testservice",
	StripUri:               true,
	PreserveHost:           true,
	Retries:                3,
	UpstreamConnectTimeout: 1000,
	UpstreamSendTimeout:    2000,
	UpstreamReadTimeout:    3000,
	HttpsOnly:              true,
	HttpIfTerminated:       true,
}

api, err := gokong.NewClient(gokong.NewDefaultConfig()).Apis().Create(apiRequest)

Get an API by id:

api, err := gokong.NewClient(gokong.NewDefaultConfig()).Apis().GetById("cdf5372e-1c10-4ea5-a3dd-1e4c31bb99f5")

Get an API by name:

api, err :=  gokong.NewClient(gokong.NewDefaultConfig()).Apis().GetByName("Example")

List all APIs:

apis, err := gokong.NewClient(gokong.NewDefaultConfig()).Apis().List()

List all APIs with a filter:

apis, err := gokong.NewClient(gokong.NewDefaultConfig()).Apis().ListFiltered(&gokong.ApiFilter{Id:"936ad391-c30d-43db-b624-2f820d6fd38d", Name:"MyApi"})

Delete an API by id:

err :=  gokong.NewClient(gokong.NewDefaultConfig()).Apis().DeleteById("f138641a-a15b-43c3-bd76-7157a68eae24")

Delete an API by name:

err :=  gokong.NewClient(gokong.NewDefaultConfig()).Apis().DeleteByName("Example")

Update an API by id:

apiRequest := &gokong.ApiRequest{
  Name:                   "Example",
  Hosts:                  []string{"example.com"},
  Uris:                   []string{"/example"},
  Methods:                []string{"GET", "POST"},
  UpstreamUrl:            "http://localhost:4140/testservice",
  StripUri:               true,
  PreserveHost:           true,
  Retries:                3,
  UpstreamConnectTimeout: 1000,
  UpstreamSendTimeout:    2000,
  UpstreamReadTimeout:    3000,
  HttpsOnly:              true,
  HttpIfTerminated:       true,
}

updatedApi, err :=  gokong.NewClient(gokong.NewDefaultConfig()).Apis().UpdateById("1213a00d-2b12-4d65-92ad-5a02d6c710c2", apiRequest)

Update an API by name:

apiRequest := &gokong.ApiRequest{
  Name:                   "Example",
  Hosts:                  []string{"example.com"},
  Uris:                   []string{"/example"},
  Methods:                []string{"GET", "POST"},
  UpstreamUrl:            "http://localhost:4140/testservice",
  StripUri:               true,
  PreserveHost:           true,
  Retries:                3,
  UpstreamConnectTimeout: 1000,
  UpstreamSendTimeout:    2000,
  UpstreamReadTimeout:    3000,
  HttpsOnly:              true,
  HttpIfTerminated:       true,
}

updatedApi, err :=  gokong.NewClient(gokong.NewDefaultConfig()).Apis().UpdateByName("Example", apiRequest)

Consumers

Create a new Consumer (for more information on the Consumer Fields see the Kong documentation):

consumerRequest := &gokong.ConsumerRequest{
  Username: "User1",
  CustomId: "SomeId",
}

consumer, err := gokong.NewClient(gokong.NewDefaultConfig()).Consumers().Create(consumerRequest)

Get a Consumer by id:

consumer, err := gokong.NewClient(gokong.NewDefaultConfig()).Consumers().GetById("e8ccbf13-a662-45be-9b6a-b549cc739c18")

Get a Consumer by username:

consumer, err := gokong.NewClient(gokong.NewDefaultConfig()).Consumers().GetByUsername("User1")

List all Consumers:

consumers, err := gokong.NewClient(gokong.NewDefaultConfig()).Consumers().List()

List all Consumers with a filter:

consumers, err := gokong.NewClient(gokong.NewDefaultConfig()).Consumers().ListFiltered(&gokong.ConsumerFilter{CustomId:"1234", Username: "User1"})

Delete a Consumer by id:

err :=  gokong.NewClient(gokong.NewDefaultConfig()).Consumers().DeleteById("7c8741b7-3cf5-4d90-8674-b34153efbcd6")

Delete a Consumer by username:

err :=  gokong.NewClient(gokong.NewDefaultConfig()).Consumers().DeleteByUsername("User1")

Update a Consumer by id:

consumerRequest := &gokong.ConsumerRequest{
  Username: "User1",
  CustomId: "SomeId",
}

updatedConsumer, err :=  gokong.NewClient(gokong.NewDefaultConfig()).Consumers().UpdateById("44a37c3d-a252-4968-ab55-58c41b0289c2", consumerRequest)

Update a Consumer by username:

consumerRequest := &gokong.ConsumerRequest{
  Username: "User2",
  CustomId: "SomeId",
}

updatedConsumer, err :=  gokong.NewClient(gokong.NewDefaultConfig()).Consumers().UpdateByUsername("User2", consumerRequest)

Plugins

Create a new Plugin to be applied to all APIs and consumers do not set ApiId or ConsumerId. Not all plugins can be configured in this way (for more information on the Plugin Fields see the Kong documentation):

pluginRequest := &gokong.PluginRequest{
  Name: "response-ratelimiting",
  Config: map[string]interface{}{
    "limits.sms.minute": 20,
  },
}

createdPlugin, err := gokong.NewClient(gokong.NewDefaultConfig()).Plugins().Create(pluginRequest)

Create a new Plugin for a single API (only set ApiId), not all plugins can be configured in this way (for more information on the Plugin Fields see the Kong documentation):

client := gokong.NewClient(gokong.NewDefaultConfig())

apiRequest := &gokong.ApiRequest{
  Name:                   "test-api",
  Hosts:                  []string{"example.com"},
  Uris:                   []string{"/example"},
  Methods:                []string{"GET", "POST"},
  UpstreamUrl:            "http://localhost:4140/testservice",
  StripUri:               true,
  PreserveHost:           true,
  Retries:                3,
  UpstreamConnectTimeout: 1000,
  UpstreamSendTimeout:    2000,
  UpstreamReadTimeout:    3000,
  HttpsOnly:              true,
  HttpIfTerminated:       true,
}

createdApi, err := client.Apis().Create(apiRequest)

pluginRequest := &gokong.PluginRequest{
  Name: "response-ratelimiting",
  ApiId: createdApi.Id,
  Config: map[string]interface{}{
    "limits.sms.minute": 20,
  },
}

createdPlugin, err :=  client.Plugins().Create(pluginRequest)

Create a new Plugin for a single Consumer (only set ConsumerId), Not all plugins can be configured in this way (for more information on the Plugin Fields see the Kong documentation):

client := gokong.NewClient(gokong.NewDefaultConfig())

consumerRequest := &gokong.ConsumerRequest{
  Username: "User1",
  CustomId: "test",
}

createdConsumer, err := client.Consumers().Create(consumerRequest)

pluginRequest := &gokong.PluginRequest{
  Name: "response-ratelimiting",
  ConsumerId: createdConsumer.Id,
  Config: map[string]interface{}{
    "limits.sms.minute": 20,
  },
}

createdPlugin, err :=  client.Plugins().Create(pluginRequest)

Create a new Plugin for a single Consumer and Api (set ConsumerId and ApiId), Not all plugins can be configured in this way (for more information on the Plugin Fields see the Kong documentation):

client := gokong.NewClient(gokong.NewDefaultConfig())

consumerRequest := &gokong.ConsumerRequest{
  Username: "User1",
  CustomId: "test",
}

createdConsumer, err := client.Consumers().Create(consumerRequest)

apiRequest := &gokong.ApiRequest{
  Name:                   "test-api",
  Hosts:                  []string{"example.com"},
  Uris:                   []string{"/example"},
  Methods:                []string{"GET", "POST"},
  UpstreamUrl:            "http://localhost:4140/testservice",
  StripUri:               true,
  PreserveHost:           true,
  Retries:                3,
  UpstreamConnectTimeout: 1000,
  UpstreamSendTimeout:    2000,
  UpstreamReadTimeout:    3000,
  HttpsOnly:              true,
  HttpIfTerminated:       true,
}

createdApi, err := client.Apis().Create(apiRequest)

pluginRequest := &gokong.PluginRequest{
  Name:       "response-ratelimiting",
  ConsumerId: createdConsumer.Id,
  ApiId:      createdApi.Id,
  Config: map[string]interface{}{
    "limits.sms.minute": 20,
  },
}

createdPlugin, err :=  client.Plugins().Create(pluginRequest)

Get a plugin by id:

plugin, err := gokong.NewClient(gokong.NewDefaultConfig()).Plugins().GetById("04bda233-d035-4b8a-8cf2-a53f3dd990f3")

List all plugins:

plugins, err := gokong.NewClient(gokong.NewDefaultConfig()).Plugins().List()

List all plugins with a filter:

plugins, err := gokong.NewClient(gokong.NewDefaultConfig()).Plugins().ListFiltered(&gokong.PluginFilter{Name: "response-ratelimiting", ConsumerId: "7009a608-b40c-4a21-9a90-9219d5fd1ac7"})

Delete a plugin by id:

err := gokong.NewClient(gokong.NewDefaultConfig()).Plugins().DeleteById("f2bbbab8-3e6f-4d9d-bada-d486600b3b4c")

Update a plugin by id:

updatePluginRequest := &gokong.PluginRequest{
  Name:       "response-ratelimiting",
  ConsumerId: createdConsumer.Id,
  ApiId:      createdApi.Id,
  Config: map[string]interface{}{
    "limits.sms.minute": 20,
  },
}

updatedPlugin, err := gokong.NewClient(gokong.NewDefaultConfig()).Plugins().UpdateById("70692eed-2293-486d-b992-db44a6459360", updatePluginRequest)

Certificates

Create a Certificate (for more information on the Certificate Fields see the Kong documentation):

certificateRequest := &gokong.CertificateRequest{
  Cert: "public key --- 123",
  Key:  "private key --- 456",
}

createdCertificate, err := gokong.NewClient(gokong.NewDefaultConfig()).Certificates().Create(certificateRequest)

Get a Certificate by id:

certificate, err := gokong.NewClient(gokong.NewDefaultConfig()).Certificates().GetById("0408cbd4-e856-4565-bc11-066326de9231")

List all certificates:

certificates, err := gokong.NewClient(gokong.NewDefaultConfig()).Certificates().List()

Delete a Certificate:

err := gokong.NewClient(gokong.NewDefaultConfig()).Certificates().DeleteById("db884cf2-9dd7-4e33-9ef5-628165076a42")

Update a Certificate:

updateCertificateRequest := &gokong.CertificateRequest{
  Cert: "public key --- 789",
  Key:  "private key --- 111",
}

updatedCertificate, err := gokong.NewClient(gokong.NewDefaultConfig()).Certificates().UpdateById("1dc11281-30a6-4fb9-aec2-c6ff33445375", updateCertificateRequest)

SNIs

Create an SNI (for more information on the Sni Fields see the Kong documentation):

client := gokong.NewClient(gokong.NewDefaultConfig())

certificateRequest := &gokong.CertificateRequest{
  Cert: "public key --- 123",
  Key:  "private key --- 111",
}

certificate, err := client.Certificates().Create(certificateRequest)

snisRequest := &gokong.SnisRequest{
  Name:             "example.com",
  SslCertificateId: certificate.Id,
}

sni, err := client.Snis().Create(snisRequest)

Get an SNI by name:

sni, err := client.Snis().GetByName("example.com")

List all SNIs:

snis, err := client.Snis().List()

Delete an SNI by name:

err := client.Snis().DeleteByName("example.com")

Update an SNI by name:

updateSniRequest := &gokong.SnisRequest{
  Name:             "example.com",
  SslCertificateId: "a9797703-3ae6-44a9-9f0a-4ebb5d7f301f",
}

updatedSni, err := client.Snis().UpdateByName("example.com", updateSniRequest)

Upstreams

Create an Upstream (for more information on the Upstream Fields see the Kong documentation):

upstreamRequest := &gokong.UpstreamRequest{
  Name: "test-upstream",
  Slots: 10,
}

createdUpstream, err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().Create(upstreamRequest)

Get an Upstream by id:

upstream, err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().GetById("3705d962-caa8-4d0b-b291-4f0e85fe227a")

Get an Upstream by name:

upstream, err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().GetByName("test-upstream")

List all Upstreams:

upstreams, err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().List()

List all Upstreams with a filter:

upstreams, err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().ListFiltered(&gokong.UpstreamFilter{Name:"test-upstream", Slots:10})

Delete an Upstream by id:

err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().DeleteById("3a46b122-47ee-4c5d-b2de-49be84a672e6")

Delete an Upstream by name:

err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().DeleteById("3a46b122-47ee-4c5d-b2de-49be84a672e6")

Delete an Upstream by id:

err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().DeleteByName("test-upstream")

Update an Upstream by id:

updateUpstreamRequest := &gokong.UpstreamRequest{
  Name: "test-upstream",
  Slots: 10,
}

updatedUpstream, err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().UpdateById("3a46b122-47ee-4c5d-b2de-49be84a672e6", updateUpstreamRequest)

Update an Upstream by name:

updateUpstreamRequest := &gokong.UpstreamRequest{
  Name: "test-upstream",
  Slots: 10,
}

updatedUpstream, err := gokong.NewClient(gokong.NewDefaultConfig()).Upstreams().UpdateByName("test-upstream", updateUpstreamRequest)

Contributing

I would love to get contributions to the project so please feel free to submit a PR. To setup your dev station you need go and docker installed.

Once you have cloned the repository the make command will build the code and run all of the tests. If they all pass then you are good to go!

If when you run the make command you get the following error:

gofmt needs running on the following files:

Then all you need to do is run make fmt this will reformat all of the code (I know awesome)!!

Documentation

Index

Constants

View Source
const ApisPath = "/apis/"
View Source
const CertificatesPath = "/certificates/"
View Source
const ConsumerCredentialJWTFormat = "/consumers/%s/jwt"
View Source
const ConsumerCredentialJWTPath = "/consumers/"
View Source
const ConsumersPath = "/consumers/"
View Source
const EnvKongAdminHostAddress = "KONG_ADMIN_ADDR"
View Source
const PluginsPath = "/plugins/"
View Source
const SnisPath = "/snis/"
View Source
const UpstreamsPath = "/upstreams/"

Variables

This section is empty.

Functions

func GetEnvVarOrDefault

func GetEnvVarOrDefault(key string, defaultValue string) string

Types

type Api

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

func UnmarshalAPI added in v1.0.8

func UnmarshalAPI(body []byte) (*Api, error)

type ApiClient

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

func (*ApiClient) Create

func (apiClient *ApiClient) Create(newApi *ApiRequest) (*Api, error)

func (*ApiClient) DeleteById

func (apiClient *ApiClient) DeleteById(id string) error

func (*ApiClient) DeleteByName

func (apiClient *ApiClient) DeleteByName(name string) error

func (*ApiClient) GetById

func (apiClient *ApiClient) GetById(id string) (*Api, error)

func (*ApiClient) GetByName

func (apiClient *ApiClient) GetByName(name string) (*Api, error)

func (*ApiClient) List

func (apiClient *ApiClient) List() (*Apis, error)

func (*ApiClient) ListFiltered

func (apiClient *ApiClient) ListFiltered(filter *ApiFilter) (*Apis, error)

func (*ApiClient) UpdateById

func (apiClient *ApiClient) UpdateById(id string, apiRequest *ApiRequest) (*Api, error)

func (*ApiClient) UpdateByName

func (apiClient *ApiClient) UpdateByName(name string, apiRequest *ApiRequest) (*Api, error)

type ApiFilter

type ApiFilter struct {
	Id          string `url:"id,omitempty"`
	Name        string `url:"name,omitempty"`
	UpstreamUrl string `url:"upstream_url,omitempty"`
	Retries     int    `url:"retries,omitempty"`
	Size        int    `url:"size,omitempty"`
	Offset      int    `url:"offset,omitempty"`
}

type ApiRequest

type ApiRequest struct {
	Name                   string   `json:"name"`
	Hosts                  []string `json:"hosts,omitempty"`
	Uris                   []string `json:"uris,omitempty"`
	Methods                []string `json:"methods,omitempty"`
	UpstreamUrl            string   `json:"upstream_url"`
	StripUri               bool     `json:"strip_uri"`
	PreserveHost           bool     `json:"preserve_host,omitempty"`
	Retries                int      `json:"retries,omitempty"`
	UpstreamConnectTimeout int      `json:"upstream_connect_timeout,omitempty"`
	UpstreamSendTimeout    int      `json:"upstream_send_timeout,omitempty"`
	UpstreamReadTimeout    int      `json:"upstream_read_timeout,omitempty"`
	HttpsOnly              bool     `json:"https_only,omitempty"`
	HttpIfTerminated       bool     `json:"http_if_terminated,omitempty"`
}

type Apis

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

func UnmarshalAPIs added in v1.0.8

func UnmarshalAPIs(body []byte) (*Apis, error)

type Certificate

type Certificate struct {
	Id   string `json:"id,omitempty"`
	Cert string `json:"cert,omitempty"`
	Key  string `json:"key,omitempty"`
}

type CertificateClient

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

func (*CertificateClient) Create

func (certificateClient *CertificateClient) Create(certificateRequest *CertificateRequest) (*Certificate, error)

func (*CertificateClient) DeleteById

func (certificateClient *CertificateClient) DeleteById(id string) error

func (*CertificateClient) GetById

func (certificateClient *CertificateClient) GetById(id string) (*Certificate, error)

func (*CertificateClient) List

func (certificateClient *CertificateClient) List() (*Certificates, error)

func (*CertificateClient) UpdateById

func (certificateClient *CertificateClient) UpdateById(id string, certificateRequest *CertificateRequest) (*Certificate, error)

type CertificateRequest

type CertificateRequest struct {
	Cert string `json:"cert,omitempty"`
	Key  string `json:"key,omitempty"`
}

type Certificates

type Certificates struct {
	Results []*Certificate `json:"data,omitempty"`
	Total   int            `json:"total,omitempty"`
}

type Config

type Config struct {
	HostAddress string
	// contains filtered or unexported fields
}

func NewDefaultConfig

func NewDefaultConfig() *Config

type Consumer

type Consumer struct {
	Id       string `json:"id,omitempty"`
	CustomId string `json:"custom_id,omitempty"`
	Username string `json:"username,omitempty"`
}

type ConsumerClient

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

func (*ConsumerClient) Create

func (consumerClient *ConsumerClient) Create(consumerRequest *ConsumerRequest) (*Consumer, error)

func (*ConsumerClient) DeleteById

func (consumerClient *ConsumerClient) DeleteById(id string) error

func (*ConsumerClient) DeleteByUsername

func (consumerClient *ConsumerClient) DeleteByUsername(username string) error

func (*ConsumerClient) GetById

func (consumerClient *ConsumerClient) GetById(id string) (*Consumer, error)

func (*ConsumerClient) GetByUsername

func (consumerClient *ConsumerClient) GetByUsername(username string) (*Consumer, error)

func (*ConsumerClient) List

func (consumerClient *ConsumerClient) List() (*Consumers, error)

func (*ConsumerClient) ListFiltered

func (consumerClient *ConsumerClient) ListFiltered(filter *ConsumerFilter) (*Consumers, error)

func (*ConsumerClient) UpdateById

func (consumerClient *ConsumerClient) UpdateById(id string, consumerRequest *ConsumerRequest) (*Consumer, error)

func (*ConsumerClient) UpdateByUsername

func (consumerClient *ConsumerClient) UpdateByUsername(username string, consumerRequest *ConsumerRequest) (*Consumer, error)

type ConsumerCredentialJWT added in v1.0.4

type ConsumerCredentialJWT struct {
	Id           string `json:"id,omitempty"`
	Key          string `json:"key,omitempty"`
	Secret       string `json:"secret,omitempty"`
	ConsumerId   string `json:"consumer_id,omitempty"`
	Algorithm    string `json:"algorithm,omitempty"`
	RSAPublicKey string `json:"rsa_public_key,omitempty"`
}

type ConsumerCredentialJWTClient added in v1.0.4

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

func (*ConsumerCredentialJWTClient) Create added in v1.0.4

func (consumerClient *ConsumerCredentialJWTClient) Create(consumerRequest *ConsumerCredentialJWTRequest) (*ConsumerCredentialJWT, error)

func (*ConsumerCredentialJWTClient) DeleteById added in v1.0.4

func (consumerClient *ConsumerCredentialJWTClient) DeleteById(consumerId, id string) error

func (*ConsumerCredentialJWTClient) GetById added in v1.0.4

func (consumerClient *ConsumerCredentialJWTClient) GetById(consumerId, id string) (*ConsumerCredentialJWT, error)

func (*ConsumerCredentialJWTClient) List added in v1.0.4

func (consumerClient *ConsumerCredentialJWTClient) List(consumerId string) (*ConsumerCredentialJWTs, error)

type ConsumerCredentialJWTFilter added in v1.0.4

type ConsumerCredentialJWTFilter struct {
	Id           string `url:"id,omitempty"`
	Key          string `json:"key,omitempty"`
	Secret       string `json:"secret,omitempty"`
	ConsumerId   string `json:"consumer_id,omitempty"`
	Algorithm    string `json:"algorithm,omitempty"`
	RSAPublicKey string `json:"rsa_public_key,omitempty"`
	Size         int    `url:"size,omitempty"`
	Offset       int    `url:"offset,omitempty"`
}

type ConsumerCredentialJWTRequest added in v1.0.4

type ConsumerCredentialJWTRequest struct {
	ConsumerId   string `json:"consumer_id,omitempty"`
	Key          string `json:"key,omitempty"`
	Secret       string `json:"secret,omitempty"`
	Algorithm    string `json:"algorithm,omitempty"`
	RSAPublicKey string `json:"rsa_public_key,omitempty"`
}

type ConsumerCredentialJWTs added in v1.0.4

type ConsumerCredentialJWTs struct {
	Results []*ConsumerCredentialJWT `json:"data,omitempty"`
	Total   int                      `json:"total,omitempty"`
	Next    string                   `json:"next,omitempty"`
}

type ConsumerFilter

type ConsumerFilter struct {
	Id       string `url:"id,omitempty"`
	CustomId string `url:"custom_id,omitempty"`
	Username string `url:"username,omitempty"`
	Size     int    `url:"size,omitempty"`
	Offset   int    `url:"offset,omitempty"`
}

type ConsumerRequest

type ConsumerRequest struct {
	Username string `json:"username,omitempty"`
	CustomId string `json:"custom_id,omitempty"`
}

type Consumers

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

type KongAdminClient

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

func NewClient

func NewClient(config *Config) *KongAdminClient

func (*KongAdminClient) Apis

func (kongAdminClient *KongAdminClient) Apis() *ApiClient

func (*KongAdminClient) Certificates

func (kongAdminClient *KongAdminClient) Certificates() *CertificateClient

func (*KongAdminClient) ConsumerCredentialJWT added in v1.0.4

func (kongAdminClient *KongAdminClient) ConsumerCredentialJWT() *ConsumerCredentialJWTClient

func (*KongAdminClient) Consumers

func (kongAdminClient *KongAdminClient) Consumers() *ConsumerClient

func (*KongAdminClient) Delete added in v1.0.2

func (client *KongAdminClient) Delete(url string) (*http.Response, []byte, error)

func (*KongAdminClient) Get added in v1.0.2

func (client *KongAdminClient) Get(url string) (*http.Response, []byte, error)

func (*KongAdminClient) Patch added in v1.0.2

func (client *KongAdminClient) Patch(url string, val interface{}) (*http.Response, []byte, error)

func (*KongAdminClient) Plugins

func (kongAdminClient *KongAdminClient) Plugins() *PluginClient

func (*KongAdminClient) Post added in v1.0.2

func (client *KongAdminClient) Post(url string, val interface{}) (*http.Response, []byte, error)

func (*KongAdminClient) Snis

func (kongAdminClient *KongAdminClient) Snis() *SnisClient

func (*KongAdminClient) Status

func (kongAdminClient *KongAdminClient) Status() *StatusClient

func (*KongAdminClient) Upstreams

func (kongAdminClient *KongAdminClient) Upstreams() *UpstreamClient

type Plugin

type Plugin struct {
	Id         string                 `json:"id"`
	Name       string                 `json:"name"`
	ApiId      string                 `json:"api_id,omitempty"`
	ConsumerId string                 `json:"consumer_id,omitempty"`
	Config     map[string]interface{} `json:"config,omitempty"`
	Enabled    bool                   `json:"enabled,omitempty"`
}

type PluginClient

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

func (*PluginClient) Create

func (pluginClient *PluginClient) Create(pluginRequest *PluginRequest) (*Plugin, error)

func (*PluginClient) DeleteById

func (pluginClient *PluginClient) DeleteById(id string) error

func (*PluginClient) GetById

func (pluginClient *PluginClient) GetById(id string) (*Plugin, error)

func (*PluginClient) List

func (pluginClient *PluginClient) List() (*Plugins, error)

func (*PluginClient) ListFiltered

func (pluginClient *PluginClient) ListFiltered(filter *PluginFilter) (*Plugins, error)

func (*PluginClient) UpdateById

func (pluginClient *PluginClient) UpdateById(id string, pluginRequest *PluginRequest) (*Plugin, error)

type PluginFilter

type PluginFilter struct {
	Id         string `url:"id,omitempty"`
	Name       string `url:"name,omitempty"`
	ApiId      string `url:"api_id,omitempty"`
	ConsumerId string `url:"consumer_id,omitempty"`
	Size       int    `url:"size,omitempty"`
	Offset     int    `url:"offset,omitempty"`
}

type PluginRequest

type PluginRequest struct {
	Name       string                 `json:"name"`
	ApiId      string                 `json:"api_id,omitempty"`
	ConsumerId string                 `json:"consumer_id,omitempty"`
	Config     map[string]interface{} `json:"config,omitempty"`
}

type Plugins

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

type Sni

type Sni struct {
	Name             string `json:"name,omitempty"`
	SslCertificateId string `json:"ssl_certificate_id,omitempty"`
}

type Snis

type Snis struct {
	Results []*Sni `json:"data,omitempty"`
	Total   int    `json:"total,omitempty"`
}

type SnisClient

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

func (*SnisClient) Create

func (snisClient *SnisClient) Create(snisRequest *SnisRequest) (*Sni, error)

func (*SnisClient) DeleteByName

func (snisClient *SnisClient) DeleteByName(name string) error

func (*SnisClient) GetByName

func (snisClient *SnisClient) GetByName(name string) (*Sni, error)

func (*SnisClient) List

func (snisClient *SnisClient) List() (*Snis, error)

func (*SnisClient) UpdateByName

func (snisClient *SnisClient) UpdateByName(name string, snisRequest *SnisRequest) (*Sni, error)

type SnisRequest

type SnisRequest struct {
	Name             string `json:"name,omitempty"`
	SslCertificateId string `json:"ssl_certificate_id,omitempty"`
}

type Status

type Status struct {
	Server   serverStatus   `json:"server"`
	Database databaseStatus `json:"database"`
}

type StatusClient

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

func (*StatusClient) GetStatus added in v1.0.2

func (statusClient *StatusClient) GetStatus() (*Status, error)

type Upstream

type Upstream struct {
	Id        string `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	Slots     int    `json:"slots,omitempty"`
	OrderList []int  `json:"orderlist,omitempty"`
}

type UpstreamClient

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

func (*UpstreamClient) Create

func (upstreamClient *UpstreamClient) Create(upstreamRequest *UpstreamRequest) (*Upstream, error)

func (*UpstreamClient) DeleteById

func (upstreamClient *UpstreamClient) DeleteById(id string) error

func (*UpstreamClient) DeleteByName

func (upstreamClient *UpstreamClient) DeleteByName(name string) error

func (*UpstreamClient) GetById

func (upstreamClient *UpstreamClient) GetById(id string) (*Upstream, error)

func (*UpstreamClient) GetByName

func (upstreamClient *UpstreamClient) GetByName(name string) (*Upstream, error)

func (*UpstreamClient) List

func (upstreamClient *UpstreamClient) List() (*Upstreams, error)

func (*UpstreamClient) ListFiltered

func (upstreamClient *UpstreamClient) ListFiltered(filter *UpstreamFilter) (*Upstreams, error)

func (*UpstreamClient) UpdateById

func (upstreamClient *UpstreamClient) UpdateById(id string, upstreamRequest *UpstreamRequest) (*Upstream, error)

func (*UpstreamClient) UpdateByName

func (upstreamClient *UpstreamClient) UpdateByName(name string, upstreamRequest *UpstreamRequest) (*Upstream, error)

type UpstreamFilter

type UpstreamFilter struct {
	Id     string `url:"id,omitempty"`
	Name   string `url:"name,omitempty"`
	Slots  int    `url:"slots,omitempty"`
	Size   int    `url:"size,omitempty"`
	Offset int    `url:"offset,omitempty"`
}

type UpstreamRequest

type UpstreamRequest struct {
	Name      string `json:"name,omitempty"`
	Slots     int    `json:"slots,omitempty"`
	OrderList []int  `json:"orderlist,omitempty"`
}

type Upstreams

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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