core

package
v5.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPages = errors.New("no pages remain")

ErrNoPages is a sentinel error used to signal that no pages remain.

This error should be used similar to io.EOF, such that it represents a non-actionable error.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int         `json:"-"`
	Header     http.Header `json:"-"`
	// contains filtered or unexported fields
}

APIError is a lightweight wrapper around the standard error interface that preserves the status code from the RPC, if any.

func NewAPIError

func NewAPIError(statusCode int, header http.Header, err error) *APIError

NewAPIError constructs a new API error.

func (*APIError) Error

func (a *APIError) Error() string

Error returns the API error's message.

func (*APIError) Unwrap

func (a *APIError) Unwrap() error

Unwrap returns the underlying error. This also makes the error compatible with errors.As and errors.Is.

type APIKeyOption

type APIKeyOption struct {
	APIKey string
}

APIKeyOption implements the RequestOption interface.

type BaseURLOption

type BaseURLOption struct {
	BaseURL string
}

BaseURLOption implements the RequestOption interface.

type BodyPropertiesOption

type BodyPropertiesOption struct {
	BodyProperties map[string]interface{}
}

BodyPropertiesOption implements the RequestOption interface.

type CorrelationIDOption

type CorrelationIDOption struct {
	CorrelationID *string
}

CorrelationIDOption implements the RequestOption interface.

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient is an interface for a subset of the *http.Client.

type HTTPClientOption

type HTTPClientOption struct {
	HTTPClient HTTPClient
}

HTTPClientOption implements the RequestOption interface.

type HTTPHeaderOption

type HTTPHeaderOption struct {
	HTTPHeader http.Header
}

HTTPHeaderOption implements the RequestOption interface.

type IdempotencyKeyOption

type IdempotencyKeyOption struct {
	IdempotencyKey *string
}

IdempotencyKeyOption implements the RequestOption interface.

type IdempotentRequestOption

type IdempotentRequestOption interface {
	// contains filtered or unexported methods
}

IdempotentRequestOption adapts the behavior of an individual request.

type IdempotentRequestOptions

type IdempotentRequestOptions struct {
	*RequestOptions

	IdempotencyKey *string
}

IdempotentRequestOptions defines all of the possible idempotent request options.

This type is primarily used by the generated code and is not meant to be used directly; use the option package instead.

func NewIdempotentRequestOptions

func NewIdempotentRequestOptions(opts ...IdempotentRequestOption) *IdempotentRequestOptions

NewIdempotentRequestOptions returns a new *IdempotentRequestOptions value.

This function is primarily used by the generated code and is not meant to be used directly; use IdempotentRequestOption instead.

func (*IdempotentRequestOptions) ToHeader

func (i *IdempotentRequestOptions) ToHeader() http.Header

ToHeader maps the configured request options into a http.Header used for the request.

type MaxAttemptsOption

type MaxAttemptsOption struct {
	MaxAttempts uint
}

MaxAttemptsOption implements the RequestOption interface.

type Page

type Page[T any] struct {
	Results      []T
	NextPageFunc func(context.Context) (*Page[T], error)
}

Page represents a single page of results.

func (*Page[T]) GetNextPage

func (p *Page[T]) GetNextPage(ctx context.Context) (*Page[T], error)

GetNextPage fetches the next page, if any. If no pages remain, the ErrNoPages error is returned.

func (*Page[T]) Iterator

func (p *Page[T]) Iterator() *PageIterator[T]

Iterator returns an iterator that starts at the current page.

type PageIterator

type PageIterator[T any] struct {
	// contains filtered or unexported fields
}

PageIterator is an auto-iterator for paginated endpoints.

func (*PageIterator[T]) Current

func (p *PageIterator[T]) Current() T

Current returns the current element.

func (*PageIterator[T]) Err

func (p *PageIterator[T]) Err() error

Err returns a non-nil error if the iterator encountered an error.

func (*PageIterator[T]) Next

func (p *PageIterator[T]) Next(ctx context.Context) bool

Next returns true if the given iterator has more results, fetching the next page as needed.

type QueryParametersOption

type QueryParametersOption struct {
	QueryParameters url.Values
}

QueryParametersOption implements the RequestOption interface.

type RequestOption

type RequestOption interface {
	// contains filtered or unexported methods
}

RequestOption adapts the behavior of the client or an individual request.

type RequestOptions

type RequestOptions struct {
	BaseURL         string
	HTTPClient      HTTPClient
	HTTPHeader      http.Header
	BodyProperties  map[string]interface{}
	QueryParameters url.Values
	MaxAttempts     uint
	APIKey          string
	CorrelationID   *string
}

RequestOptions defines all of the possible request options.

This type is primarily used by the generated code and is not meant to be used directly; use the option package instead.

func NewRequestOptions

func NewRequestOptions(opts ...RequestOption) *RequestOptions

NewRequestOptions returns a new *RequestOptions value.

This function is primarily used by the generated code and is not meant to be used directly; use RequestOption instead.

func (*RequestOptions) ToHeader

func (r *RequestOptions) ToHeader() http.Header

ToHeader maps the configured request options into a http.Header used for the request(s).

type Response

type Response[T any] struct {
	StatusCode int
	Header     http.Header
	Body       T
}

Response is an HTTP response from an HTTP client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL