dropbox

package
v6.0.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPHeaderSafeJSON

func HTTPHeaderSafeJSON(b []byte) string

HTTPHeaderSafeJSON encode the JSON passed in b []byte passed in in a way that is suitable for HTTP headers.

See: https://www.dropbox.com/developers/reference/json-encoding

func OAuthEndpoint

func OAuthEndpoint(domain string) oauth2.Endpoint

OAuthEndpoint constructs an `oauth2.Endpoint` for the given domain

func Version

func Version() (string, string)

Version returns the current SDK version and API Spec version

Types

type APIError

type APIError struct {
	ErrorSummary string `json:"error_summary"`
}

APIError is the base type for endpoint-specific errors.

func (APIError) Error

func (e APIError) Error() string

type Config

type Config struct {
	// OAuth2 access token
	Token string
	// Logging level for SDK generated logs
	LogLevel LogLevel
	// Logging target for verbose SDK logging
	Logger *log.Logger
	// Used with APIs that support operations as another user
	AsMemberID string
	// Used with APIs that support operations as an admin
	AsAdminID string
	// Path relative to which action should be taken
	PathRoot string
	// No need to set -- for testing only
	Domain string
	// No need to set -- for testing only
	Client *http.Client
	// No need to set -- for testing only
	HeaderGenerator func(hostType string, namespace string, route string) map[string]string
	// No need to set -- for testing only
	URLGenerator func(hostType string, namespace string, route string) string
}

Config contains parameters for configuring the SDK.

func (*Config) LogDebug

func (c *Config) LogDebug(format string, v ...interface{})

LogDebug emits a debug level SDK log if config's log level is at least LogDebug

func (*Config) LogInfo

func (c *Config) LogInfo(format string, v ...interface{})

LogInfo emits an info level SDK log if config's log level is at least LogInfo

func (Config) WithNamespaceID

func (c Config) WithNamespaceID(nsID string) Config

Ergonomic methods to set namespace relative to which action should be taken

func (Config) WithRoot

func (c Config) WithRoot(nsID string) Config

type Context

type Context struct {
	Config          Config
	Client          *http.Client
	NoAuthClient    *http.Client
	HeaderGenerator func(hostType string, namespace string, route string) map[string]string
	URLGenerator    func(hostType string, namespace string, route string) string
}

Context is the base client context used to implement per-namespace clients.

func NewContext

func NewContext(c Config) Context

NewContext returns a new Context with the given Config.

func (*Context) Execute

func (c *Context) Execute(req Request, body io.Reader) ([]byte, io.ReadCloser, error)

type LogLevel

type LogLevel uint

LogLevel defines a type that can set the desired level of logging the SDK will generate.

const (
	// LogOff will disable all SDK logging. This is the default log level
	LogOff LogLevel = iota * (1 << 8)
	// LogDebug will enable detailed SDK debug logs. It will log requests (including arguments),
	// response and body contents.
	LogDebug
	// LogInfo will log SDK request (not including arguments) and responses.
	LogInfo
)

type Request

type Request struct {
	Host      string
	Namespace string
	Route     string
	Style     string
	Auth      string

	Arg          interface{}
	ExtraHeaders map[string]string
}

type SDKInternalError

type SDKInternalError struct {
	StatusCode int
	Content    string
}

func (SDKInternalError) Error

func (e SDKInternalError) Error() string

type Tagged

type Tagged struct {
	Tag string `json:".tag"`
}

Tagged is used for tagged unions.

Jump to

Keyboard shortcuts

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