Documentation
¶
Index ¶
Constants ¶
const DefaultAddr = "api.zvelo.com"
DefaultAddr is used by both GRPCv1Client and RESTv1Client as the default address:port for all zveloAPI calls. It can be overridden using the WithAddr Option.
const DefaultScopes = "zvelo.dataset"
DefaultScopes are the default scopes used when no scopes are explicietly defined
const UserAgent = "go-zapi v1"
UserAgent is the user agent that will be provided by the RESTv1Client. It can be overridden by providing a custom transport using the WithTransport Option.
Variables ¶
var Endpoint = oauth2.Endpoint{
AuthURL: "https://auth.zvelo.com/oauth2/auth",
TokenURL: "https://auth.zvelo.com/oauth2/token",
}
Endpoint is an oauth2.Endpoint that is useful for working with the oauth2 package
Functions ¶
func CallbackHandler ¶
func CallbackHandler(h Handler, opts ...CallbackOption) http.Handler
CallbackHandler returns an http.Handler that can be used with an http.Server to receive and process zveloAPI callbacks
func KeyGetter ¶ added in v1.3.0
func KeyGetter(opts ...CallbackOption) httpsig.KeyGetter
KeyGetter returns an httpsig.KeyGetter that will properly fetch and cache zvelo public keys
Types ¶
type CallOption ¶
type CallOption interface {
// contains filtered or unexported methods
}
CallOption configures a Call before it starts or extracts information from a Call after it completes. It is only used with the RESTv1Client. grpc.CallOption is still available for the GRPCv1Client.
func Response ¶
func Response(h **http.Response) CallOption
Response will return the entire http.Response received from a zveloAPI call. This is useful to request or response headers, see http error messages, read the raw body and more.
type CallbackOption ¶ added in v1.3.0
type CallbackOption func(*callbackOptions)
A CallbackOption is used to configure the CallbackHandler
func WithCallbackDebug ¶ added in v1.3.0
func WithCallbackDebug(val io.Writer) CallbackOption
WithCallbackDebug causes the CallbackHandler to emit debug logs to the writer
func WithKeyGetterClient ¶ added in v1.3.0
func WithKeyGetterClient(val Doer) CallbackOption
WithKeyGetterClient causes the CallbackHandler to use the passed in http.Client, instead of http.DefaultClient
func WithoutValidation ¶ added in v1.3.1
func WithoutValidation() CallbackOption
WithoutValidation causes the CallbackHandler to skip signature validation
type GRPCv1Client ¶
type GRPCv1Client interface { msg.APIv1Client io.Closer }
A GRPCv1Client implements msg.APIv1Client as well as an io.Closer that, if closed, will close the underlying gRPC connection.
type GRPCv1Dialer ¶
type GRPCv1Dialer interface {
Dial(context.Context, ...grpc.DialOption) (GRPCv1Client, error)
}
A GRPCv1Dialer is used to simplify connecting to zveloAPI with the correct options. grpc DialOptions will override the defaults.
func NewGRPCv1 ¶
func NewGRPCv1(ts oauth2.TokenSource, opts ...Option) GRPCv1Dialer
NewGRPCv1 returns a properly configured GRPCv1Dialer
type Handler ¶
type Handler interface {
Handle(*msg.QueryResult)
}
A Handler responds to a zveloAPI callback
type HandlerFunc ¶
type HandlerFunc func(*msg.QueryResult)
The HandlerFunc type is an adapter to allow the use of ordinary functions as zveloAPI handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.
type Option ¶
type Option func(*options)
An Option is used to configure different parts of this package. Not every Option is useful with every function that takes Options.
func WithAddr ¶
WithAddr returns an Option that overrides the default address:port for all zveloAPI requests
func WithDebug ¶
WithDebug returns an Option that will cause requests from the RESTv1Client and callbacks processed by the CallbackHandler to emit debug logs to the writer
func WithForceTrace ¶
func WithForceTrace() Option
WithForceTrace returns an Option that will cause all requests to be traced by the api server
func WithTLSInsecureSkipVerify ¶
func WithTLSInsecureSkipVerify() Option
WithTLSInsecureSkipVerify returns an Option that disables certificate chain and host name verification of the connection to zveloAPI. This should only be used for testing, e.g. with mocks.
func WithTracer ¶
func WithTracer(val opentracing.Tracer) Option
WithTracer returns an Option that will cause requests to be instrumented by the given tracer. If not specified, opentracing.GlobalTracer will be used.
func WithTransport ¶
func WithTransport(val http.RoundTripper) Option
WithTransport returns an Option that will cause all requests from the RESTv1Client to be processed by the given http.RoundTripper. If not specified, http.DefaultTransport will be used.
type RESTv1Client ¶
type RESTv1Client interface { Query(ctx context.Context, in *msg.QueryRequests, opt ...CallOption) (*msg.QueryReplies, error) Result(ctx context.Context, reqID string, opt ...CallOption) (*msg.QueryResult, error) GraphQL(ctx context.Context, query string, result interface{}, opt ...CallOption) error }
A RESTv1Client implements a very similar interface to GRPCv1Client but uses a standard HTTP/REST transport instead of gRPC. Generally the gRPC client is preferred for its efficiency.
func NewRESTv1 ¶
func NewRESTv1(ts oauth2.TokenSource, opts ...Option) RESTv1Client
NewRESTv1 returns a properly configured RESTv1Client