tyk_api

package
v0.0.0-...-85d8d22 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Root endpoint = ""

	License     endpoint = "admin/license"
	AdminOrgs   endpoint = "admin/organisations/"
	AdminOrg    endpoint = "admin/organisations/{org-id}"
	OrgKey      endpoint = "admin/org/keys"
	SSO         endpoint = "admin/sso"
	AdminReload endpoint = "admin/system/reload"
	AdminUser   endpoint = "admin/users"

	APIDef      endpoint = "api/apis/"
	KeyDetail   endpoint = "api/apis/default/keys/{key-id}"
	Keys        endpoint = "api/keys"
	PolicyList  endpoint = "api/portal/policies?p=-1"
	DashResetPW endpoint = "api/users/{user-id}/actions/reset"
)

Variables

View Source
var ErrNotFound = errors.New("not found; endpoint may not exist on application")
View Source
var GetConf = func() *Config {
	if sconf == nil {
		sconf = &Config{}

		err := conf.GetModuleConf(sconf, "ARA_TYKAPI", nil)
		if err != nil {
			log.Fatal("Failed to unmarshal api client config: ", err)
		}

		SetDefaults()
	}

	return sconf
}

Functions

func SetDefaults

func SetDefaults()

Types

type APIResponseData

type APIResponseData struct {
	Status  string
	Message string
	Meta    interface{}
}

type CachedClient

type CachedClient interface {
	Add(name string, h Handler)
	Get(name string) Handler
}

CachedClient represents methods in cacheClient

func GetCachedClients

func GetCachedClients() CachedClient

GetCachedClients returns a singleton CachedClient

type Config

type Config struct {
	TykAPI map[string]*TykAPIConfig
}

type DashboardAPIDefinition

type DashboardAPIDefinition struct {
	APIDefinition   apidef.APIDefinition `json:"api_definition"`
	UserGroupOwners []string             `json:"user_group_owners,omitempty"`
	UserOwners      []string             `json:"user_owners,omitempty"`
}

type Handler

type Handler interface {
	CreateOrg(orgName, portalHostname string) (string, error)
	FetchOrg(orgID string) (interface{}, error)
	UpdateOrg(orgID string, orgData []byte) error
	CreateUser(fname, lname, email, pass, orgID string) (string, string, error)
	ResetPassword(key, uid, old, new string) error
	GetKeyDetail(key string) (*user.SessionState, error)
	CreateAccessToken(org string, accessList []user.AccessDefinition) (string, error)
	GetAllPolicies() ([]models.Policy, error)
	CreateAccessURL(orgID string) (string, error)
	CreateAPI(apiDef []byte) (string, error)
	GetAPIDetail(id string) (*DashboardAPIDefinition, error)
	DeleteAPI(id string) error
	ReloadDashboardUrls() error
	Init(cfg *TykAPIConfig) error
	CreateOrgKey(orgKeyData user.SessionState) (string, error)
	GetConf() *TykAPIConfig
	UpdateDashboardLicense(license string) error
}

func NewHandler

func NewHandler(cfg *TykAPIConfig) (Handler, error)

func NewMockHandler

func NewMockHandler(cfg *TykAPIConfig) (Handler, error)

type KeyResponseData

type KeyResponseData struct {
	Data  user.SessionState `json:"data"`
	KeyID string            `json:"key_id"`
}

type PolicyListResponse

type PolicyListResponse struct {
	Data []models.Policy `json:"data"`
}

type SSORequest

type SSORequest struct {
	ForSection   string
	OrgID        string
	EmailAddress string
}

type TykAPIConfig

type TykAPIConfig struct {
	DashboardEndpoint string
	Secret            string

	// AvailabilityTests is the number of availability checks that must pass before the API is considered available.
	// Defaults to 3.
	AvailabilityTests int

	// AvailabilityWait is the number of seconds to wait between availability checks.
	// Defaults to 10.
	AvailabilityWait int

	Mock bool
}

type TykAPIHandler

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

func (*TykAPIHandler) CreateAPI

func (t *TykAPIHandler) CreateAPI(apiDef []byte) (id string, err error)

func (*TykAPIHandler) CreateAccessToken

func (t *TykAPIHandler) CreateAccessToken(org string, accessList []user.AccessDefinition) (key string, err error)

func (*TykAPIHandler) CreateAccessURL

func (t *TykAPIHandler) CreateAccessURL(orgID string) (string, error)

func (*TykAPIHandler) CreateOrg

func (t *TykAPIHandler) CreateOrg(orgName, portalHostname string) (oID string, err error)

func (*TykAPIHandler) CreateOrgKey

