slashdb

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asc

func Asc(field string) string

Asc sets the ascending format for the given field i.e. 'a' -> 'a', '-b' -> 'b'

func Desc

func Desc(field string) string

Desc sets the descending format for the given field i.e. '-a' -> '-a', 'b' -> '-b'

Types

type CRUDer

type CRUDer interface {
	Get(
		ctx context.Context,
		sdbReq fmt.Stringer,
		container interface{},
	) error
	Create(
		ctx context.Context,
		sdbReq fmt.Stringer,
		payload interface{},
	) (types.CreateResponse, error)
	Update(
		ctx context.Context,
		sdbReq fmt.Stringer,
		payload interface{},
	) error
	Delete(
		ctx context.Context,
		sdbReq fmt.Stringer,
	) error
}

CRUDer an interface representing CRUD operations

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer - a simple interface for a http.Client

type Filter

type Filter struct {
	Values map[string][]string
	Order  []string
}

Filter describes the request filtering condition (also ordering)

func NewFilter

func NewFilter(
	values map[string][]string,
	order []string,
) Filter

NewFilter the default constructor for the Filter object

type Part

type Part struct {
	Name      string
	Fields    []string
	Filter    Filter
	Separator string
}

Part describes a single request part/segment

func NewPart

func NewPart(
	name string,
	fields []string,
	filter Filter,
	separator string,
) Part

NewPart the default constructor for the Part object

func (Part) String

func (part Part) String() string

type QueryConfigManager

type QueryConfigManager interface {
	QueryConfigs(ctx context.Context) (map[string]types.QueryConfig, error)
	QueryConfig(ctx context.Context, id string) (types.QueryConfig, error)
	CreateQueryConfig(ctx context.Context, q types.QueryConfig) error
	UpdateQueryConfig(ctx context.Context, id string, q types.QueryConfig) error
	DeleteQueryConfig(ctx context.Context, id string) error
}

QueryConfigManager - represents CRUD operations for the QueryConfig request

type Request

type Request struct {
	Kind      string
	Parts     []Part
	Params    map[string]string
	Separator string
}

Request main SlashDB request object

func NewDataRequest

func NewDataRequest(separator string) *Request

NewDataRequest the data resource request constructor

func NewQueryRequest

func NewQueryRequest(separator string) *Request

NewQueryRequest the query resource request constructor

func (*Request) AddParts

func (req *Request) AddParts(part ...Part)

AddParts adds the user defined parts to the request

func (*Request) DistinctOff

func (req *Request) DistinctOff()

DistinctOff turns off distinct for the request

func (*Request) DistinctOn

func (req *Request) DistinctOn()

DistinctOn turns on distinct for the request

func (*Request) HeadersOff

func (req *Request) HeadersOff()

HeadersOff turns off headers for the request

func (*Request) HeadersOn

func (req *Request) HeadersOn()

HeadersOn turns on headers for the request

func (*Request) NilVisibleOff

func (req *Request) NilVisibleOff()

NilVisibleOff turns off nil_visible for the request

func (*Request) NilVisibleOn

func (req *Request) NilVisibleOn()

NilVisibleOn turns on nil_visible for the request

func (*Request) RemoveCSVNullStr

func (req *Request) RemoveCSVNullStr()

RemoveCSVNullStr turns off csvNullStr for the request

func (*Request) RemoveCardinality

func (req *Request) RemoveCardinality()

RemoveCardinality removes the cardinality query param from the request

func (*Request) RemoveDepth

func (req *Request) RemoveDepth()

RemoveDepth removes the depth query param from the request

func (*Request) RemoveLimit

func (req *Request) RemoveLimit()

RemoveLimit removes the limit query param from the request

func (*Request) RemoveOffset

func (req *Request) RemoveOffset()

RemoveOffset removes the offset query param from the request

func (*Request) RemoveSetURLStringSub

func (req *Request) RemoveSetURLStringSub()

RemoveSetURLStringSub removes the URL string substitution query param from the request

func (*Request) RemoveSort

func (req *Request) RemoveSort()

RemoveSort removes the sort query param from the request

func (*Request) RemoveWildcard

func (req *Request) RemoveWildcard()

RemoveWildcard removes the wildcard query param from the request

func (*Request) ResetSeparator

func (req *Request) ResetSeparator()

ResetSeparator resets the separator query param to the default ','

func (*Request) SetCSVNullStr

func (req *Request) SetCSVNullStr(csvNullStr string)

SetCSVNullStr turns on csvNullStr for the request

func (*Request) SetCardinality

func (req *Request) SetCardinality(cardinality int)

SetCardinality sets the cardinality query param on the request

func (*Request) SetDepth

func (req *Request) SetDepth(depth int)

SetDepth sets the depth query param on the request

func (*Request) SetLimit

func (req *Request) SetLimit(limit int)

SetLimit sets the limit query param on the request

func (*Request) SetOffset

func (req *Request) SetOffset(offset int)

SetOffset sets the offset query param on the request

func (*Request) SetSeparator

func (req *Request) SetSeparator(separator string)

SetSeparator sets the separator query param on the request

func (*Request) SetSort

func (req *Request) SetSort(fields ...string)

SetSort sets the sort query param on the request

func (*Request) SetURLStringSub

func (req *Request) SetURLStringSub(urlStringSub string)

SetURLStringSub sets the URL string substitution query param on the request

func (*Request) SetWildcard

func (req *Request) SetWildcard(wildcard string)

SetWildcard sets the wildcard query param on the request

func (*Request) StreamingOff

func (req *Request) StreamingOff()

StreamingOff turns off streaming for the request

func (*Request) StreamingOn

func (req *Request) StreamingOn()

