types

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAuthorized defines a not authorized error
	ErrNotAuthorized = NewError().Status(http.StatusUnauthorized).Format("not authorized")

	// ErrInvalidParameter defines an invalid parameter error
	ErrInvalidParameter = NewError().Status(http.StatusBadRequest).Format("invalid parameter")

	// ErrNotImplemented defines a not implemented error
	ErrNotImplemented = NewError().Status(http.StatusNotImplemented).FormatFunc("method '%s' not implemented")

	// ErrResourceConflict is returned when an object conflicts with one that already exists
	ErrResourceConflict = NewError().Status(http.StatusConflict).FormatFunc("'%s' conflicts with one that already exists")

	// ErrNotFound is is returned when an object was not found
	ErrNotFound = NewError().Status(http.StatusNotFound).FormatFunc("'%s' not found")

	// ErrServerError is reserved for server errors
	ErrServerError = NewError().Status(http.StatusInternalServerError).FormatFunc("server error: %s")
)
View Source
var (
	// NoContentResponse is a no content HTTP success response
	NoContentResponse = NewResponse().SetStatus(http.StatusNoContent)

	// SeeOtherResponse returns a redirect response
	SeeOtherResponse = func(loc string) *Response {
		return NewResponse().SetStatus(http.StatusSeeOther).SetHeader("Location", loc)
	}
)
View Source
var (
	// PathSeparator is the character used to separate the elements
	// of the keypath.
	//
	// For example, `location.address.city`
	PathSeparator = "."

	// SignatureSeparator is the character that is used to
	// separate the Base64 string from the security signature.
	SignatureSeparator = "_"
)
View Source
var (
	// DefaultProfile is a default profile object
	DefaultProfile = &Profile{
		StandardClaims: openid.StandardClaims{
			Locale: ptr.String("en-US"),
		},
	}
)
View Source
var ModelGenerateUUID = false

ModelGenerateUUID is a flag to tell sparks to generate a new uuid for the models

Functions

This section is empty.

Types

type Caster added in v1.1.3

type Caster interface {
	String() string
	StringPtr() *string
	StringSlice() []string
	Bool() bool
	Int64() int64
	Float64() float64
	Slice() []interface{}
	StringMap() StringMap
	Time() time.Time
}

Caster defines a simple casting interface

type CompoundModel added in v1.3.2

type CompoundModel struct {
	ModelBase
	// Table unitque identifier
	// Read Only: true
	ID int64 `json:"id,omitempty"`

	// Universally unique identifier
	// Read Only: true
	UUID *strfmt.UUID `json:"uuid,omitempty"`
}

CompoundModel uses an integer for the primary key, but also has an optional UUID

func (*CompoundModel) BeforeCreate added in v1.3.2

func (m *CompoundModel) BeforeCreate() (err error)

BeforeCreate hooks the gorm on create

func (*CompoundModel) MarshalBinary added in v1.3.2

func (m *CompoundModel) MarshalBinary() ([]byte, error)

MarshalBinary interface implementation

func (*CompoundModel) UnmarshalBinary added in v1.3.2

func (m *CompoundModel) UnmarshalBinary(b []byte) error

UnmarshalBinary interface implementation

func (*CompoundModel) Validate added in v1.3.2

func (m *CompoundModel) Validate(formats strfmt.Registry) error

Validate validates this base model

type Error

type Error struct {
	Code    *string                `json:"code,omitempty"`
	Message *string                `json:"message,omitempty"`
	Detail  map[string]interface{} `json:"detail,omitempty"`
	// contains filtered or unexported fields
}

Error is the common error struct compatible with swagger response types

func NewError

func NewError(err ...error) *Error

NewError returns a new models.Error from a go error

func (*Error) BodyLength

func (e *Error) BodyLength() int

BodyLength returns the http body length in bytes

func (*Error) Err

func (e *Error) Err() error

Err returns the underlining error

func (*Error) Error

func (e *Error) Error() string

Err returns the go error

func (*Error) ErrorCode

func (e *Error) ErrorCode(code string) *Error

ErrorCode sets the error code

func (*Error) Format

func (e *Error) Format(msg string, args ...interface{}) *Error

Format formats the error message

func (*Error) FormatFunc

func (e *Error) FormatFunc(msg string) func(args ...interface{}) *Error

FormatFunc func formats a error message functor

func (*Error) Header

func (e *Error) Header() http.Header

Header returns the http header

func (*Error) RPCCode added in v1.4.1

