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 HashSHA256(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 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 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 Config
- type ConfigIDer
- type ErrorField
- 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 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
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, checkConfigID bool, 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 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 Config ¶
type Config struct { // The Bearer token used to authenticate requests. Token string // Config ID for multi-config projects 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 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