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 CreateSystemParams
- type CreateSystemReply
- type ListAccountsReply
- type RPCClient
- type RPCError
- type RPCRequest
- type RPCResponse
- type RPCResponseIfc
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)
CreateSystemAPI(CreateSystemParams) (CreateSystemReply, error)
ListAccountsAPI() (ListAccountsReply, error)
}
Client is the interface providing typed noobaa API calls
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"`
}
CreateSystemReply is the reply of system_api.create_system()
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 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) CreateSystemAPI ¶
func (c *RPCClient) CreateSystemAPI(params CreateSystemParams) (CreateSystemReply, error)
CreateSystemAPI calls system_api.create_system()
func (*RPCClient) ListAccountsAPI ¶
func (c *RPCClient) ListAccountsAPI() (ListAccountsReply, error)
ListAccountsAPI calls account_api.list_accounts()
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.