client

package
v0.0.1-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TidepoolServerNameHeaderName       = "x-tidepool-server-name"
	TidepoolServerSecretHeaderName     = "x-tidepool-server-secret"
	TidepoolUserSessionTokenHeaderName = "x-tidepool-session-token"

	ServerTokenTimeoutOnFailureFirst = time.Second
	ServerTokenTimeoutOnFailureLast  = time.Minute
)

Variables

View Source
var UploadPermissions = Permissions{"upload": {}}
View Source
var ViewPermissions = Permissions{"view": {}}

Functions

func IsUnauthorizedError

func IsUnauthorizedError(err error) bool

Types

type Client

type Client interface {
	Start() error
	Close()
	ValidateUserSession(context *service.Context, sessionToken string) (string, error)
	ValidateTargetUserPermissions(context *service.Context, requestUserID string, targetUserID string, targetPermissions Permissions) error
	GetUserGroupID(context *service.Context, userID string) (string, error)
}

type Config

type Config struct {
	Address            string `json:"address"`
	RequestTimeout     int    `json:"requestTimeout"`
	ServerTokenSecret  string `json:"serverTokenSecret"`
	ServerTokenTimeout int    `json:"serverTokenTimeout"`
}

func (*Config) Validate

func (c *Config) Validate() error

type Permission

type Permission map[string]interface{}

type Permissions

type Permissions map[string]Permission

type Standard

type Standard struct {
	// contains filtered or unexported fields
}

func NewStandard

func NewStandard(config *Config, logger log.Logger) (*Standard, error)

func (*Standard) Close

func (s *Standard) Close()

func (*Standard) GetUserGroupID

func (s *Standard) GetUserGroupID(context *service.Context, userID string) (string, error)

func (*Standard) Start

func (s *Standard) Start() error

func (*Standard) ValidateTargetUserPermissions

func (s *Standard) ValidateTargetUserPermissions(context *service.Context, requestUserID string, targetUserID string, targetPermissions Permissions) error

func (*Standard) ValidateUserSession

func (s *Standard) ValidateUserSession(context *service.Context, sessionToken string) (string, error)

type UnauthorizedError

type UnauthorizedError struct{}

func NewUnauthorizedError

func NewUnauthorizedError() *UnauthorizedError

func (*UnauthorizedError) Error

func (u *UnauthorizedError) Error() string

type UnexpectedResponseError

type UnexpectedResponseError struct {
	Method     string
	URL        string
	StatusCode int
}

func NewUnexpectedResponseError

func NewUnexpectedResponseError(response *http.Response, request *http.Request) *UnexpectedResponseError

func (*UnexpectedResponseError) Error

func (u *UnexpectedResponseError) Error() string

Jump to

Keyboard shortcuts

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