func (e *Error) RPCCode() int64

RPCCode returns an approximate json-rpc code corresponding to the http status

func (*Error) Reason

func (e *Error) Reason(args ...interface{}) *Error

Reason sets the detail for the error

func (*Error) Scan

func (e *Error) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (*Error) Status

func (e *Error) Status(status int) *Error

Status sets the http status

func (*Error) StatusCode

func (e *Error) StatusCode() int

StatusCode returns the http statuscode

func (*Error) String

func (e *Error) String() string

func (*Error) Validate

func (*Error) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

func (Error) Value

func (e Error) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

func (*Error) WriteResponse

func (e *Error) WriteResponse(rw http.ResponseWriter, pr runtime.Producer)

WriteResponse implements the middleware.Responder interface

type InfluxPoint added in v1.3.2

type InfluxPoint struct {
	Values []interface{}
	Index  int
	Time   time.Time
	// contains filtered or unexported fields
}

InfluxPoint is a point in series data

func (*InfluxPoint) ColIndex added in v1.3.2

func (p *InfluxPoint) ColIndex(key string) int

ColIndex get the index of a column

func (*InfluxPoint) Columns added in v1.3.2

func (p *InfluxPoint) Columns() []string

Columns return the point columns

func (*InfluxPoint) Get added in v1.3.2

func (p *InfluxPoint) Get(key string) Value

Get returns a value for the key from values or tags

func (*InfluxPoint) Map added in v1.3.2

func (p *InfluxPoint) Map() map[string]interface{}

Map returns a map of the point

func (*InfluxPoint) Series added in v1.3.2

func (p *InfluxPoint) Series() *InfluxSeries

Series returns the series for the point

func (*InfluxPoint) Tag added in v1.3.2

func (p *InfluxPoint) Tag(key string) string

Tag returns a tag value

func (*InfluxPoint) Tags added in v1.3.2

func (p *InfluxPoint) Tags() map[string]string

Tags returns the list of tags

func (*InfluxPoint) UnmarshalStruct added in v1.3.2

func (p *InfluxPoint) UnmarshalStruct(prefix string, out interface{}, tags ...string) bool

UnmarshalStruct unmarshals series data into the structure

func (*InfluxPoint) Value added in v1.3.2

func (p *InfluxPoint) Value(key string) Value

Value returns a value for the key from values or tags

type InfluxSeries added in v1.3.2

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

InfluxSeries is a class for scanning influx data

func NewInfluxSeries added in v1.3.2

func NewInfluxSeries(row models.Row, colPrefix ...string) *InfluxSeries

NewInfluxSeries creates a new influx series mapper

func (*InfluxSeries) AddColumn added in v1.3.2

func (s *InfluxSeries) AddColumn(key string) int

AddColumn adds a new column to the series at the end

func (*InfluxSeries) ColIndex added in v1.3.2

func (s *InfluxSeries) ColIndex(key string) int

ColIndex get the index of a column

func (*InfluxSeries) Columns added in v1.3.2

func (s *InfluxSeries) Columns() []string

Columns return the point columns

func (*InfluxSeries) Length added in v1.3.2

func (s *InfluxSeries) Length() int

Length returns the length of the values

func (*InfluxSeries) NewPoint added in v1.3.2

func (s *InfluxSeries) NewPoint(val interface{}, ts time.Time, points ...*InfluxPoint) *InfluxPoint

NewPoint creates a new point from the map

func (*InfluxSeries) Scan added in v1.3.2

func (s *InfluxSeries) Scan(scan func(point *InfluxPoint) error) error

Scan a series

func (*InfluxSeries) Tag added in v1.3.2

func (s *InfluxSeries) Tag(key string) string

Tag returns a tag value

func (*InfluxSeries) Tags added in v1.3.2

func (s *InfluxSeries) Tags() map[string]string

Tags returns the list of tags

type Link struct {

	// expires at
	ExpiresAt int64 `json:"expires_at,omitempty"`

	// the target url/uri
	// Format: uri
	Href strfmt.URI `json:"href,omitempty"`

	// optional link name
	Name *string `json:"name,omitempty"`
}

Link an href link object swagger:model Link

func (*Link) MarshalBinary

func (m *Link) MarshalBinary() ([]byte, error)

MarshalBinary interface implementation

func (*Link) UnmarshalBinary

func (m *Link) UnmarshalBinary(b []byte) error

UnmarshalBinary interface implementation

func (*Link) Validate

