Documentation ¶
Index ¶
- Variables
- func B64ToStr(enc string) ([]byte, error)
- func Bool(v bool) *bool
- func BoolValue(v *bool) bool
- func GetDefaultPangeaLogger() *zerolog.Logger
- func GetFileSize(input *os.File) (int64, error)
- 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 AcceptedResult
- type AttachedFile
- type AttachedFileSaveInfo
- type BaseError
- type BaseRequest
- type BaseService
- func (bs *BaseService) DownloadFile(ctx context.Context, url string) (*AttachedFile, error)
- 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, handleQueue bool) (*Response, error)
- func (c *Client) DownloadFile(ctx context.Context, url string) (*AttachedFile, error)
- func (c *Client) FetchAcceptedResponse(ctx context.Context, reqID string, v interface{}) (*Response, error)
- func (c *Client) FullPostPresignedURL(ctx context.Context, url string, input ConfigIDer, out any, fd FileData) (*Response, error)
- func (c *Client) GetPendingRequestID() []string
- func (c *Client) GetPresignedURL(ctx context.Context, url string, input any) (*Response, *AcceptedResult, error)
- func (c *Client) GetRequestIDURL(rid string) (string, error)
- func (c *Client) GetURL(path string) (string, error)
- func (c *Client) NewRequest(method, url string, body any) (*http.Request, error)
- func (c *Client) NewRequestForm(method, url string, fd FileData, setHeaders bool) (*http.Request, error)
- func (c *Client) NewRequestMultipart(method, url string, body any, fd FileData) (*http.Request, error)
- func (c *Client) PostMultipart(ctx context.Context, url string, input any, out any, fd FileData) (*Response, error)
- func (c *Client) ServiceName() string
- func (c *Client) SetHeaders(req *http.Request)
- func (c *Client) UploadFile(ctx context.Context, url string, tm TransferMethod, fd FileData) error
- type ClientOption
- type Config
- type ConfigIDer
- type ErrorField
- type FileData
- type FileUploader
- 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 TransferMethod
- type TransferRequest
- type TransferRequester
- type UnmarshalError
- type UploadFileParams
Constants ¶
This section is empty.
Variables ¶
var ErrDecryptionFailed = errors.New("decryption failed")
var ErrInvalidPrivateKey = errors.New("invalid private key")
var ErrInvalidPublicKey = errors.New("invalid public key")
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 ¶
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 ¶
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 AcceptedResult AcceptedResult Response }
TODO: Duplicated fields. Remove ResponseHeader in next breaking update.
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 AcceptedResult ¶ added in v3.1.0
type AcceptedResult struct { TTLMins int `json:"ttl_mins"` RetryCounter int `json:"retry_counter"` Location string `json:"location"` PostURL string `json:"post_url"` PutURL string `json:"put_url"` PostFormData map[string]string `json:"post_form_data"` }
func (AcceptedResult) HasUploadURL ¶ added in v3.4.0
func (ar AcceptedResult) HasUploadURL() bool
type AttachedFile ¶ added in v3.8.0
func (AttachedFile) Save ¶ added in v3.8.0
func (af AttachedFile) Save(info AttachedFileSaveInfo) error
type AttachedFileSaveInfo ¶ added in v3.8.0
type BaseError ¶
type BaseRequest ¶
type BaseRequest struct { // Config ID. 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) DownloadFile ¶ added in v3.8.0
func (bs *BaseService) DownloadFile(ctx context.Context, url string) (*AttachedFile, error)
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 ¶
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) DownloadFile(ctx context.Context, url string) (*AttachedFile, 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 ¶
func (c *Client) Do(ctx context.Context, req *http.Request, v any, handleQueue bool) (*Response, error)
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 happens, 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) DownloadFile ¶ added in v3.8.0
func (*Client) FetchAcceptedResponse ¶
func (c *Client) FetchAcceptedResponse(ctx context.Context, reqID string, v interface{}) (*Response, error)
FetchAcceptedResponse retries the
func (*Client) FullPostPresignedURL ¶ added in v3.3.0
func (*Client) GetPendingRequestID ¶
func (*Client) GetPresignedURL ¶ added in v3.3.0
func (*Client) GetRequestIDURL ¶ added in v3.1.0
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) NewRequestForm ¶ added in v3.1.0
func (*Client) NewRequestMultipart ¶ added in v3.1.0
func (*Client) PostMultipart ¶ added in v3.1.0
func (*Client) ServiceName ¶ added in v3.1.0
func (*Client) SetHeaders ¶
func (*Client) UploadFile ¶ added in v3.3.0
type ClientOption ¶
func ClientWithConfigID ¶
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 HTTP/202. PollResultTimeout time.Duration // Retry config defaults to a base retry option RetryConfig *RetryConfig // Logger Logger *zerolog.Logger }
type ConfigIDer ¶
type ErrorField ¶
type FileUploader ¶ added in v3.11.0
type FileUploader struct {
// contains filtered or unexported fields
}
func NewFileUploader ¶ added in v3.11.0
func NewFileUploader() FileUploader
func (*FileUploader) UploadFile ¶ added in v3.11.0
func (fu *FileUploader) UploadFile(ctx context.Context, url string, tm TransferMethod, fd FileData) error
type FilterBase ¶
type FilterBase struct {
// contains filtered or unexported fields
}
func NewFilterBase ¶
func NewFilterBase(f Filter) *FilterBase
func (FilterBase) Filter ¶
func (fb FilterBase) Filter() Filter
type FilterCommon ¶
type FilterCommon struct {
// contains filtered or unexported fields
}
type FilterEqual ¶
type FilterEqual[T any] struct { FilterCommon }
func NewFilterEqual ¶
func NewFilterEqual[T any](name string, filter *Filter) *FilterEqual[T]
func (*FilterEqual[T]) Get ¶
func (f *FilterEqual[T]) Get() *T
func (*FilterEqual[T]) Set ¶
func (f *FilterEqual[T]) Set(value *T)
type FilterMatch ¶
type FilterMatch[T any] struct { FilterEqual[T] }
func NewFilterMatch ¶
func NewFilterMatch[T any](name string, filter *Filter) *FilterMatch[T]
func (*FilterMatch[T]) Contains ¶
func (f *FilterMatch[T]) Contains() []T
func (*FilterMatch[T]) In ¶
func (f *FilterMatch[T]) In() []T
func (*FilterMatch[T]) SetContains ¶
func (f *FilterMatch[T]) SetContains(value []T)
func (*FilterMatch[T]) SetIn ¶
func (f *FilterMatch[T]) SetIn(value []T)
type FilterRange ¶
type FilterRange[T any] struct { FilterEqual[T] }
func NewFilterRange ¶
func NewFilterRange[T any](name string, filter *Filter) *FilterRange[T]
func (*FilterRange[T]) GreaterThan ¶
func (f *FilterRange[T]) GreaterThan() *T
func (*FilterRange[T]) GreaterThanEqual ¶
func (f *FilterRange[T]) GreaterThanEqual() *T
func (*FilterRange[T]) LessThan ¶
func (f *FilterRange[T]) LessThan() *T
func (*FilterRange[T]) LessThanEqual ¶
func (f *FilterRange[T]) LessThanEqual() *T
func (*FilterRange[T]) SetGreaterThan ¶
func (f *FilterRange[T]) SetGreaterThan(value *T)
func (*FilterRange[T]) SetGreaterThanEqual ¶
func (f *FilterRange[T]) SetGreaterThanEqual(value *T)
func (*FilterRange[T]) SetLessThan ¶
func (f *FilterRange[T]) SetLessThan(value *T)
func (*FilterRange[T]) SetLessThanEqual ¶
func (f *FilterRange[T]) SetLessThanEqual(value *T)
type PangeaErrors ¶
type PangeaErrors struct {
Errors []ErrorField `json:"errors,omitempty"`
}
type PangeaResponse ¶
type PangeaResponse[T any] struct { Response Result *T AcceptedResult *AcceptedResult }
type Response ¶
type Response struct { ResponseHeader HTTPResponse *http.Response AttachedFiles []AttachedFile // Query raw result RawResult json.RawMessage `json:"result"` // contains filtered or unexported fields }
func (Response) MarshalJSON ¶ added in v3.6.0
MarshalJSON implements the json.Marshaler interface for CustomType.
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 TransferMethod ¶ added in v3.1.0
type TransferMethod string
const ( TMmultipart TransferMethod = "multipart" TMpostURL TransferMethod = "post-url" TMputURL TransferMethod = "put-url" TMsourceURL TransferMethod = "source-url" TMdestURL TransferMethod = "dest-url" )
type TransferRequest ¶ added in v3.1.0
type TransferRequest struct {
TransferMethod TransferMethod `json:"transfer_method,omitempty"`
}
func (TransferRequest) GetTransferMethod ¶ added in v3.1.0
func (tr TransferRequest) GetTransferMethod() TransferMethod
type TransferRequester ¶ added in v3.1.0
type TransferRequester interface {
GetTransferMethod() TransferMethod
}
type UnmarshalError ¶
func NewUnmarshalError ¶
func NewUnmarshalError(err error, bytes []byte, r *http.Response) *UnmarshalError
func (*UnmarshalError) Error ¶
func (e *UnmarshalError) Error() string
type UploadFileParams ¶ added in v3.11.0
type UploadFileParams struct { Size int `json:"size,omitempty"` CRC32C string `json:"crc32c,omitempty"` SHA256 string `json:"sha256,omitempty"` }
func GetUploadFileParams ¶ added in v3.11.0
func GetUploadFileParams(input io.ReadSeeker) (*UploadFileParams, error)