zapi

package module
v1.15.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: MIT Imports: 26 Imported by: 8

README

go-zapi

GoDoc Circle CI Coverage Status Go Report Card

Documentation

Index

Constants

View Source
const DefaultGrpcTarget = "dns:///api.zvelo.com"

DefaultGrpcTarget is used by the GRPCv1Client as the default scheme://authority/endpoint_name for all zveloAPI calls. It can be overridden using the WithGrpcTarget Option.

View Source
const DefaultRestBaseURL = "https://api.zvelo.com/"

DefaultRestBaseURL is used by the RESTv1Client as the default base URL for all zveloAPI calls. It can be overridden using the WithRestBaseURL Option.

View Source
const DefaultScopes = "zvelo.dataset"

DefaultScopes are the default scopes used when no scopes are explicietly defined

View Source
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

View Source
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

This section is empty.

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.

func WithHeader added in v1.10.0

func WithHeader(key, val string) CallOption

WithHeader adds the header named key with value val to outgoing REST http requests

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 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 WithDebug

func WithDebug(val io.Writer) Option

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 WithGrpcTarget added in v1.11.0

func WithGrpcTarget(val string) Option

WithGrpcTarget returns an Option that overrides the default gRPC target for all zveloAPI requests

func WithRestBaseURL added in v1.11.0

func WithRestBaseURL(val string) Option

WithRestBaseURL returns an Option that overrides the default base URL for all zveloAPI requests

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 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.

func WithoutHTTP2 added in v1.14.0

func WithoutHTTP2() Option

WithoutHTTP2 disables the http/2 client for REST queries

func WithoutTLS added in v1.9.5

func WithoutTLS() Option

WithoutTLS disables TLS when connecting to zveloAPI

type RESTv1Client

type RESTv1Client interface {
	Query(ctx context.Context, in *msg.QueryRequests, opts ...CallOption) (*msg.QueryReplies, error)
	Result(ctx context.Context, reqID string, opts ...CallOption) (*msg.QueryResult, error)
	GraphQL(ctx context.Context, query string, result interface{}, opts ...CallOption) error
	Suggest(ctx context.Context, in *msg.Suggestion, opts ...CallOption) error
	Stream(ctx context.Context) (RESTv1StreamClient, 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

type RESTv1StreamClient added in v1.6.0

type RESTv1StreamClient interface {
	Recv() (*msg.QueryResult, error)
}

RESTv1StreamClient provides an interface to receive streamed query results from zveloAPI servers.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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