diff --git a/clientbase/client.go b/clientbase/client.go deleted file mode 100644 index 69805cab..00000000 --- a/clientbase/client.go +++ /dev/null @@ -1,19 +0,0 @@ -package clientbase - -import ( - "net/http" - - "github.com/rancher/norman/types" -) - -type APIBaseClient struct { - Ops *APIOperations - Opts *ClientOpts - Types map[string]types.Schema -} - -type APIOperations struct { - Opts *ClientOpts - Types map[string]types.Schema - Client *http.Client -} diff --git a/clientbase/common.go b/clientbase/common.go index 73dcb7a0..aa3e9662 100644 --- a/clientbase/common.go +++ b/clientbase/common.go @@ -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 diff --git a/clientbase/ops.go b/clientbase/ops.go index ebeccb61..b96d1760 100644 --- a/clientbase/ops.go +++ b/clientbase/ops.go @@ -12,6 +12,12 @@ import ( "github.com/rancher/norman/types" ) +type APIOperations struct { + Opts *ClientOpts + Types map[string]types.Schema + Client *http.Client +} + func (a *APIOperations) setupRequest(req *http.Request) { req.Header.Add("Authorization", a.Opts.getAuthHeader()) }