func (t *TykAPIHandler) CreateOrgKey(keyData user.SessionState) (key string, err error)

func (*TykAPIHandler) CreateUser

func (t *TykAPIHandler) CreateUser(fname, lname, email, pass, orgID string) (accessKey, id string, err error)

func (*TykAPIHandler) DeleteAPI

func (t *TykAPIHandler) DeleteAPI(id string) (err error)

func (*TykAPIHandler) FetchOrg

func (t *TykAPIHandler) FetchOrg(orgID string) (orG interface{}, err error)

func (*TykAPIHandler) GetAPIDetail

func (t *TykAPIHandler) GetAPIDetail(id string) (data *DashboardAPIDefinition, err error)

func (*TykAPIHandler) GetAllPolicies

func (t *TykAPIHandler) GetAllPolicies() (pols []models.Policy, err error)

func (*TykAPIHandler) GetConf

func (t *TykAPIHandler) GetConf() *TykAPIConfig

func (*TykAPIHandler) GetKeyDetail

func (t *TykAPIHandler) GetKeyDetail(key string) (us *user.SessionState, err error)

func (*TykAPIHandler) Init

func (t *TykAPIHandler) Init(cfg *TykAPIConfig) error

func (*TykAPIHandler) ReloadDashboardUrls

func (t *TykAPIHandler) ReloadDashboardUrls() (err error)

func (*TykAPIHandler) ResetPassword

func (t *TykAPIHandler) ResetPassword(key, uid, old, new string) error

func (*TykAPIHandler) UpdateDashboardLicense

func (t *TykAPIHandler) UpdateDashboardLicense(license string) (err error)

func (*TykAPIHandler) UpdateOrg

func (t *TykAPIHandler) UpdateOrg(orgID string, orgData []byte) (err error)

type TykAPIMockHandler

type TykAPIMockHandler struct {
	OrgSessions map[string]*user.SessionState
	// contains filtered or unexported fields
}

func (*TykAPIMockHandler) CreateAPI

func (t *TykAPIMockHandler) CreateAPI(apiDef []byte) (string, error)

func (*TykAPIMockHandler) CreateAccessToken

func (t *TykAPIMockHandler) CreateAccessToken(org string, accessList []user.AccessDefinition) (string, error)

func (*TykAPIMockHandler) CreateAccessURL

func (t *TykAPIMockHandler) CreateAccessURL(orgID string) (string, error)

func (*TykAPIMockHandler) CreateOrg

func (t *TykAPIMockHandler) CreateOrg(orgName string, portal string) (string, error)

func (*TykAPIMockHandler) CreateOrgKey

func (t *TykAPIMockHandler) CreateOrgKey(keydata user.SessionState) (string, error)

func (*TykAPIMockHandler) CreateUser

func (t *TykAPIMockHandler) CreateUser(fname, lname, email, pass, orgID string) (string, string, error)

func (*TykAPIMockHandler) DeleteAPI

func (t *TykAPIMockHandler) DeleteAPI(id string) error

func (*TykAPIMockHandler) FetchOrg

func (t *TykAPIMockHandler) FetchOrg(orgID string) (interface{}, error)

func (*TykAPIMockHandler) GetAPIDetail

func (t *TykAPIMockHandler) GetAPIDetail(id string) (*DashboardAPIDefinition, error)

func (*TykAPIMockHandler) GetAllPolicies

func (t *TykAPIMockHandler) GetAllPolicies() ([]models.Policy, error)

func (*TykAPIMockHandler) GetConf

func (t *TykAPIMockHandler) GetConf() *TykAPIConfig

func (*TykAPIMockHandler) GetKeyDetail

func (t *TykAPIMockHandler) GetKeyDetail(key string) (*user.SessionState, error)

func (*TykAPIMockHandler) GetOrgKey

func (t *TykAPIMockHandler) GetOrgKey(orgID string) (*user.SessionState, error)

func (*TykAPIMockHandler) Init

func (t *TykAPIMockHandler) Init(cfg *TykAPIConfig) error

func (*TykAPIMockHandler) ReloadDashboardUrls

func (t *TykAPIMockHandler) ReloadDashboardUrls() error

func (*TykAPIMockHandler) ResetPassword

func (t *TykAPIMockHandler) ResetPassword(key, uid, old, new string) error

func (*TykAPIMockHandler) UpdateDashboardLicense

func (t *TykAPIMockHandler) UpdateDashboardLicense(license string) error

func (*TykAPIMockHandler) UpdateOrg

func (t *TykAPIMockHandler) UpdateOrg(orgID string, orgData []byte) error

Jump to

Keyboard shortcuts

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