Documentation ¶
Index ¶
- func B64ToStr(enc string) ([]byte, error)
- func Bool(v bool) *bool
- func BoolValue(v *bool) bool
- func GetDefaultPangeaLogger() *zerolog.Logger
- func GetHashPrefix(h string, len uint) string
- func HashSHA1(i string) string
- func HashSHA256(i string) string
- func HashSHA512(i string) string
- func Int(v int) *int
- func IntValue(v *int) int
- func PangeaTime(v pu.PangeaTimestamp) *pu.PangeaTimestamp
- func StrToB64(dec string) string
- func String(v string) *string
- func StringValue(v *string) string
- func Stringify(obj interface{}) string
- func StringifyIndented(obj interface{}) string
- func Time(v time.Time) *time.Time
- type APIError
- type AcceptedError
- type BaseError
- type BaseRequest
- type BaseService
- func (bs *BaseService) GetPendingRequestID() []string
- func (bs *BaseService) PollResultByError(ctx context.Context, e AcceptedError) (*PangeaResponse[any], error)
- func (bs *BaseService) PollResultByID(ctx context.Context, rid string, v any) (*PangeaResponse[any], error)
- func (bs *BaseService) PollResultRaw(ctx context.Context, rid string) (*PangeaResponse[map[string]any], error)
- type BaseServicer
- type Client
- func (c *Client) BareDo(ctx context.Context, req *http.Request) (*http.Response, error)
- func (c *Client) CheckResponse(r *Response, v any) error
- func (c *Client) Do(ctx context.Context, req *http.Request, v any) (*Response, error)
- func (c *Client) FetchAcceptedResponse(ctx context.Context, reqID string, v interface{}) (*Response, error)
- func (c *Client) GetPendingRequestID() []string
- func (c *Client) NewRequest(method, urlStr string, body ConfigIDer) (*http.Request, error)
- func (c *Client) NewRequestMultPart(method, urlStr string, body interface{}, file io.Reader) (*http.Request, error)
- func (c *Client) SetHeaders(req *http.Request)
- type ClientOption
- type Config
- type ConfigIDer
- type ErrorField
- type Filter
- type FilterBase
- type FilterCommon
- type FilterEqual
- type FilterMatch
- type FilterRange
- func (f *FilterRange[T]) GreaterThan() *T
- func (f *FilterRange[T]) GreaterThanEqual() *T
- func (f *FilterRange[T]) LessThan() *T
- func (f *FilterRange[T]) LessThanEqual() *T
- func (f *FilterRange[T]) SetGreaterThan(value *T)
- func (f *FilterRange[T]) SetGreaterThanEqual(value *T)
- func (f *FilterRange[T]) SetLessThan(value *T)
- func (f *FilterRange[T]) SetLessThanEqual(value *T)
- type Option
- type PangeaErrors
- type PangeaResponse
- type Response
- type ResponseHeader
- type RetryConfig
- type UnmarshalError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func BoolValue ¶
BoolValue is a helper routine that returns the value of a bool pointer or a default value if nil
func GetDefaultPangeaLogger ¶
func GetHashPrefix ¶
func HashSHA256 ¶
func HashSHA512 ¶ added in v2.3.0
func Int ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
func IntValue ¶
IntValue is a helper routine that returns the value of a int pointer or a default value if nil
func PangeaTime ¶
func PangeaTime(v pu.PangeaTimestamp) *pu.PangeaTimestamp
Time is a helper routine that allocates a new PangeaTimestamp value to store v and returns a pointer to it.
func String ¶
String is a helper routine that allocates a new string value to store v and returns a pointer to it.
func StringValue ¶
StringValue is a helper routine that returns the value of a string pointer or a default value if nil
func Stringify ¶
func Stringify(obj interface{}) string
Stringify returns the string representation of a json object.
func StringifyIndented ¶ added in v2.2.0
func StringifyIndented(obj interface{}) string
Stringify returns the string representation of a json object.
Types ¶
type APIError ¶
type APIError struct { BaseError // the reponse header of the request if any ResponseHeader *ResponseHeader // the result of the request RawResult json.RawMessage // error details PangeaErrors PangeaErrors }
func NewAPIError ¶
type AcceptedError ¶
type AcceptedError struct { ResponseHeader ResultField any }
func (*AcceptedError) Error ¶
func (e *AcceptedError) Error() string
func (*AcceptedError) Is ¶
func (e *AcceptedError) Is(target error) bool
Is returns whether the provided error equals this error.
func (*AcceptedError) ReqID ¶
func (e *AcceptedError) ReqID() string
ReqID is a helper function to get the request ID
type BaseError ¶
type BaseRequest ¶
type BaseRequest struct {
ConfigID string `json:"config_id,omitempty"`
}
func (*BaseRequest) GetConfigID ¶
func (br *BaseRequest) GetConfigID() string
func (*BaseRequest) SetConfigID ¶
func (br *BaseRequest) SetConfigID(c string)
type BaseService ¶
type BaseService struct {
Client *Client
}
func NewBaseService ¶
func NewBaseService(name string, baseCfg *Config) BaseService
func (*BaseService) GetPendingRequestID ¶
func (bs *BaseService) GetPendingRequestID() []string
func (*BaseService) PollResultByError ¶
func (bs *BaseService) PollResultByError(ctx context.Context, e AcceptedError) (*PangeaResponse[any], error)
func (*BaseService) PollResultByID ¶
func (bs *BaseService) PollResultByID(ctx context.Context, rid string, v any) (*PangeaResponse[any], error)
func (*BaseService) PollResultRaw ¶
func (bs *BaseService) PollResultRaw(ctx context.Context, rid string) (*PangeaResponse[map[string]any], error)
type BaseServicer ¶ added in v2.3.0
type BaseServicer interface { GetPendingRequestID() []string PollResultByError(ctx context.Context, e AcceptedError) (*PangeaResponse[any], error) PollResultByID(ctx context.Context, rid string, v any) (*PangeaResponse[any], error) PollResultRaw(ctx context.Context, requestID string) (*PangeaResponse[map[string]any], error) }
type Client ¶
type Client struct { // Client logger Logger zerolog.Logger // contains filtered or unexported fields }
A Client manages communication with the Pangea API.
func (*Client) BareDo ¶
BareDo sends an API request and lets you handle the api response.
If an error or API Error occurs, the error will contain more information. Otherwise you are supposed to read and close the response's Body.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v is nil, and no error hapens, the response is returned as is. The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.
The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.
func (*Client) FetchAcceptedResponse ¶
func (c *Client) FetchAcceptedResponse(ctx context.Context, reqID string, v interface{}) (*Response, error)
FetchAcceptedResponse retries the
func (*Client) GetPendingRequestID ¶
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the Domain of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Client) NewRequestMultPart ¶
func (*Client) SetHeaders ¶
type ClientOption ¶ added in v2.3.0
func ClientWithConfigID ¶ added in v2.3.0
func ClientWithConfigID(cid string) ClientOption
type Config ¶
type Config struct { // The Bearer token used to authenticate requests. Token string // Config ID for multi-config projects // @deprecated: Set config_id with options in service initialization if supported ConfigID string // The HTTP client to be used by the client. // It defaults to defaults.HTTPClient HTTPClient *http.Client // Base domain for API requests. Domain string // Set to true to use plain http Insecure bool // Set to "local" for testing locally Enviroment string // AdditionalHeaders is a map of additional headers to be sent with the request. AdditionalHeaders map[string]string // Custom user agent is a string to be added to pangea sdk user agent header and identify app CustomUserAgent string // if it should retry request // if HTTPClient is set in the config this value won't take effect Retry bool // Enable queued request retry support QueuedRetryEnabled bool // Timeout used to poll results after 202 (in secs) PollResultTimeout time.Duration // Retry config defaults to a base retry option RetryConfig *RetryConfig // Logger Logger *zerolog.Logger }
type ConfigIDer ¶
type ErrorField ¶
type FilterBase ¶ added in v2.3.0
type FilterBase struct {
// contains filtered or unexported fields
}
func NewFilterBase ¶ added in v2.3.0
func NewFilterBase(f Filter) *FilterBase
func (FilterBase) Filter ¶ added in v2.3.0
func (fb FilterBase) Filter() Filter
type FilterCommon ¶ added in v2.3.0
type FilterCommon struct {
// contains filtered or unexported fields
}
type FilterEqual ¶ added in v2.3.0
type FilterEqual[T any] struct { FilterCommon }
func NewFilterEqual ¶ added in v2.3.0
func NewFilterEqual[T any](name string, filter *Filter) *FilterEqual[T]
func (*FilterEqual[T]) Get ¶ added in v2.3.0
func (f *FilterEqual[T]) Get() *T
func (*FilterEqual[T]) Set ¶ added in v2.3.0
func (f *FilterEqual[T]) Set(value *T)
type FilterMatch ¶ added in v2.3.0
type FilterMatch[T any] struct { FilterEqual[T] }
func NewFilterMatch ¶ added in v2.3.0
func NewFilterMatch[T any](name string, filter *Filter) *FilterMatch[T]
func (*FilterMatch[T]) Contains ¶ added in v2.3.0
func (f *FilterMatch[T]) Contains() []T
func (*FilterMatch[T]) In ¶ added in v2.3.0
func (f *FilterMatch[T]) In() []T
func (*FilterMatch[T]) SetContains ¶ added in v2.3.0
func (f *FilterMatch[T]) SetContains(value []T)
func (*FilterMatch[T]) SetIn ¶ added in v2.3.0
func (f *FilterMatch[T]) SetIn(value []T)
type FilterRange ¶ added in v2.3.0
type FilterRange[T any] struct { FilterEqual[T] }
func NewFilterRange ¶ added in v2.3.0
func NewFilterRange[T any](name string, filter *Filter) *FilterRange[T]
func (*FilterRange[T]) GreaterThan ¶ added in v2.3.0
func (f *FilterRange[T]) GreaterThan() *T
func (*FilterRange[T]) GreaterThanEqual ¶ added in v2.3.0
func (f *FilterRange[T]) GreaterThanEqual() *T
func (*FilterRange[T]) LessThan ¶ added in v2.3.0
func (f *FilterRange[T]) LessThan() *T
func (*FilterRange[T]) LessThanEqual ¶ added in v2.3.0
func (f *FilterRange[T]) LessThanEqual() *T
func (*FilterRange[T]) SetGreaterThan ¶ added in v2.3.0
func (f *FilterRange[T]) SetGreaterThan(value *T)
func (*FilterRange[T]) SetGreaterThanEqual ¶ added in v2.3.0
func (f *FilterRange[T]) SetGreaterThanEqual(value *T)
func (*FilterRange[T]) SetLessThan ¶ added in v2.3.0
func (f *FilterRange[T]) SetLessThan(value *T)
func (*FilterRange[T]) SetLessThanEqual ¶ added in v2.3.0
func (f *FilterRange[T]) SetLessThanEqual(value *T)
type Option ¶ added in v2.3.0
type Option func(*BaseService) error
func WithConfigID ¶ added in v2.3.0
type PangeaErrors ¶
type PangeaErrors struct {
Errors []ErrorField `json:"errors,omitempty"`
}
type PangeaResponse ¶
type Response ¶
type Response struct { ResponseHeader HTTPResponse *http.Response // Query raw result RawResult json.RawMessage `json:"result"` }
func (*Response) UnmarshalResult ¶
type ResponseHeader ¶
type ResponseHeader struct { // The request ID RequestID *string `json:"request_id"` // The time the request was issued, ISO8601 RequestTime *string `json:"request_time"` // The time the response was issued, ISO8601 ResponseTime *string `json:"response_time"` // The HTTP status code msg Status *string `json:"status"` // The summary of the response Summary *string `json:"summary"` }
func (*ResponseHeader) String ¶
func (r *ResponseHeader) String() string
type RetryConfig ¶
type UnmarshalError ¶
func NewUnmarshalError ¶
func NewUnmarshalError(err error, bytes []byte, r *http.Response) *UnmarshalError
func (*UnmarshalError) Error ¶
func (e *UnmarshalError) Error() string