func (m *Link) Validate(formats strfmt.Registry) error

Validate validates this link

type MapFilter added in v1.1.0

type MapFilter func(index int, val interface{}) (string, interface{}, bool)

MapFilter returns true and the key and value, or false if the value should be skipped

type Mapper added in v1.1.0

type Mapper interface {
	IsSet(key interface{}) bool
	Set(key, value interface{})
	Get(key interface{}) interface{}
	Cast(key interface{}) Caster
	Sub(key interface{}) Mapper
	Delete(key interface{})
	DeleteAll(keys ...interface{})
	Copy() Mapper
	With(keys ...interface{}) Mapper
	Without(keys ...interface{}) Mapper
	Values() interface{}
	Keys() interface{}
	StringMap() StringMap
	ForEach(func(key, value interface{}))
}

Mapper provides a map wrapper interface for working easily with unknown map types

func Map added in v1.1.0

func Map(m interface{}) Mapper

Map returns a Mapper from the passed map

type Model

type Model struct {
	ModelBase
	// Universally unique identifier
	// Read Only: true
	ID strfmt.UUID `json:"id,omitempty"`
}

Model is the default database model that uses a UUID as a primary key

func (*Model) BeforeCreate added in v1.3.0

func (m *Model) BeforeCreate() (err error)

BeforeCreate hooks the gorm on create

func (*Model) MarshalBinary

func (m *Model) MarshalBinary() ([]byte, error)

MarshalBinary interface implementation

func (*Model) UnmarshalBinary

func (m *Model) UnmarshalBinary(b []byte) error

UnmarshalBinary interface implementation

func (*Model) Validate

func (m *Model) Validate(formats strfmt.Registry) error

Validate validates this base model

type ModelBase added in v1.3.2

