Documentation ¶
Index ¶
Constants ¶
const ( ContentTypeXML = "application/xml" ContentTypeJSON = "application/json" )
Allowed content types.
const AuthRetriesMax = 3
AuthRetriesMax is the maximum number of times the client will attempt to login before returning an error.
Variables ¶
var ( // ErrAuthorization is returned when the client is unable to authenticate with the server. ErrAuthorization = errors.New("authorization") // ErrContentType is returned when the client or server responds with an unknown content type header. ErrContentType = errors.New("content type") )
Functions ¶
func HandleResponse ¶
HandleResponse handles custom behavior based on server response.
Types ¶
type AuthService ¶
type AuthService struct { // Gateway is the auth endpoint Gateway string `json:"gateway"` SharedSecret string `json:"sharedSecret"` // PodName is the GraphQL Pod name PodName string `json:"podName"` // Namespace is the GraphQL Namespace name Namespace string `json:"namespace"` // ObjectScaleID is just that ObjectScaleID string `json:"objectScaleID"` // contains filtered or unexported fields }
AuthService is an in-cluster Authenticator.
func (*AuthService) IsAuthenticated ¶
func (auth *AuthService) IsAuthenticated() bool
IsAuthenticated returns true if the authenticated has been established. This does not mean the next request is guaranteed to succeed as authentication can become expired.
func (*AuthService) Token ¶
func (auth *AuthService) Token() string
Token returns the current authentication token.
type AuthUser ¶
type AuthUser struct { // Gateway is the auth endpoint Gateway string `json:"gateway"` // Username used to authenticate management user Username string `json:"username"` // Password used to authenticate management user Password string `json:"password"` // contains filtered or unexported fields }
AuthUser is an out-of-cluster or username+password based Authenticator.
func (*AuthUser) IsAuthenticated ¶
IsAuthenticated returns true if the authenticated has been established. This does not mean the next request is guaranteed to succeed as authentication can become expired.
type Authenticator ¶
type Authenticator interface { // IsAuthenticated returns true if the authenticated has been established. This // does not mean the next request is guaranteed to succeed as authentication can // become expired. IsAuthenticated() bool // Login obtains fresh authentication token(s) from the server. Login(context.Context, *http.Client) error // Token returns the current authentication token. Token() string }
Authenticator can perform a Login to the gateway.
type CountWriter ¶
type CountWriter struct {
N int
}
CountWriter is an io.Writer that counts bytes written without actually writing anything.
type LogWriter ¶ added in v0.2.0
type LogWriter struct {
// contains filtered or unexported fields
}
type RemoteCaller ¶
type RemoteCaller interface {
MakeRemoteCall(ctx context.Context, r Request, into interface{}) error
}
RemoteCaller interface is used to create backend calls. into represents type, _into_ which data will be unmarshalled. Naming follows Effective Go naming convention https://go.dev/doc/effective_go#interface-names
type Request ¶
type Request struct { // Method is the method of REST API request Method string // Path is the path of REST API request Path string // Body is the body of REST API request Body interface{} // ContentType is the body of REST API request ContentType string // Params are the parameters of the REST API request Params map[string]string }
Request is an ObjectScale API request wrapper.
func (Request) HTTPWithContext ¶
HTTPWithContext converts the Request data into an http.Request object.
type Simple ¶
type Simple struct { // Endpoint is the URL of the management API Endpoint string `json:"endpoint"` // Authenticator!=nil means Authenticator.Login will be called to // obtain login credentials. Authenticator Authenticator // Should X-EMC-Override header be added into the request OverrideHeader bool HTTPClient *http.Client // contains filtered or unexported fields }
Simple is the simple client definition.
func (*Simple) MakeRemoteCall ¶
MakeRemoteCall executes an API request against the client endpoint, returning the object body of the response into a response object.