Documentation
¶
Index ¶
- Variables
- type APIError
- type Auth0ClientEnvEntryOption
- type BaseURLOption
- type BodyPropertiesOption
- type BufferStreamReader
- type ClientCredentialsAndAudienceOption
- type ClientCredentialsOption
- type ClientCredentialsPrivateKeyJwtAndAudienceOption
- type ClientCredentialsPrivateKeyJwtOption
- type CustomDomainHeaderOption
- type DebugOption
- type HTTPClient
- type HTTPClientOption
- type HTTPHeaderOption
- type InsecureOption
- type MaxAttemptsOption
- type MaxBufSizeOption
- type NoAuth0ClientInfoOption
- type Page
- type PageIterator
- type PageRequest
- type PageResponse
- type QueryParametersOption
- type RequestOption
- type RequestOptions
- type Response
- type ScannerStreamReader
- type SseEvent
- type SseEventMeta
- type SseStreamReader
- type Stream
- type StreamEvent
- type StreamEventRaw
- type StreamFormat
- type StreamOption
- type TokenOption
- type TokenSourceOption
- type UserAgentOption
Constants ¶
This section is empty.
Variables ¶
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 ¶
NewAPIError constructs a new API error.
type Auth0ClientEnvEntryOption ¶
Auth0ClientEnvEntryOption 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 BufferStreamReader ¶ added in v2.10.0
type BufferStreamReader struct {
// contains filtered or unexported fields
}
BufferStreamReader reads data from a *bufio.Reader, which splits on newlines.
func (*BufferStreamReader) ReadFromStream ¶ added in v2.10.0
func (b *BufferStreamReader) ReadFromStream() ([]byte, error)
type ClientCredentialsOption ¶
type CustomDomainHeaderOption ¶
type CustomDomainHeaderOption struct {
CustomDomainHeader string
}
CustomDomainHeaderOption implements the RequestOption interface.
type DebugOption ¶
type DebugOption struct {
Debug bool
}
DebugOption implements the RequestOption interface.
type HTTPClient ¶
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 ¶
HTTPHeaderOption implements the RequestOption interface.
type InsecureOption ¶
type InsecureOption struct{}
InsecureOption implements the RequestOption interface. This option is for testing purposes only and should not be used in production.
type MaxAttemptsOption ¶
type MaxAttemptsOption struct {
MaxAttempts uint
}
MaxAttemptsOption implements the RequestOption interface.
type MaxBufSizeOption ¶ added in v2.10.0
type MaxBufSizeOption struct {
MaxBufSize int
}
MaxBufSizeOption implements the RequestOption interface.
type NoAuth0ClientInfoOption ¶
type NoAuth0ClientInfoOption struct{}
NoAuth0ClientInfoOption implements the RequestOption interface.
type Page ¶
type Page[Cursor comparable, T any, R any] struct { Results []T Response R RawResponse PageResponse[Cursor, T, R] StatusCode int Header http.Header NextPageFunc func(context.Context) (*Page[Cursor, T, R], error) }
Page represents a single page of results.
func (*Page[Cursor, T, R]) GetNextPage ¶
GetNextPage fetches the next page, if any. If no pages remain, the ErrNoPages error is returned.
func (*Page[Cursor, T, R]) Iterator ¶
func (p *Page[Cursor, T, R]) Iterator() *PageIterator[Cursor, T, R]
Iterator returns an iterator that starts at the current page.
type PageIterator ¶
type PageIterator[Cursor comparable, T any, R any] struct { // contains filtered or unexported fields }
PageIterator is an auto-iterator for paginated endpoints.
func (*PageIterator[Cursor, T, R]) Current ¶
func (p *PageIterator[Cursor, T, R]) Current() T
Current returns the current element.
func (*PageIterator[Cursor, T, R]) Err ¶
func (p *PageIterator[Cursor, T, R]) Err() error
Err returns a non-nil error if the iterator encountered an error.
type PageRequest ¶ added in v2.3.0
type PageRequest[Cursor comparable] struct { Cursor Cursor // Holds the value of the response type (populated by the *Caller). Response any }
PageRequest represents the information required to identify a single page.
type PageResponse ¶ added in v2.3.0
type PageResponse[Cursor comparable, T any, R any] struct { Results []T Response R Next Cursor Done bool }
PageResponse represents the information associated with a single page.
Type parameters:
- Cursor: the type used for pagination (e.g., string cursor or integer offset)
- T: the type of individual items in the page
- R: the response type returned by the paginated endpoint
type QueryParametersOption ¶
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
MaxBufSize int
Ctx context.Context
Token string
TokenSource oauth2.TokenSource
Insecure bool // For testing purposes only - allows HTTP instead of HTTPS
// Auth0ClientEnv holds custom environment entries for the Auth0-Client header
Auth0ClientEnv map[string]string
// NoAuth0ClientInfo when true, prevents sending the "Auth0-Client" header
NoAuth0ClientInfo bool
// CustomDomainHeader is the custom domain to be sent in the "Auth0-Custom-Domain" header
// for whitelisted API endpoints
CustomDomainHeader 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 ScannerStreamReader ¶ added in v2.10.0
type ScannerStreamReader struct {
// contains filtered or unexported fields
}
ScannerStreamReader reads data from a *bufio.Scanner, which allows for configurable delimiters.
func (*ScannerStreamReader) ReadFromStream ¶ added in v2.10.0
func (s *ScannerStreamReader) ReadFromStream() ([]byte, error)
type SseEvent ¶ added in v2.10.0
type SseEvent struct {
SseEventMeta
Data []byte
// contains filtered or unexported fields
}
type SseEventMeta ¶ added in v2.10.0
type SseEventMeta struct {
ID string
Event string
// Retry is the reconnection time in milliseconds.
// Zero if not set or if the value was not a valid integer.
Retry int
}
SseEventMeta holds SSE metadata fields shared by StreamEvent and StreamEventRaw.
type SseStreamReader ¶ added in v2.10.0
type SseStreamReader struct {
// contains filtered or unexported fields
}
func (*SseStreamReader) LastEventID ¶ added in v2.10.0
func (s *SseStreamReader) LastEventID() string
LastEventID returns the most recently received event ID.
func (*SseStreamReader) ReadEvent ¶ added in v2.10.0
func (s *SseStreamReader) ReadEvent() (*SseEvent, error)
ReadEvent reads the next SSE event with full metadata, skipping comment-only events.
func (*SseStreamReader) ReadFromStream ¶ added in v2.10.0
func (s *SseStreamReader) ReadFromStream() ([]byte, error)
type Stream ¶ added in v2.10.0
type Stream[T any] struct { // contains filtered or unexported fields }
Stream represents a stream of messages sent from a server.
func NewStream ¶ added in v2.10.0
func NewStream[T any](ctx context.Context, response *http.Response, opts ...StreamOption) *Stream[T]
NewStream constructs a new Stream from the given *http.Response.
func (*Stream[T]) LastEventID ¶ added in v2.10.0
LastEventID returns the most recently received non-empty event ID. Per the SSE spec, the last event ID persists across events and should be sent as the Last-Event-ID header when reconnecting.
This works regardless of whether Recv or RecvEvent is used to consume the stream — the ID is tracked at the reader level.
func (*Stream[T]) Recv ¶ added in v2.10.0
Recv reads a message from the stream, returning io.EOF when all the messages have been read.
func (*Stream[T]) RecvEvent ¶ added in v2.10.0
func (s *Stream[T]) RecvEvent() (StreamEvent[T], error)
RecvEvent reads the next event from the stream, including SSE metadata (id, event type, retry). Returns io.EOF when all events have been read.
This is only meaningful for SSE streams. For non-SSE streams, the metadata fields will always be zero-valued.
func (*Stream[T]) RecvEventRaw ¶ added in v2.10.0
func (s *Stream[T]) RecvEventRaw() (StreamEventRaw, error)
RecvEventRaw reads the next event from the stream without JSON unmarshaling, including SSE metadata. Returns io.EOF when all events have been read.
type StreamEvent ¶ added in v2.10.0
type StreamEvent[T any] struct { SseEventMeta Data T }
StreamEvent contains the parsed data and SSE metadata for a single event.
type StreamEventRaw ¶ added in v2.10.0
type StreamEventRaw struct {
SseEventMeta
Data []byte
}
StreamEventRaw contains the raw bytes and SSE metadata for a single event.
type StreamFormat ¶ added in v2.10.0
type StreamFormat string
const ( StreamFormatSSE StreamFormat = "sse" StreamFormatEmpty StreamFormat = "" )
type StreamOption ¶ added in v2.10.0
type StreamOption func(*streamOptions)
StreamOption adapts the behavior of the Stream.
func WithDelimiter ¶ added in v2.10.0
func WithDelimiter(delimiter string) StreamOption
WithDelimiter overrides the delimiter for the Stream.
By default, the Stream is newline-delimited.
func WithEventDiscriminator ¶ added in v2.10.0
func WithEventDiscriminator(field string) StreamOption
WithEventDiscriminator configures the SSE stream reader to inject the SSE event field value as a JSON discriminator into the data payload. This is used for protocol-level discrimination where the union discriminant comes from the SSE event: field rather than from within the JSON data.
func WithFormat ¶ added in v2.10.0
func WithFormat(format StreamFormat) StreamOption
WithFormat overrides the isSSE flag for the Stream.
By default, the Stream is not SSE.
func WithMaxBufSize ¶ added in v2.10.0
func WithMaxBufSize(size int) StreamOption
WithMaxBufSize overrides the maximum buffer size for the Stream.
This controls the maximum size of a single message (in bytes) that the stream can process. By default, this is set to 1MB. If your streaming responses contain messages larger than the default, increase this value.
func WithPrefix ¶ added in v2.10.0
func WithPrefix(prefix string) StreamOption
WithPrefix overrides the prefix for the Stream.
By default, the Stream doesn't have a prefix.
func WithTerminator ¶ added in v2.10.0
func WithTerminator(terminator string) StreamOption
WithTerminator overrides the terminator for the Stream.
By default, the Stream terminates on EOF.
type TokenOption ¶
type TokenOption struct {
Token string
}
TokenOption implements the RequestOption interface.
type TokenSourceOption ¶ added in v2.6.0
type TokenSourceOption struct {
TokenSource oauth2.TokenSource
}
TokenSourceOption implements the RequestOption interface.
type UserAgentOption ¶
type UserAgentOption struct {
UserAgent string
}
UserAgentOption implements the RequestOption interface.