type ModelBase struct {
	// Date and time of object creation
	// Read Only: true
	CreatedAt strfmt.DateTime `json:"created_at,omitempty" sql:"column:_created_at"`

	// Last date of object modification
	// Read Only: true
	UpdatedAt strfmt.DateTime `json:"updated_at,omitempty" sql:"column:_updated_at"`

	// meta
	Meta StringMap `json:"meta,omitempty"`

	// tags
	Tags StringArray `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

ModelBase is the base model attributes

func (*ModelBase) Context added in v1.3.2

func (m *ModelBase) Context() context.Context

Context returns the context for the model instance

func (*ModelBase) SetContext added in v1.3.2

func (m *ModelBase) SetContext(key, value interface{}) context.Context

SetContext sets a context key on the object

type Params

type Params = StringMap

Params is a simple type alias for a Map

func ParseStringParams

func ParseStringParams(s string) Params

ParseStringParams parses a parameter string and returns a params object Example string: foo=bar aparam="value"

type Profile added in v1.3.1

type Profile struct {
	openid.StandardClaims

	// extended attributes
	ExtendedAttributes map[string]string `json:"extendedAttributes,omitempty"`
}

Profile A record profile, optional user/client data. swagger:model Profile

func (*Profile) MarshalBinary added in v1.3.1

func (m *Profile) MarshalBinary() ([]byte, error)

MarshalBinary interface implementation

func (Profile) MarshalJSON added in v1.3.1

func (m Profile) MarshalJSON() ([]byte, error)

MarshalJSON marshals this object to a JSON structure

func (*Profile) Scan added in v1.3.1

func (m *Profile) Scan(value interface{}) error

Scan implements sql.Scanner

func (*Profile) UnmarshalBinary added in v1.3.1

func (m *Profile) UnmarshalBinary(b []byte) error

UnmarshalBinary interface implementation

func (*Profile) UnmarshalJSON added in v1.3.1

func (m *Profile) UnmarshalJSON(raw []byte) error

UnmarshalJSON unmarshals this object from a JSON structure

func (*Profile) Validate added in v1.3.1

func (m *Profile) Validate(formats strfmt.Registry) error

Validate validates this profile

func (*Profile) Value added in v1.3.1

func (m *Profile) Value() (driver.Value, error)

Value implements the driver.Valuer interface

type Response

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

Response defines a simple middleware.Responder struct

func NewResponse

func NewResponse(options ...*ResponseOptions) *Response

NewResponse returns a new response object

func (*Response) Body

func (r *Response) Body() []byte

Body returns the body

func (*Response) Copy

func (r *Response) Copy() *Response

Copy copies a response

func (*Response) Header

func (r *Response) Header() http.Header

Header implements the http.ResponseWriter

func (*Response) Length

func (r *Response) Length() int

Length returns the response length

func (*Response) SetAcceleration

func (r *Response) SetAcceleration(acc bool) *Response

SetAcceleration enables json acceleration

func (*Response) SetHeader

func (r *Response) SetHeader(name, value string) *Response

SetHeader sets additional response headers

func (*Response) SetHeaderMap

func (r *Response) SetHeaderMap(vals map[string]string) *Response

SetHeaderMap sets additional response headers

func (*Response) SetHeaders

func (r *Response) SetHeaders(h http.Header) *Response

SetHeaders sets all of the headers

func (*Response) SetOptions

func (r *Response) SetOptions(options ...*ResponseOptions) *Response

SetOptions sets the options for a response

func (*Response) SetPayload

func (r *Response) SetPayload(payload interface{}) *Response

SetPayload sets the payload

func (*Response) SetStatus

func (r *Response) SetStatus(s int) *Response

SetStatus sets the response http status

func (*Response) StatusCode

func (r *Response) StatusCode() int

StatusCode returns the response http status code

func (*Response) Write

func (r *Response) Write(body []byte) (int, error)

Write implements the http.ResponseWriter.Write() method

func (*Response) WriteHeader

func (r *Response) WriteHeader(statusCode int)

WriteHeader implements the http.ResponseWriter.WriteHeader() method

func (*Response) WriteResponse

func (r *Response) WriteResponse(rw http.ResponseWriter, pr runtime.Producer)

WriteResponse implements the middleware.Responder.WriteResponse() method

type ResponseOptions

type ResponseOptions struct {
	Request      *http.Request
	Encoding     string
	ContentType  string
	Binary       bool
	Acceleration bool
}

ResponseOptions defines responder options

type Slicer added in v1.1.0

type Slicer interface {
	Append(vals ...interface{}) Slicer
	Insert(index int, val interface{}) Slicer
	IndexOf(val interface{}) int
	Len() int
	Get(index int) interface{}
	Remove(index int) Slicer
	Filter(func(index int, val interface{}) bool) Slicer
	ForEach(func(index int, val interface{})) Slicer
	Map(out interface{}, filters ...MapFilter) Slicer
	ToStringMap() StringMap
	Contains(values ...interface{}) bool
	ContainsAny(values ...interface{}) bool
}

Slicer is a generic slice manipulation interface helper

func Slice added in v1.1.0

func Slice(s interface{}) Slicer

Slice returns a slicer object from a pointer to a slice

v := make([]string, 0)
util.Slice(&v).Append("foo")

type StringArray

type StringArray pq.StringArray

StringArray is a proper string array type

func (*StringArray) Scan

func (a *StringArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (*StringArray) Validate

func (*StringArray) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

func (StringArray) Value

func (a StringArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type StringMap

type StringMap map[string]interface{}

StringMap is a wrapper on a map[string]interface{} that implements the Mapper interface

func (StringMap) Bool added in v1.1.0

func (p StringMap) Bool(key string, def ...bool) bool

Bool parses and returns the boolean value of the parameter

func (StringMap) Cast added in v1.1.3

func (p StringMap) Cast(key interface{}) Caster

Cast returns Caster to convert the value to another type

func (StringMap) Copy added in v1.1.0

func (p StringMap) Copy() Mapper

Copy does a shallow copy

func (StringMap) Delete added in v1.1.0

func (p StringMap) Delete(key interface{})

Delete removes a key

func (StringMap) DeleteAll added in v1.3.4

func (p StringMap) DeleteAll(keys ...interface{})

DeleteAll removes several keys

func (StringMap) Float64 added in v1.1.0

func (p StringMap) Float64(key string, def ...float64) float64

Float64 returns the float value or 0 if not set

func (StringMap) ForEach added in v1.4.7

func (p StringMap) ForEach(itr func(key, value interface{}))

ForEach iterates over the map

func (StringMap) Get added in v1.1.0

func (p StringMap) Get(key interface{}) interface{}

Get returns the value and if the key is set

func (StringMap) GetValue added in v1.1.0

func (p StringMap) GetValue(key string) (Value, bool)

GetValue returns a Value and if the key is set

func (StringMap) Int64 added in v1.1.0

func (p StringMap) Int64(key string, def ...int64) int64

Int64 returns the int value or 0 if not set

func (StringMap) IsSet added in v1.1.0

func (p StringMap) IsSet(key interface{}) bool

IsSet returns true if the parameter is set

func (StringMap) Keys added in v1.3.2

func (p StringMap) Keys() interface{}

Keys returns the keys from the map

func (*StringMap) Scan added in v1.1.0

func (p *StringMap) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (StringMap) Set added in v1.1.0

func (p StringMap) Set(key, value interface{})

Set sets a value in the map

func (StringMap) String added in v1.1.0

func (p StringMap) String(key string, def ...string) string

String returns a string value for the param, or the optional default

func (StringMap) StringMap added in v1.4.7

func (p StringMap) StringMap() StringMap

StringMap returns the string map

func (StringMap) StringPtr added in v1.1.0

func (p StringMap) StringPtr(key string, def ...string) *string

StringPtr returns a string ptr or nil

func (StringMap) StringSlice added in v1.1.0

func (p StringMap) StringSlice(key string) []string

StringSlice returns a string value for the param, or the optional default

func (StringMap) Sub added in v1.1.0

func (p StringMap) Sub(key interface{}) Mapper

Sub returns a sub StringMap for the key

func (*StringMap) Validate

func (*StringMap) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

func (StringMap) Value added in v1.1.0

func (p StringMap) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

func (StringMap) Values added in v1.3.2

func (p StringMap) Values() interface{}

Values returns the keys from the map

func (StringMap) With added in v1.4.7

func (p StringMap) With(keys ...interface{}) Mapper

With returns a map with only the specified keys

func (StringMap) Without added in v1.1.0

func (p StringMap) Without(keys ...interface{}) Mapper

Without removes the keys, returns a shallow copy

type Ticker added in v1.1.1

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

Ticker is a ticker wrapper with some extra functionality

func NewTicker added in v1.1.1

func NewTicker(period time.Duration) *Ticker

NewTicker create a new resetable ticker

func (*Ticker) C added in v1.1.1

func (t *Ticker) C() <-chan time.Time

C returns the ticker channel

func (*Ticker) Reset added in v1.1.1

func (t *Ticker) Reset()

Reset resets the tickers

type UUIDArray

type UUIDArray []strfmt.UUID

UUIDArray is a proper string array type

func (*UUIDArray) Scan

func (a *UUIDArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (UUIDArray) Strings

func (a UUIDArray) Strings() []string

Strings returns a string slice from the uuid array

func (*UUIDArray) Validate

func (*UUIDArray) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

func (UUIDArray) Value

func (a UUIDArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Value

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

Value defines a value wrapper

func NewValue

func NewValue(v interface{}) Value

NewValue returns a new value with cast helpers

func (Value) Bool

func (v Value) Bool() bool

Bool casts the value to a bool

func (Value) Float64

func (v Value) Float64() float64

Float64 casts the value to a float64

func (Value) Int64

func (v Value) Int64() int64

Int64 casts the value to an int64

func (Value) Interface added in v1.1.0

func (v Value) Interface() interface{}

Interface returns the underlying interface for the value

func (Value) IsJSONNumber added in v1.3.2

func (v Value) IsJSONNumber() bool

IsJSONNumber return true if the original value was a json.Number

func (Value) IsNil added in v1.1.3

func (v Value) IsNil() bool

IsNil returns if the enclosed value is nil

func (Value) Slice added in v1.3.0

func (v Value) Slice() []interface{}

Slice returns the value cast as []interface{}

func (Value) String

func (v Value) String() string

String casts the value to a string

func (Value) StringMap added in v1.3.0

func (v Value) StringMap() StringMap

StringMap converts the object to a StringMap

func (Value) StringPtr

func (v Value) StringPtr() *string

StringPtr casts the value to a string pointer

func (Value) StringSlice

func (v Value) StringSlice() []string

StringSlice casts the value to a string slice

func (Value) Time added in v1.3.2

func (v Value) Time() time.Time

Time casts the value to a time.Time

Directories

Path Synopsis
Package binary provides helpers for encoding binary data from a spec file very loosely based on kaitai; see https://doc.kaitai.io.
Package binary provides helpers for encoding binary data from a spec file very loosely based on kaitai; see https://doc.kaitai.io.
geo
encoding/ewkb
Package ewkb implements Well Known Binary encoding and decoding.
Package ewkb implements Well Known Binary encoding and decoding.
Package ptr provides some helpers for converting types to pointers
Package ptr provides some helpers for converting types to pointers

Jump to

Keyboard shortcuts

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