StreamingOn turns on streaming for the request

func (*Request) String

func (req *Request) String() string

func (*Request) WantArrayOff

func (req *Request) WantArrayOff()

WantArrayOff turns off wantarray for the request

func (*Request) WantArrayOn

func (req *Request) WantArrayOn()

WantArrayOn turns on wantarray for the request

type ResourceConfigManager

type ResourceConfigManager interface {
	ResourceConfigs(ctx context.Context) (map[string]types.ResourceConfig, error)
	ResourceConfig(ctx context.Context, id string) (types.ResourceConfig, error)
	CreateResourceConfig(ctx context.Context, d types.ResourceConfig) error
	UpdateResourceConfig(ctx context.Context, id string, d types.ResourceConfig) error
	DeleteResourceConfig(ctx context.Context, id string) error
}

ResourceConfigManager - represents CRUD operations for the ResourceConfig request

type Service

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

Service - main SlashDB API service

func NewService

func NewService(
	host, apiKeyName, apiKeyValue, refIDPrefix string,
	echoMode bool,
	httpClient Doer,
) (*Service, error)

NewService - returns a new instance of a SlashDB service

func (*Service) Create added in v0.0.4

func (s *Service) Create(
	ctx context.Context,
	sdbReq fmt.Stringer,
	payload interface{},
) (types.CreateResponse, error)

Create creates resources using POST method

func (*Service) CreateQueryConfig added in v0.0.4

func (s *Service) CreateQueryConfig(ctx context.Context, q types.QueryConfig) error

CreateQueryConfig creates a new custom quetry config

func (*Service) CreateResourceConfig added in v0.0.4

func (s *Service) CreateResourceConfig(ctx context.Context, d types.ResourceConfig) error

CreateResourceConfig creates a new data resource config

func (*Service) CreateUserConfig added in v0.0.4

func (s *Service) CreateUserConfig(ctx context.Context, u types.UserConfig) error

CreateUserConfig creates a new user config

func (*Service) Delete added in v0.0.4

func (s *Service) Delete(
	ctx context.Context,
	sdbReq fmt.Stringer,
) error

Delete deletes resources using DELETE method

func (*Service) DeleteQueryConfig added in v0.0.4

func (s *Service) DeleteQueryConfig(ctx context.Context, id string) error

DeleteQueryConfig deletes a single custom quetry config

func (*Service) DeleteResourceConfig added in v0.0.4

func (s *Service) DeleteResourceConfig(ctx context.Context, id string) error

DeleteResourceConfig deletes a single data resource config

func (*Service) DeleteUserConfig added in v0.0.4

func (s *Service) DeleteUserConfig(ctx context.Context, id string) error

DeleteUserConfig deletes a single user config

func (*Service) Get added in v0.0.4

func (s *Service) Get(
	ctx context.Context,
	sdbReq fmt.Stringer,
	container interface{},
) error

Get gets resources using GET method

func (*Service) Init

func (s *Service) Init(ctx context.Context) error

Init - initializes the service i.e. get the base resource mapping

func (*Service) QueryConfig added in v0.0.4

func (s *Service) QueryConfig(ctx context.Context, id string) (types.QueryConfig, error)

QueryConfig retrives a single custom quetry config

func (*Service) QueryConfigs added in v0.0.4

func (s *Service) QueryConfigs(ctx context.Context) (map[string]types.QueryConfig, error)

QueryConfigs retrives all the custom quetry configs

func (*Service) ResourceConfig added in v0.0.4

func (s *Service) ResourceConfig(ctx context.Context, id string) (types.ResourceConfig, error)

ResourceConfig retrives a single data resource config

func (*Service) ResourceConfigs added in v0.0.4

func (s *Service) ResourceConfigs(ctx context.Context) (map[string]types.ResourceConfig, error)

ResourceConfigs retrives all the data resource configs

func (*Service) Resources

func (s *Service) Resources() map[string]string

Resources - returns a copy of the services resources map

func (*Service) Update added in v0.0.4

func (s *Service) Update(
	ctx context.Context,
	sdbReq fmt.Stringer,
	payload interface{},
) error

Update updates resources using PUT method

func (*Service) UpdateQueryConfig added in v0.0.4

func (s *Service) UpdateQueryConfig(ctx context.Context, id string, q types.QueryConfig) error

UpdateQueryConfig updates an existing custom quetry config

func (*Service) UpdateResourceConfig added in v0.0.4

func (s *Service) UpdateResourceConfig(ctx context.Context, id string, d types.ResourceConfig) error

UpdateResourceConfig updates an existing data resource config

func (*Service) UpdateUserConfig added in v0.0.4

func (s *Service) UpdateUserConfig(ctx context.Context, id string, u types.UserConfig) error

UpdateUserConfig updates an existing user config

func (*Service) UserConfig added in v0.0.4

func (s *Service) UserConfig(ctx context.Context, id string) (types.UserConfig, error)

UserConfig retrives a single user config

func (*Service) UserConfigs added in v0.0.4

func (s *Service) UserConfigs(ctx context.Context) (map[string]types.UserConfig, error)

UserConfigs retrives all the user configs

type UserConfigManager

type UserConfigManager interface {
	UserConfigs(ctx context.Context) (map[string]types.UserConfig, error)
	UserConfig(ctx context.Context, id string) (types.UserConfig, error)
	CreateUserConfig(ctx context.Context, u types.UserConfig) error
	UpdateUserConfig(ctx context.Context, id string, u types.UserConfig) error
	DeleteUserConfig(ctx context.Context, id string) error
}

UserConfigManager - represents CRUD operations for the UserConfig request configs

Jump to

Keyboard shortcuts

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