Documentation
¶
Index ¶
- Variables
- func AddHeaders(q map[string]string) func(*http.Request)
- func AddQuery(q map[string]string) func(*http.Request)
- func CreateOrUpdateWebhook(c UniversalClient, spec *tykv1alpha1.WebhookSpec) error
- func Do(r *http.Request) (*http.Response, error)
- func DoReload(c UniversalClient, fn func(u UniversalClient) error) error
- func Error(res *http.Response) error
- func IgnoreNotFound(err error) error
- func IsNotFound(err error) bool
- func IsTODO(err error) bool
- func JSON(res *http.Response, o interface{}) error
- func RunRequestKase(t *testing.T, e environmet.Env, fn func(Client) error, kase ...Kase)
- func SetHeaders(q map[string]string) func(*http.Request)
- type Client
- func (c Client) Call(method, url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) Delete(url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) Environment() environmet.Env
- func (c Client) Get(url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) JSON(method, url string, body interface{}, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) Post(url string, body io.Reader, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) PostJSON(url string, body interface{}, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) PutJSON(url string, body interface{}, fn ...func(*http.Request)) (*http.Response, error)
- func (c Client) Request(method, url string, body io.Reader) (*http.Request, error)
- type Kase
- type RequestKase
- type ResponseKase
- type UniversalApi
- type UniversalCertificate
- type UniversalClient
- type UniversalOrganization
- type UniversalSecurityPolicy
- type UniversalWebhook
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("Resource not found")
ErrNotFound is returned when an api call returns 404
View Source
var ErrTODO = errors.New("TODO: This feature is not implemented yet")
ErrTODO is returned when a feature is not yet implemented
Functions ¶
func CreateOrUpdateWebhook ¶
func CreateOrUpdateWebhook(c UniversalClient, spec *tykv1alpha1.WebhookSpec) error
func DoReload ¶
func DoReload(c UniversalClient, fn func(u UniversalClient) error) error
DoReload call HotReload if fn returns nil
func IgnoreNotFound ¶
IgnoreNotFound returns nil if err is ErrNotFound
func RunRequestKase ¶
RunRequestKase this helps check if we are sending a correct request. This assumes fn will only perform a single API call, this ignores the response it only validates we are sending correct path/method/headers
Types ¶
type Client ¶
type Client struct {
Env environmet.Env
Log logr.Logger
BeforeRequest func(*http.Request)
Do func(*http.Request) (*http.Response, error)
}
func (Client) Environment ¶
func (c Client) Environment() environmet.Env
type Kase ¶
type Kase struct {
Name string
Request RequestKase
Response *ResponseKase
}
Kase a single test case for an API call.
type RequestKase ¶
type ResponseKase ¶
type UniversalApi ¶
type UniversalApi interface {
Get(apiID string) (*v1.APIDefinitionSpec, error)
All() ([]v1.APIDefinitionSpec, error)
Create(spec *v1.APIDefinitionSpec) error
Update(def *v1.APIDefinitionSpec) error
Delete(id string) error
}
type UniversalCertificate ¶
type UniversalClient ¶
type UniversalClient interface {
Environment() environmet.Env
HotReload() error
Api() UniversalApi
SecurityPolicy() UniversalSecurityPolicy
Webhook() UniversalWebhook
Certificate() UniversalCertificate
Organization() UniversalOrganization
}
type UniversalOrganization ¶
type UniversalOrganization interface {
GetID() string
}
type UniversalSecurityPolicy ¶
type UniversalSecurityPolicy interface {
All() ([]tykv1alpha1.SecurityPolicySpec, error)
// Get retruns the policy with the given id.
Get(id string) (*tykv1alpha1.SecurityPolicySpec, error)
// Create creates a new def and updates id and other fields. It is up to the
// caller to update any fields that will be set after the policy has been
// created for instance _id
Create(def *tykv1alpha1.SecurityPolicySpec) error
// Update this will update an existing policy
Update(def *tykv1alpha1.SecurityPolicySpec) error
//Delete deletes policy id id
Delete(id string) error
}
type UniversalWebhook ¶
type UniversalWebhook interface {
All() ([]tykv1alpha1.WebhookSpec, error)
Get(id string) (*tykv1alpha1.WebhookSpec, error)
Create(*tykv1alpha1.WebhookSpec) error
Update(def *tykv1alpha1.WebhookSpec) error
Delete(id string) error
}
Click to show internal directories.
Click to hide internal directories.