mirror of
https://github.com/rancher/norman.git
synced 2025-09-01 23:36:58 +00:00
Add interface for APIBaseClient
Problem: There are three clients based off the APIBaseClient so three code paths are needed to make the same type of call in each client Solution: Add an interface so any client that satisfies it can be used to make these calls
This commit is contained in:
committed by
Darren Shepherd
parent
93bfc4ea3a
commit
9846d7349c
@@ -28,6 +28,25 @@ var (
|
||||
dialer = &websocket.Dialer{}
|
||||
)
|
||||
|
||||
type APIBaseClientInterface interface {
|
||||
Websocket(url string, headers map[string][]string) (*websocket.Conn, *http.Response, error)
|
||||
List(schemaType string, opts *types.ListOpts, respObject interface{}) error
|
||||
Post(url string, createObj interface{}, respObject interface{}) error
|
||||
GetLink(resource types.Resource, link string, respObject interface{}) error
|
||||
Create(schemaType string, createObj interface{}, respObject interface{}) error
|
||||
Update(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error
|
||||
ByID(schemaType string, id string, respObject interface{}) error
|
||||
Delete(existing *types.Resource) error
|
||||
Reload(existing *types.Resource, output interface{}) error
|
||||
Action(schemaType string, action string, existing *types.Resource, inputObject, respObject interface{}) error
|
||||
}
|
||||
|
||||
type APIBaseClient struct {
|
||||
Ops *APIOperations
|
||||
Opts *ClientOpts
|
||||
Types map[string]types.Schema
|
||||
}
|
||||
|
||||
type ClientOpts struct {
|
||||
URL string
|
||||
AccessKey string
|
||||
|
Reference in New Issue
Block a user