Documentation ¶
Overview ¶
Package nb makes client API calls to noobaa servers.
Index ¶
- func FindPortByName(srv *corev1.Service, portName string) *corev1.ServicePort
- func GetAPIPortName(api string) string
- type APIRouter
- type APIRouterNodePort
- type APIRouterPodPort
- type APIRouterServicePort
- type Client
- type CreateAuthParams
- type CreateAuthReply
- type CreateBucketParams
- type CreateBucketReply
- type CreateSystemParams
- type CreateSystemReply
- type DeleteBucketParams
- type DeleteBucketReply
- type ListAccountsReply
- type ListBucketsReply
- type RPCClient
- func (c *RPCClient) Call(req RPCRequest, res RPCResponseIfc) error
- func (c *RPCClient) CreateAuthAPI(params CreateAuthParams) (CreateAuthReply, error)
- func (c *RPCClient) CreateBucketAPI(params CreateBucketParams) (CreateBucketReply, error)
- func (c *RPCClient) CreateSystemAPI(params CreateSystemParams) (CreateSystemReply, error)
- func (c *RPCClient) DeleteBucketAPI(params DeleteBucketParams) (DeleteBucketReply, error)
- func (c *RPCClient) GetAuthToken() string
- func (c *RPCClient) ListAccountsAPI() (ListAccountsReply, error)
- func (c *RPCClient) ListBucketsAPI() (ListBucketsReply, error)
- func (c *RPCClient) ReadAuthAPI() (ReadAuthReply, error)
- func (c *RPCClient) SetAuthToken(token string)
- type RPCError
- type RPCRequest
- type RPCResponse
- type RPCResponseIfc
- type ReadAuthReply
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindPortByName ¶
func FindPortByName(srv *corev1.Service, portName string) *corev1.ServicePort
FindPortByName returns the port in the service that matches the given name.
func GetAPIPortName ¶
GetAPIPortName maps every noobaa api name to the service port name that serves it.
Types ¶
type APIRouter ¶
APIRouter should be able to map noobaa api names to actual addresses See implementations below: APIRouterNodePort, APIRouterPodPort, APIRouterServicePort
type APIRouterNodePort ¶
APIRouterNodePort uses the service node port to route to NodeIP:NodePorts
func (*APIRouterNodePort) GetAddress ¶
func (r *APIRouterNodePort) GetAddress(api string) string
GetAddress implements the router
type APIRouterPodPort ¶
APIRouterPodPort uses the service target port to route to PodIP:TargetPort
func (*APIRouterPodPort) GetAddress ¶
func (r *APIRouterPodPort) GetAddress(api string) string
GetAddress implements the router
type APIRouterServicePort ¶
APIRouterServicePort uses the service port to route to Srv.Namespace:Port
func (*APIRouterServicePort) GetAddress ¶
func (r *APIRouterServicePort) GetAddress(api string) string
GetAddress implements the router
type Client ¶
type Client interface { SetAuthToken(token string) GetAuthToken() string ReadAuthAPI() (ReadAuthReply, error) ListAccountsAPI() (ListAccountsReply, error) ListBucketsAPI() (ListBucketsReply, error) CreateAuthAPI(CreateAuthParams) (CreateAuthReply, error) CreateSystemAPI(CreateSystemParams) (CreateSystemReply, error) CreateBucketAPI(CreateBucketParams) (CreateBucketReply, error) DeleteBucketAPI(DeleteBucketParams) (DeleteBucketReply, error) }
Client is the interface providing typed noobaa API calls
type CreateAuthParams ¶ added in v1.0.0
type CreateAuthParams struct { System string `json:"system"` Role string `json:"role"` Email string `json:"email"` Password string `json:"password"` }
CreateAuthParams is the params of auth_api.create_auth()
type CreateAuthReply ¶ added in v1.0.0
type CreateAuthReply struct {
Token string `json:"token"`
}
CreateAuthReply is the reply of auth_api.create_auth()
type CreateBucketParams ¶ added in v1.0.0
type CreateBucketParams struct {
Name string `json:"name"`
}
CreateBucketParams is the params of bucket_api.create_bucket()
type CreateBucketReply ¶ added in v1.0.0
type CreateBucketReply struct { }
CreateBucketReply is the reply of bucket_api.create_bucket()
type CreateSystemParams ¶
type CreateSystemParams struct { Name string `json:"name"` Email string `json:"email"` Password string `json:"password"` }
CreateSystemParams is the params of system_api.create_system()
type CreateSystemReply ¶
type CreateSystemReply struct { Token string `json:"token"` OperatorToken string `json:"operator_token"` }
CreateSystemReply is the reply of system_api.create_system()
type DeleteBucketParams ¶ added in v1.0.0
type DeleteBucketParams struct {
Name string `json:"name"`
}
DeleteBucketParams is the params of bucket_api.delete_bucket()
type DeleteBucketReply ¶ added in v1.0.0
type DeleteBucketReply struct { }
DeleteBucketReply is the reply of bucket_api.delete_bucket()
type ListAccountsReply ¶
type ListAccountsReply struct { Accounts []struct { Name string `json:"name"` Email string `json:"email"` AccessKeys []struct { AccessKey string `json:"access_key"` SecretKey string `json:"secret_key"` } `json:"access_keys"` } `json:"accounts"` }
ListAccountsReply is the reply to account_api.list_accounts()
type ListBucketsReply ¶ added in v1.0.0
type ListBucketsReply struct { Buckets []struct { Name string `json:"name"` } `json:"buckets"` }
type RPCClient ¶
RPCClient makes API calls to noobaa. Requests to noobaa are plain http requests with json request and json response.
func (*RPCClient) Call ¶
func (c *RPCClient) Call(req RPCRequest, res RPCResponseIfc) error
Call an API method to noobaa. The response type should be defined to include RPCResponseIfc inline. This is needed in order for json.Unmarshal() to decode into the reply structure.
func (*RPCClient) CreateAuthAPI ¶ added in v1.0.0
func (c *RPCClient) CreateAuthAPI(params CreateAuthParams) (CreateAuthReply, error)
CreateAuthAPI calls auth_api.create_auth()
func (*RPCClient) CreateBucketAPI ¶ added in v1.0.0
func (c *RPCClient) CreateBucketAPI(params CreateBucketParams) (CreateBucketReply, error)
CreateBucketAPI calls bucket_api.create_bucket()
func (*RPCClient) CreateSystemAPI ¶
func (c *RPCClient) CreateSystemAPI(params CreateSystemParams) (CreateSystemReply, error)
CreateSystemAPI calls system_api.create_system()
func (*RPCClient) DeleteBucketAPI ¶ added in v1.0.0
func (c *RPCClient) DeleteBucketAPI(params DeleteBucketParams) (DeleteBucketReply, error)
DeleteBucketAPI calls bucket_api.delete_bucket()
func (*RPCClient) GetAuthToken ¶ added in v1.0.0
GetAuthToken is getting the client token for next calls
func (*RPCClient) ListAccountsAPI ¶
func (c *RPCClient) ListAccountsAPI() (ListAccountsReply, error)
ListAccountsAPI calls account_api.list_accounts()
func (*RPCClient) ListBucketsAPI ¶ added in v1.0.0
func (c *RPCClient) ListBucketsAPI() (ListBucketsReply, error)
ListBucketsAPI calls bucket_api.list_buckets()
func (*RPCClient) ReadAuthAPI ¶ added in v1.0.0
func (c *RPCClient) ReadAuthAPI() (ReadAuthReply, error)
CreateAuthAPI calls auth_api.read_auth()
func (*RPCClient) SetAuthToken ¶
SetAuthToken is setting the client token for next calls
type RPCRequest ¶
type RPCRequest struct { API string `json:"api"` Method string `json:"method"` AuthToken string `json:"auth_token,omitempty"` Params interface{} `json:"params,omitempty"` }
RPCRequest is the structure encoded in every request
type RPCResponse ¶
type RPCResponse struct { Op string `json:"op"` RequestID string `json:"reqid"` Took float64 `json:"took"` Error *RPCError `json:"error,omitempty"` }
RPCResponse is the structure encoded in every response Specific API response structures should include this inline, and add the standard Reply field with the specific fields. Refer to examples.
func (*RPCResponse) Response ¶
func (r *RPCResponse) Response() *RPCResponse
Response is implementing the RPCResponseIfc interface
type RPCResponseIfc ¶
type RPCResponseIfc interface {
Response() *RPCResponse
}
RPCResponseIfc is the interface for response structs. RPCResponse is the only real implementor of it.
type ReadAuthReply ¶ added in v1.0.0
type ReadAuthReply struct { Account struct { Name string `json:"name"` Email string `json:"email"` IsSupport bool `json:"is_support"` MustChangePassword bool `json:"must_change_password"` } `json:"account"` System struct { Name string `json:"name"` } `json:"system"` AuthorizedBy string `json:"authorized_by"` Role string `json:"role"` Extra map[string]interface{} `json:"extra"` }
ReadAuthReply is the reply of auth_api.read_auth()