Documentation
¶
Overview ¶
Package custom defines interfaces to interact with custom entities in Kong.
Index ¶
- type Entity
- type EntityCRUD
- type EntityCRUDDefinition
- func (e *EntityCRUDDefinition) DeleteEndpoint(entity Entity) (string, error)
- func (e *EntityCRUDDefinition) GetEndpoint(entity Entity) (string, error)
- func (e EntityCRUDDefinition) ListEndpoint(entity Entity) (string, error)
- func (e *EntityCRUDDefinition) PatchEndpoint(entity Entity) (string, error)
- func (e *EntityCRUDDefinition) PostEndpoint(entity Entity) (string, error)
- func (e *EntityCRUDDefinition) Type() Type
- type EntityObject
- type Object
- type Registry
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity interface { // Type returns the type of the entity. Type() Type // Object returns the object, an instance // of a custom entity in Kong. Object() Object SetObject(Object) // AddRelation adds a foreign // relation with another entity's ID. AddRelation(string, string) // GetRelation should return foreign // entity's ID that is associated with Entity. GetRelation(string) string // GetAllRelations should return all // relationship of current Entity. GetAllRelations() map[string]string }
Entity represents an instance of a custom entity alongwith it's relations to other entities.
type EntityCRUD ¶
type EntityCRUD interface { // Type return the type of custom entitiy // (like key-auth, basic-auth, acl). Type() Type // GetEndpoint returns the URL to get // an existing entity e. // This is useful when one has the foreign relations // and the primary key for that entity. GetEndpoint(e Entity) (string, error) // PostEndpoint returns the URL to create // an entity e of a Type. PostEndpoint(e Entity) (string, error) // PatchEndpoint returns the URL to use for updating // custom entity e. PatchEndpoint(e Entity) (string, error) // DeleteEndpoint returns the URL to use // to delete entity e. DeleteEndpoint(e Entity) (string, error) // ListEndpoint returns the list URL. // This can be used to list all // instances of a type. ListEndpoint(e Entity) (string, error) }
EntityCRUD defines endpoints on Kong's Admin API to interact with the Custom entity in Kong. Various *Endpoint methods can render the endpoint to interact with a custom entity in Kong. The RESTful endpoints are dynamically generated since based on foreign relations, the URLs change.
type EntityCRUDDefinition ¶
type EntityCRUDDefinition struct { Name Type `yaml:"name" json:"name"` CRUDPath string `yaml:"crud" json:"curd"` PrimaryKey string `yaml:"primary_key" json:"primary_key"` }
EntityCRUDDefinition implements the EntityCRUD interface.
func (*EntityCRUDDefinition) DeleteEndpoint ¶
func (e *EntityCRUDDefinition) DeleteEndpoint(entity Entity) (string, error)
DeleteEndpoint returns the URL to use to delete entity e.
func (*EntityCRUDDefinition) GetEndpoint ¶
func (e *EntityCRUDDefinition) GetEndpoint(entity Entity) (string, error)
GetEndpoint returns the URL to get an existing entity e. This is useful when one has the foreign relations and the primary key for that entity.
func (EntityCRUDDefinition) ListEndpoint ¶
func (e EntityCRUDDefinition) ListEndpoint(entity Entity) (string, error)
ListEndpoint returns the list URL. This can be used to list all instances of a type.
func (*EntityCRUDDefinition) PatchEndpoint ¶
func (e *EntityCRUDDefinition) PatchEndpoint(entity Entity) (string, error)
PatchEndpoint returns the URL to use for updating custom entity e.
func (*EntityCRUDDefinition) PostEndpoint ¶
func (e *EntityCRUDDefinition) PostEndpoint(entity Entity) (string, error)
PostEndpoint returns the URL to create an entity e of a Type.
func (*EntityCRUDDefinition) Type ¶
func (e *EntityCRUDDefinition) Type() Type
Type return the type of custom entitiy in Kong.
type EntityObject ¶
type EntityObject struct {
// contains filtered or unexported fields
}
EntityObject is a default implmentation of Entity interface.
func NewEntityObject ¶
func NewEntityObject(typ Type) *EntityObject
NewEntityObject creates a new EntityObject of type typ with content of object and foreign references as defined in ref.
func (*EntityObject) AddRelation ¶
func (E *EntityObject) AddRelation(k, v string)
AddRelation adds a foreign relation with another entity's ID.
func (*EntityObject) GetAllRelations ¶
func (E *EntityObject) GetAllRelations() map[string]string
GetAllRelations should return all relationship of current Entity.
func (*EntityObject) GetRelation ¶
func (E *EntityObject) GetRelation(k string) string
GetRelation should return foreign entity's ID that is associated with Entity.
func (*EntityObject) Object ¶
func (E *EntityObject) Object() Object
Object returns the object, an instance of a custom entity in Kong.
func (*EntityObject) SetObject ¶
func (E *EntityObject) SetObject(newObject Object)
SetObject sets the internal object to newObject.
func (*EntityObject) Type ¶
func (E *EntityObject) Type() Type
Type returns the type of the entity. Type() Type
type Object ¶
type Object map[string]interface{}
Object is an instance of a custom entity definition in Kong.
type Registry ¶
type Registry interface { // Register puts EntityCRUD in the internal // store and returns an error if the entity // of Type is already registered Register(Type, EntityCRUD) error // Lookup returns the EntityCRUD object associated // with typ, or nil if one is not Registered yet. Lookup(Type) EntityCRUD // Unregister unregisters the entity // registered with Type from the store. // It returns an // error if the Type was not registered // before this call. Unregister(Type) error }
Registry is a store of EntityCRUD objects
func NewDefaultRegistry ¶
func NewDefaultRegistry() Registry
NewDefaultRegistry returns a default registry