Documentation ¶
Index ¶
- type Client
- type ClientIMPL
- func (c *ClientIMPL) GetCustomHTTPHeaders() http.Header
- func (c *ClientIMPL) Query(ctx context.Context, cfg RequestConfigRenderer, resp interface{}) (RespMeta, error)
- func (c *ClientIMPL) QueryParams() QueryParamsEncoder
- func (c *ClientIMPL) QueryParamsWithFields(fp FieldProvider) QueryParamsEncoder
- func (c *ClientIMPL) SetCustomHTTPHeaders(headers http.Header)
- func (c *ClientIMPL) SetLogger(logger Logger)
- func (c *ClientIMPL) SetTraceID(ctx context.Context, traceID string) context.Context
- func (c *ClientIMPL) TraceID(ctx context.Context) string
- type ContextKey
- type ErrorMsg
- type FieldProvider
- type Logger
- type PaginationInfo
- type QueryParams
- func (qp *QueryParams) Async(value bool) QueryParamsEncoder
- func (qp *QueryParams) Encode() string
- func (qp *QueryParams) Limit(value int) QueryParamsEncoder
- func (qp *QueryParams) Offset(value int) QueryParamsEncoder
- func (qp *QueryParams) Order(fields ...string) QueryParamsEncoder
- func (qp *QueryParams) RawArg(key string, value string) QueryParamsEncoder
- func (qp *QueryParams) Select(fields ...string) QueryParamsEncoder
- type QueryParamsEncoder
- type RequestConfig
- type RequestConfigRenderer
- type RespMeta
- type TimeoutSemaphore
- type TimeoutSemaphoreError
- type TimeoutSemaphoreInterface
- type Traceable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Traceable Query( ctx context.Context, cfg RequestConfigRenderer, resp interface{}) (RespMeta, error) QueryParams() QueryParamsEncoder QueryParamsWithFields(provider FieldProvider) QueryParamsEncoder GetCustomHTTPHeaders() http.Header SetCustomHTTPHeaders(headers http.Header) SetLogger(logger Logger) }
ApiClient is PowerStore API client interface
type ClientIMPL ¶
type ClientIMPL struct {
// contains filtered or unexported fields
}
ClientIMPL struct holds API client settings
func New ¶
func New(apiURL string, username string, password string, insecure bool, defaultTimeout int64, rateLimit int, requestIDKey ContextKey, ) (*ClientIMPL, error)
New creates and initialize API client
func (*ClientIMPL) GetCustomHTTPHeaders ¶ added in v1.8.0
func (c *ClientIMPL) GetCustomHTTPHeaders() http.Header
GetCustomHTTPHeaders method retrieves http headers
func (*ClientIMPL) Query ¶
func (c *ClientIMPL) Query( ctx context.Context, cfg RequestConfigRenderer, resp interface{}, ) (RespMeta, error)
Query method do http request and reads response to provided struct
func (*ClientIMPL) QueryParams ¶
func (c *ClientIMPL) QueryParams() QueryParamsEncoder
QueryParams method returns QueryParamsEncoder
func (*ClientIMPL) QueryParamsWithFields ¶
func (c *ClientIMPL) QueryParamsWithFields(fp FieldProvider) QueryParamsEncoder
QueryParamsWithFields method returns QueryParamsEncoder with configured select values
func (*ClientIMPL) SetCustomHTTPHeaders ¶
func (c *ClientIMPL) SetCustomHTTPHeaders(headers http.Header)
SetCustomHTTPHeaders method register headers which will be sent with every request
func (*ClientIMPL) SetLogger ¶
func (c *ClientIMPL) SetLogger(logger Logger)
SetLogger set logger for use by gopowerstore
func (*ClientIMPL) SetTraceID ¶
SetTraceID set tracing id to context
type ContextKey ¶ added in v1.14.1
type ContextKey string
type ErrorMsg ¶
type ErrorMsg struct { StatusCode int `json:"-"` Severity string Message string `json:"message_l10n"` Arguments []string }
ErrorMsg is internal error representation
type FieldProvider ¶
type FieldProvider interface {
Fields() []string
}
FieldProvider provide method which return required fields list
type Logger ¶
type Logger interface { Info(ctx context.Context, format string, args ...interface{}) Debug(ctx context.Context, format string, args ...interface{}) Error(ctx context.Context, format string, args ...interface{}) }
Logger interface for gopowerstore custom logger
type PaginationInfo ¶
type PaginationInfo struct { // first element index in response First int // last element index in response Last int // total elements count Total int // indicate that response is paginated IsPaginate bool }
PaginationInfo stores information about pagination
type QueryParams ¶
type QueryParams struct {
// contains filtered or unexported fields
}
QueryParams struct holds additional query options for PowerStore API
func (*QueryParams) Async ¶
func (qp *QueryParams) Async(value bool) QueryParamsEncoder
Async set value of QueryParams.asyncParam
func (*QueryParams) Encode ¶
func (qp *QueryParams) Encode() string
Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") sorted by key.
func (*QueryParams) Limit ¶
func (qp *QueryParams) Limit(value int) QueryParamsEncoder
Limit set value of QueryParams.limitParam
func (*QueryParams) Offset ¶
func (qp *QueryParams) Offset(value int) QueryParamsEncoder
Offset set value of QueryParams.offsetParam
func (*QueryParams) Order ¶
func (qp *QueryParams) Order(fields ...string) QueryParamsEncoder
Order adds values to QueryParams.orderParam array
func (*QueryParams) RawArg ¶
func (qp *QueryParams) RawArg(key string, value string) QueryParamsEncoder
RawArg allows to set query params in key/value form
func (*QueryParams) Select ¶
func (qp *QueryParams) Select(fields ...string) QueryParamsEncoder
Select adds values to QueryParams.selectParam array
type QueryParamsEncoder ¶
type QueryParamsEncoder interface { RawArg(string, string) QueryParamsEncoder Select(...string) QueryParamsEncoder Order(...string) QueryParamsEncoder Limit(int) QueryParamsEncoder Offset(int) QueryParamsEncoder Async(bool) QueryParamsEncoder Encode() string }
QueryParamsEncoder interface provide ability to manipulate query string parameters
type RequestConfig ¶
type RequestConfig struct { // http method Name Method string // target endpoint Endpoint string // id of the entity ID string // action which perform on entity Action string // addition query params QueryParams QueryParamsEncoder // request body Body interface{} }
RequestConfig provide options for the request
func (RequestConfig) RenderRequestConfig ¶
func (rc RequestConfig) RenderRequestConfig() RequestConfig
RenderRequestConfig is RequestConfigRenderer implementation
type RequestConfigRenderer ¶
type RequestConfigRenderer interface {
RenderRequestConfig() RequestConfig
}
RequestConfigRenderer provides methods for rendering request config
type RespMeta ¶
type RespMeta struct { // http status Status int // pagination data Pagination PaginationInfo }
RespMeta struct represents additional information about response
type TimeoutSemaphore ¶ added in v1.14.1
func NewTimeoutSemaphore ¶ added in v1.3.0
func NewTimeoutSemaphore(timeout int64, rateLimit int, logger Logger) *TimeoutSemaphore
func (*TimeoutSemaphore) Acquire ¶ added in v1.14.1
func (ts *TimeoutSemaphore) Acquire(ctx context.Context) error
func (*TimeoutSemaphore) Release ¶ added in v1.14.1
func (ts *TimeoutSemaphore) Release(ctx context.Context)
func (*TimeoutSemaphore) SetLogger ¶ added in v1.14.1
func (ts *TimeoutSemaphore) SetLogger(logger Logger) TimeoutSemaphoreInterface
type TimeoutSemaphoreError ¶ added in v1.3.0
type TimeoutSemaphoreError struct {
// contains filtered or unexported fields
}
func (*TimeoutSemaphoreError) Error ¶ added in v1.3.0
func (e *TimeoutSemaphoreError) Error() string
type TimeoutSemaphoreInterface ¶ added in v1.3.0
type TimeoutSemaphoreInterface interface { Acquire(ctx context.Context) error Release(ctx context.Context) SetLogger(logger Logger) TimeoutSemaphoreInterface }
TimeoutSemaphoreInterface gives ability to limit rate of requests to PowerStore API