rdl

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: Apache-2.0 Imports: 22 Imported by: 34

Documentation

Index

Constants

View Source
const MAX_COLUMNS = 128
View Source
const Version = "1.5.2"

Variables

This section is empty.

Functions

func BoolParam

func BoolParam(r *http.Request, name string, defaultValue bool) (bool, error)

func CompareSchemas

func CompareSchemas(s1 *Schema, s2 *Schema) string

func Equal

func Equal(val1 interface{}, val2 interface{}) bool

Equal - Return true if the two values are equivalent, in the RDL sense.

func ExportToJSON

func ExportToJSON(schema *Schema, outpath string) error

ExportToJSON - v2 schema export to JSON. If out is empty, dump to stdout.

func Float32Param

func Float32Param(r *http.Request, name string, defaultValue float32) (float32, error)

func Float64Param

func Float64Param(r *http.Request, name string, defaultValue float64) (float64, error)

func FoldHttpHeaderName

func FoldHttpHeaderName(name string) string

FoldHttpHeaderName adapts to the Go misfeature: all headers are canonicalized as Capslike-This (for a header "CapsLike-this").

func HeaderParam

func HeaderParam(r *http.Request, name string, defaultValue string) string

func Int32Param

func Int32Param(r *http.Request, name string, defaultValue int32) (int32, error)

func Int64Param

func Int64Param(r *http.Request, name string, defaultValue int64) (int64, error)

func JSONResponse

func JSONResponse(w http.ResponseWriter, code int, data interface{})

JSONResponse provides response encoded as JSON.

func OptionalBoolParam

func OptionalBoolParam(r *http.Request, name string) (*bool, error)

func OptionalFloat64Param

func OptionalFloat64Param(r *http.Request, name string) (*float64, error)

func OptionalHeaderParam

func OptionalHeaderParam(r *http.Request, name string) string

func OptionalInt32Param

func OptionalInt32Param(r *http.Request, name string) (*int32, error)

func OptionalInt64Param

func OptionalInt64Param(r *http.Request, name string) (*int64, error)

func OptionalStringParam

func OptionalStringParam(r *http.Request, name string) string

OptionalStringParam parses and returns an optional parameter from the form body (multipart/form-data encoded).

func Pretty

func Pretty(obj interface{}) string

func StatusCode

func StatusCode(sym string) string

StatusCode returns the integer status code (as a string) for the symbolic name. I.e. "OK" -> "200"

func StatusMessage

func StatusMessage(sym string) string

StatusMessage returns the full message for a symbolic identifier, i.e. "OK" -> "200 OK"

func StringParam

func StringParam(r *http.Request, name string, defaultValue string) (string, bool)

func TypeInfo

func TypeInfo(t *Type) (TypeName, TypeRef, string)

TypeInfo returns common info that every type shares.

func UnparseRDL added in v1.4.12

func UnparseRDL(schema *Schema, out *bufio.Writer) error

func UnparseRDLFile added in v1.4.12

func UnparseRDLFile(schema *Schema, filename string) error

func ValidatorUseCache added in v1.4.13

func ValidatorUseCache(flag bool)

func WriteJSON

func WriteJSON(schema *Schema, out *bufio.Writer) error

WriteJSON - v2 schema export to JSON

Types

type AliasTypeBuilder

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

func NewAliasTypeBuilder

func NewAliasTypeBuilder(supertype string, name string) *AliasTypeBuilder

func (*AliasTypeBuilder) Build

func (tb *AliasTypeBuilder) Build() *Type

func (*AliasTypeBuilder) Comment

func (tb *AliasTypeBuilder) Comment(comment string) *AliasTypeBuilder

type AliasTypeDef

type AliasTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`
}

AliasTypeDef - AliasTypeDef is used for type definitions that add no additional attributes, and thus just create an alias

func NewAliasTypeDef

func NewAliasTypeDef(init ...*AliasTypeDef) *AliasTypeDef

NewAliasTypeDef - creates an initialized AliasTypeDef instance, returns a pointer to it

func (AliasTypeDef) String

func (s AliasTypeDef) String() string

func (*AliasTypeDef) UnmarshalJSON

func (self *AliasTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a AliasTypeDef

func (*AliasTypeDef) Validate

func (self *AliasTypeDef) Validate() error

Validate - checks for missing required fields, etc

type Any

type Any interface{}

type Array

type Array []interface{}

Array - a typedef for a "naked" array with no field definitions

func (Array) Equal

func (a Array) Equal(another Array) bool

Equal - in RDL, arrays and structs can be compared. This Equal method does that.

type ArrayOfInt

type ArrayOfInt []int32

ArrayOfInt -

type ArrayTypeBuilder

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

func NewArrayTypeBuilder

func NewArrayTypeBuilder(supertype string, name string) *ArrayTypeBuilder

func (*ArrayTypeBuilder) Build

func (tb *ArrayTypeBuilder) Build() *Type

func (*ArrayTypeBuilder) Comment

func (tb *ArrayTypeBuilder) Comment(comment string) *ArrayTypeBuilder

func (*ArrayTypeBuilder) Items

func (tb *ArrayTypeBuilder) Items(items string) *ArrayTypeBuilder

type ArrayTypeDef

type ArrayTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// The type of the items, default to any type
	//
	Items TypeRef `json:"items" rdl:"default=Any"`

	//
	// If present, indicate the fixed size.
	//
	Size *int32 `json:"size,omitempty" rdl:"optional"`

	//
	// If present, indicate the min size
	//
	MinSize *int32 `json:"minSize,omitempty" rdl:"optional"`

	//
	// If present, indicate the max size
	//
	MaxSize *int32 `json:"maxSize,omitempty" rdl:"optional"`
}

ArrayTypeDef - Array types can be restricted by item type and size

func NewArrayTypeDef

func NewArrayTypeDef(init ...*ArrayTypeDef) *ArrayTypeDef

NewArrayTypeDef - creates an initialized ArrayTypeDef instance, returns a pointer to it

func (*ArrayTypeDef) Init

func (self *ArrayTypeDef) Init() *ArrayTypeDef

Init - sets up the instance according to its default field values, if any

func (ArrayTypeDef) String

func (s ArrayTypeDef) String() string

func (*ArrayTypeDef) UnmarshalJSON

func (self *ArrayTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a ArrayTypeDef

func (*ArrayTypeDef) Validate

func (self *ArrayTypeDef) Validate() error

Validate - checks for missing required fields, etc

type Authenticator

type Authenticator interface {
	Authenticate(nToken string) Principal //the method that authenticates
	HTTPHeader() string                   //the header the credential is stored in when using HTTP
}

An Authenticator takes some credentials and, if valid, returns a Principal representing them.

type Authorizer

type Authorizer interface {
	//returns a boolean indication if the principal can perform the action on the resource. The error return value
	//means that an error was encountered before this could be determined.
	Authorize(action string, resource string, principal Principal) (bool, error)
}

Authorizer is the interface for an object that can authorize access. Usually set up to ZMSAuthorizer.

type BaseType

type BaseType int

BaseType -

const (
	BaseTypeBool BaseType
	BaseTypeInt8
	BaseTypeInt16
	BaseTypeInt32
	BaseTypeInt64
	BaseTypeFloat32
	BaseTypeFloat64
	BaseTypeBytes
	BaseTypeString
	BaseTypeTimestamp
	BaseTypeSymbol
	BaseTypeUUID
	BaseTypeArray
	BaseTypeMap
	BaseTypeStruct
	BaseTypeEnum
	BaseTypeUnion
	BaseTypeAny
)

BaseType constants

func NewBaseType

func NewBaseType(init ...interface{}) BaseType

NewBaseType - return a string representation of the enum

func (BaseType) MarshalJSON

func (e BaseType) MarshalJSON() ([]byte, error)

MarshalJSON is defined for proper JSON encoding of a BaseType

func (BaseType) String

func (e BaseType) String() string

String - return a string representation of the enum

func (BaseType) SymbolSet

func (e BaseType) SymbolSet() []string

SymbolSet - return an array of all valid string representations (symbols) of the enum

func (*BaseType) UnmarshalJSON

func (e *BaseType) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a BaseType

type BytesTypeBuilder added in v1.4.14

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

func NewBytesTypeBuilder added in v1.4.14

func NewBytesTypeBuilder(name string) *BytesTypeBuilder

func (*BytesTypeBuilder) Build added in v1.4.14

func (tb *BytesTypeBuilder) Build() *Type

func (*BytesTypeBuilder) Comment added in v1.4.14

func (tb *BytesTypeBuilder) Comment(comment string) *BytesTypeBuilder

func (*BytesTypeBuilder) MaxSize added in v1.4.14

func (tb *BytesTypeBuilder) MaxSize(maxsize int32) *BytesTypeBuilder

func (*BytesTypeBuilder) MinSize added in v1.4.14

func (tb *BytesTypeBuilder) MinSize(minsize int32) *BytesTypeBuilder

type BytesTypeDef

type BytesTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// Fixed size
	//
	Size *int32 `json:"size,omitempty" rdl:"optional"`

	//
	// Min size
	//
	MinSize *int32 `json:"minSize,omitempty" rdl:"optional"`

	//
	// Max size
	//
	MaxSize *int32 `json:"maxSize,omitempty" rdl:"optional"`
}

BytesTypeDef - Bytes allow the restriction by fixed size, or min/max size.

func NewBytesTypeDef

func NewBytesTypeDef(init ...*BytesTypeDef) *BytesTypeDef

NewBytesTypeDef - creates an initialized BytesTypeDef instance, returns a pointer to it

func (*BytesTypeDef) UnmarshalJSON

func (self *BytesTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a BytesTypeDef

func (*BytesTypeDef) Validate

func (self *BytesTypeDef) Validate() error

Validate - checks for missing required fields, etc

type EnumElementDef

type EnumElementDef struct {

	//
	// The identifier representing the value
	//
	Symbol Identifier `json:"symbol"`

	//
	// the comment for the element
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`
}

EnumElementDef - EnumElementDef defines one of the elements of an Enum

func NewEnumElementDef

func NewEnumElementDef(init ...*EnumElementDef) *EnumElementDef

NewEnumElementDef - creates an initialized EnumElementDef instance, returns a pointer to it

func (*EnumElementDef) UnmarshalJSON

func (self *EnumElementDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a EnumElementDef

func (*EnumElementDef) Validate

func (self *EnumElementDef) Validate() error

Validate - checks for missing required fields, etc

type EnumTypeBuilder

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

func NewEnumTypeBuilder

func NewEnumTypeBuilder(supertype string, name string) *EnumTypeBuilder

func (*EnumTypeBuilder) Build

func (tb *EnumTypeBuilder) Build() *Type

func (*EnumTypeBuilder) Comment

func (tb *EnumTypeBuilder) Comment(comment string) *EnumTypeBuilder

func (*EnumTypeBuilder) Element

func (tb *EnumTypeBuilder) Element(sym string, comment string) *EnumTypeBuilder

type EnumTypeDef

type EnumTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// The enumeration of the possible elements
	//
	Elements []*EnumElementDef `json:"elements"`
}

EnumTypeDef - Define an enumerated type. Each value of the type is represented by a symbolic identifier.

func NewEnumTypeDef

func NewEnumTypeDef(init ...*EnumTypeDef) *EnumTypeDef

NewEnumTypeDef - creates an initialized EnumTypeDef instance, returns a pointer to it

func (*EnumTypeDef) Init

func (self *EnumTypeDef) Init() *EnumTypeDef

Init - sets up the instance according to its default field values, if any

func (EnumTypeDef) String

func (s EnumTypeDef) String() string

func (*EnumTypeDef) UnmarshalJSON

func (self *EnumTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a EnumTypeDef

func (*EnumTypeDef) Validate

func (self *EnumTypeDef) Validate() error

Validate - checks for missing required fields, etc

type ExceptionDef

type ExceptionDef struct {

	//
	// The type of the exception
	//
	Type string `json:"type"`

	//
	// the optional comment for the exception
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`
}

ExceptionDef - ExceptionDef describes the exception a symbolic response code maps to.

func NewExceptionDef

func NewExceptionDef(init ...*ExceptionDef) *ExceptionDef

NewExceptionDef - creates an initialized ExceptionDef instance, returns a pointer to it

func (*ExceptionDef) UnmarshalJSON

func (self *ExceptionDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a ExceptionDef

func (*ExceptionDef) Validate

func (self *ExceptionDef) Validate() error

Validate - checks for missing required fields, etc

type ExtendedAnnotation

type ExtendedAnnotation string

ExtendedAnnotation - ExtendedAnnotation - parsed and preserved, but has no defined meaning in RDL. Such annotations must begin with "x_", and may have an associated string literal value (the value will be "" if the annotation is just a flag).

type Identifier

type Identifier string

Identifier - All names need to be of this restricted string type

type IntOOBTest

type IntOOBTest struct {
	Theyear int32 `json:"theyear"`
}

IntOOBTest -

func NewIntOOBTest

func NewIntOOBTest(init ...*IntOOBTest) *IntOOBTest

NewIntOOBTest - creates an initialized IntOOBTest instance, returns a pointer to it

func (*IntOOBTest) UnmarshalJSON

func (pTypeDef *IntOOBTest) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a IntOOBTest

func (*IntOOBTest) Validate

func (pTypeDef *IntOOBTest) Validate() error

Validate - checks for missing required fields, etc

type MapArrayTest

type MapArrayTest struct {
	Locations map[string]ArrayOfInt `json:"locations"`
}

MapArrayTest -

func NewMapArrayTest

func NewMapArrayTest(init ...*MapArrayTest) *MapArrayTest

NewMapArrayTest - creates an initialized MapArrayTest instance, returns a pointer to it

func (*MapArrayTest) Init

func (pTypeDef *MapArrayTest) Init() *MapArrayTest

Init - sets up the instance according to its default field values, if any

func (*MapArrayTest) UnmarshalJSON

func (pTypeDef *MapArrayTest) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a MapArrayTest

func (*MapArrayTest) Validate

func (pTypeDef *MapArrayTest) Validate() error

Validate - checks for missing required fields, etc

type MapTest

type MapTest struct {
	Locations map[string]int32 `json:"locations"`
}

MapTest -

func NewMapTest

func NewMapTest(init ...*MapTest) *MapTest

NewMapTest - creates an initialized MapTest instance, returns a pointer to it

func (*MapTest) Init

func (pTypeDef *MapTest) Init() *MapTest

Init - sets up the instance according to its default field values, if any

func (*MapTest) UnmarshalJSON

func (pTypeDef *MapTest) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a MapTest

func (*MapTest) Validate

func (pTypeDef *MapTest) Validate() error

Validate - checks for missing required fields, etc

type MapTypeBuilder

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

func NewMapTypeBuilder

func NewMapTypeBuilder(supertype string, name string) *MapTypeBuilder

func (*MapTypeBuilder) Build

func (tb *MapTypeBuilder) Build() *Type

func (*MapTypeBuilder) Comment

func (tb *MapTypeBuilder) Comment(comment string) *MapTypeBuilder

func (*MapTypeBuilder) Items

func (tb *MapTypeBuilder) Items(items string) *MapTypeBuilder

func (*MapTypeBuilder) Keys

func (tb *MapTypeBuilder) Keys(keys string) *MapTypeBuilder

type MapTypeDef

type MapTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// The type of the keys, default to String.
	//
	Keys TypeRef `json:"keys" rdl:"default=String"`

	//
	// The type of the items, default to Any type
	//
	Items TypeRef `json:"items" rdl:"default=Any"`

	//
	// If present, indicates the fixed size.
	//
	Size *int32 `json:"size,omitempty" rdl:"optional"`

	//
	// If present, indicate the min size
	//
	MinSize *int32 `json:"minSize,omitempty" rdl:"optional"`

	//
	// If present, indicate the max size
	//
	MaxSize *int32 `json:"maxSize,omitempty" rdl:"optional"`
}

MapTypeDef - Map types can be restricted by key type, item type and size

func NewMapTypeDef

func NewMapTypeDef(init ...*MapTypeDef) *MapTypeDef

NewMapTypeDef - creates an initialized MapTypeDef instance, returns a pointer to it

func (*MapTypeDef) Init

func (self *MapTypeDef) Init() *MapTypeDef

Init - sets up the instance according to its default field values, if any

func (MapTypeDef) String

func (s MapTypeDef) String() string

func (*MapTypeDef) UnmarshalJSON

func (self *MapTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a MapTypeDef

func (*MapTypeDef) Validate

func (self *MapTypeDef) Validate() error

Validate - checks for missing required fields, etc

type NamespacedIdentifier

type NamespacedIdentifier string

NamespacedIdentifier - A Namespace is a dotted compound name, using reverse domain name order (i.e. "com.yahoo.auth")

type NegativeNumberTest

type NegativeNumberTest struct {
	Mylatitude float64 `json:"mylatitude"`
}

NegativeNumberTest -

func NewNegativeNumberTest

func NewNegativeNumberTest(init ...*NegativeNumberTest) *NegativeNumberTest

NewNegativeNumberTest - creates an initialized NegativeNumberTest instance, returns a pointer to it

func (*NegativeNumberTest) UnmarshalJSON

func (pTypeDef *NegativeNumberTest) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a NegativeNumberTest

func (*NegativeNumberTest) Validate

func (pTypeDef *NegativeNumberTest) Validate() error

Validate - checks for missing required fields, etc

type Number

type Number struct {
	Variant NumberVariantTag `json:"-" rdl:"union"`
	Int8    *int8            `json:"Int8,omitempty"`
	Int16   *int16           `json:"Int16,omitempty"`
	Int32   *int32           `json:"Int32,omitempty"`
	Int64   *int64           `json:"Int64,omitempty"`
	Float32 *float32         `json:"Float32,omitempty"`
	Float64 *float64         `json:"Float64,omitempty"`
}

Number - A numeric is any of the primitive numeric types

func (Number) String

func (u Number) String() string

func (*Number) UnmarshalJSON

func (p *Number) UnmarshalJSON(b []byte) error

UnmarshalJSON for Number

func (*Number) Validate

func (p *Number) Validate() error

Validate for Number

type NumberTypeBuilder

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

func NewNumberTypeBuilder

func NewNumberTypeBuilder(supertype string, name string) *NumberTypeBuilder

func (*NumberTypeBuilder) Build

func (tb *NumberTypeBuilder) Build() *Type

func (*NumberTypeBuilder) Comment

func (tb *NumberTypeBuilder) Comment(comment string) *NumberTypeBuilder

func (*NumberTypeBuilder) Max

func (tb *NumberTypeBuilder) Max(max interface{}) *NumberTypeBuilder

func (*NumberTypeBuilder) Min

func (tb *NumberTypeBuilder) Min(min interface{}) *NumberTypeBuilder

type NumberTypeDef

type NumberTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// Min value
	//
	Min *Number `json:"min,omitempty" rdl:"optional"`

	//
	// Max value
	//
	Max *Number `json:"max,omitempty" rdl:"optional"`
}

NumberTypeDef - A number type definition allows the restriction of numeric values.

func NewNumberTypeDef

func NewNumberTypeDef(init ...*NumberTypeDef) *NumberTypeDef

NewNumberTypeDef - creates an initialized NumberTypeDef instance, returns a pointer to it

func (NumberTypeDef) String

func (s NumberTypeDef) String() string

func (*NumberTypeDef) UnmarshalJSON

func (self *NumberTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a NumberTypeDef

func (*NumberTypeDef) Validate

func (self *NumberTypeDef) Validate() error

Validate - checks for missing required fields, etc

type NumberVariantTag

type NumberVariantTag int

NumberVariantTag - generated to support Number

const (
	NumberVariantInt8 NumberVariantTag
	NumberVariantInt16
	NumberVariantInt32
	NumberVariantInt64
	NumberVariantFloat32
	NumberVariantFloat64
)

Supporting constants

type Options

type Options int

Options - options comment

const (
	ONE Options
	TWO
	THREE
)

Options constants

func NewOptions

func NewOptions(init ...interface{}) Options

NewOptions - return a string representation of the enum

func (Options) MarshalJSON

func (e Options) MarshalJSON() ([]byte, error)

MarshalJSON is defined for proper JSON encoding of a Options

func (Options) String

func (e Options) String() string

String - return a string representation of the enum

func (*Options) UnmarshalJSON

func (e *Options) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a Options

type Principal

type Principal interface {
	GetDomain() string
	GetName() string
	GetYRN() string
	GetCredentials() string
	GetHTTPHeaderName() string
}

Principal is the subject of authentication.

type Resource

type Resource struct {

	//
	// The type of the resource
	//
	Type TypeRef `json:"type"`

	//
	// The method for the action (typically GET, POST, etc for HTTP access)
	//
	Method string `json:"method"`

	//
	// The resource path template
	//
	Path string `json:"path"`

	//
	// The optional comment
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// An Array named inputs
	//
	Inputs []*ResourceInput `json:"inputs,omitempty" rdl:"optional"`

	//
	// An Array of named outputs
	//
	Outputs []*ResourceOutput `json:"outputs,omitempty" rdl:"optional"`

	//
	// The optional authentication or authorization directive
	//
	Auth *ResourceAuth `json:"auth,omitempty" rdl:"optional"`

	//
	// The expected symbolic response code
	//
	Expected string `json:"expected" rdl:"default=OK"`

	//
	// The set of alternative but non-error response codes
	//
	Alternatives []string `json:"alternatives,omitempty" rdl:"optional"`

	//
	// A map of symbolic response code to Exception definitions
	//
	Exceptions map[string]*ExceptionDef `json:"exceptions,omitempty" rdl:"optional"`

	//
	// A hint to server implementations that this resource would be better
	// implemented with async I/O
	//
	Async *bool `json:"async,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// Optional hint for resource acceptable input types
	//
	Consumes []string `json:"consumes,omitempty" rdl:"optional"`

	//
	// Optional hint for resource output content types
	//
	Produces []string `json:"produces,omitempty" rdl:"optional"`

	//
	// The optional name of the resource
	//
	Name Identifier `json:"name,omitempty" rdl:"optional"`
}

Resource - A Resource of a REST service

func NewResource

func NewResource(init ...*Resource) *Resource

NewResource - creates an initialized Resource instance, returns a pointer to it

func (*Resource) Init

func (self *Resource) Init() *Resource

Init - sets up the instance according to its default field values, if any

func (Resource) String

func (r Resource) String() string

func (*Resource) UnmarshalJSON

func (self *Resource) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a Resource

func (*Resource) Validate

func (self *Resource) Validate() error

Validate - checks for missing required fields, etc

type ResourceAuth

type ResourceAuth struct {

	//
	// if present and true, then the requester must be authenticated
	//
	Authenticate bool `json:"authenticate,omitempty" rdl:"default=false"`

	//
	// the action to authorize access to. This forces authentication
	//
	Action string `json:"action,omitempty" rdl:"optional"`

	//
	// the resource identity to authorize access to
	//
	Resource string `json:"resource,omitempty" rdl:"optional"`

	//
	// if present, the alternate domain to check access to. This is rare.
	//
	Domain string `json:"domain,omitempty" rdl:"optional"`
}

ResourceAuth - ResourceAuth defines authentication and authorization attributes of a resource. Presence of action, resource, or domain implies authentication; the authentication flag alone is required only when no authorization is done.

func NewResourceAuth

func NewResourceAuth(init ...*ResourceAuth) *ResourceAuth

NewResourceAuth - creates an initialized ResourceAuth instance, returns a pointer to it

func (*ResourceAuth) UnmarshalJSON

func (self *ResourceAuth) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a ResourceAuth

func (*ResourceAuth) Validate

func (self *ResourceAuth) Validate() error

Validate - checks for missing required fields, etc

type ResourceBuilder

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

func NewResourceBuilder

func NewResourceBuilder(typename string, method string, path string) *ResourceBuilder

func (*ResourceBuilder) Auth

func (rb *ResourceBuilder) Auth(action string, resource string, authn bool, domain string) *ResourceBuilder

func (*ResourceBuilder) Build

func (rb *ResourceBuilder) Build() *Resource

func (*ResourceBuilder) Comment

func (rb *ResourceBuilder) Comment(comment string) *ResourceBuilder

func (*ResourceBuilder) Exception

func (rb *ResourceBuilder) Exception(sym string, typename string, comment string) *ResourceBuilder

func (*ResourceBuilder) Expected

func (rb *ResourceBuilder) Expected(sym string) *ResourceBuilder

func (*ResourceBuilder) Input

func (rb *ResourceBuilder) Input(name string, typename string, pparam bool, qparam string, header string, optional bool, def interface{}, comment string) *ResourceBuilder

func (*ResourceBuilder) Name

func (rb *ResourceBuilder) Name(sym string) *ResourceBuilder

func (*ResourceBuilder) Output

func (rb *ResourceBuilder) Output(name string, typename string, header string, optional bool, comment string) *ResourceBuilder

type ResourceContext

type ResourceContext struct {
	Writer    http.ResponseWriter
	Request   *http.Request
	Params    map[string]string
	Principal Principal
	Values    map[string]interface{}
}

ResourceContext is the context for a handler callout, in case access to the underlying request information is needed. Because explicit arguments are declared in the API with RDL (include path, query, and header params), the need to access this is rare. Note that the map of name to value is not protected for concurrency - the app must do this itself if it plans on sharing ResourceContext across threads.

func (*ResourceContext) Get

func (ctx *ResourceContext) Get(name string) interface{}

Get - returns an application data value on the context.

func (*ResourceContext) Put

func (ctx *ResourceContext) Put(name string, value interface{}) *ResourceContext

Put - associates an application datum to the given name in the context. This call is not thread-safe, the app must arrange to allow multi-threaded access.

type ResourceError

type ResourceError struct {
	Code    int    `json:"code"`    //the http status code
	Message string `json:"message"` //a human readable message

}

ResourceError is the generic container for service errors.

func (ResourceError) Error

func (e ResourceError) Error() string

func (ResourceError) StatusCode

func (e ResourceError) StatusCode() int

type ResourceInput

type ResourceInput struct {

	//
	// the formal name of the input
	//
	Name Identifier `json:"name"`

	//
	// The type of the input
	//
	Type TypeRef `json:"type"`

	//
	// The optional comment
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// true of this input is a path parameter
	//
	PathParam bool `json:"pathParam,omitempty" rdl:"default=false"`

	//
	// if present, the name of the query param name
	//
	QueryParam string `json:"queryParam,omitempty" rdl:"optional"`

	//
	// If present, the name of the header the input is associated with
	//
	Header string `json:"header,omitempty" rdl:"optional"`

	//
	// If present, the pattern associated with the pathParam (i.e. wildcard path
	// matches)
	//
	Pattern string `json:"pattern,omitempty" rdl:"optional"`

	//
	// If present, the default value for optional params
	//
	Default interface{} `json:"default,omitempty" rdl:"optional"`

	//
	// If present, indicates that the input is optional
	//
	Optional bool `json:"optional,omitempty" rdl:"default=false"`

	//
	// If present, indicates the queryparam is of flag style (no value)
	//
	Flag bool `json:"flag,omitempty" rdl:"default=false"`

	//
	// If present, indicates the parameter comes form the implementation context
	//
	Context string `json:"context,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`
}

ResourceInput - ResourceOutput defines input characteristics of a Resource

func NewResourceInput

func NewResourceInput(init ...*ResourceInput) *ResourceInput

NewResourceInput - creates an initialized ResourceInput instance, returns a pointer to it

func (*ResourceInput) UnmarshalJSON

func (self *ResourceInput) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a ResourceInput

func (*ResourceInput) Validate

func (self *ResourceInput) Validate() error

Validate - checks for missing required fields, etc

type ResourceOutput

type ResourceOutput struct {

	//
	// the formal name of the output
	//
	Name Identifier `json:"name"`

	//
	// The type of the output
	//
	Type TypeRef `json:"type"`

	//
	// the name of the header associated with this output
	//
	Header string `json:"header"`

	//
	// The optional comment for the output
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// If present, indicates that the output is optional (the server decides)
	//
	Optional bool `json:"optional,omitempty" rdl:"default=false"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`
}

ResourceOutput - ResourceOutput defines output characteristics of a Resource

func NewResourceOutput

func NewResourceOutput(init ...*ResourceOutput) *ResourceOutput

NewResourceOutput - creates an initialized ResourceOutput instance, returns a pointer to it

func (*ResourceOutput) UnmarshalJSON

func (self *ResourceOutput) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a ResourceOutput

func (*ResourceOutput) Validate

func (self *ResourceOutput) Validate() error

Validate - checks for missing required fields, etc

type Schema

type Schema struct {

	//
	// The namespace for the schema
	//
	Namespace NamespacedIdentifier `json:"namespace,omitempty" rdl:"optional"`

	//
	// The name of the schema
	//
	Name Identifier `json:"name,omitempty" rdl:"optional"`

	//
	// The version of the schema
	//
	Version *int32 `json:"version,omitempty" rdl:"optional"`

	//
	// The comment for the entire schema
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// The types this schema defines.
	//
	Types []*Type `json:"types,omitempty" rdl:"optional"`

	//
	// The resources for a service this schema defines
	//
	Resources []*Resource `json:"resources,omitempty" rdl:"optional"`

	//
	// the base path for resources in the schema.
	//
	Base string `json:"base,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`
}

Schema - A Schema is a container for types and resources. It is self-contained (no external references). and is the output of the RDL parser.

func NewSchema

func NewSchema(init ...*Schema) *Schema

NewSchema - creates an initialized Schema instance, returns a pointer to it

func ParseRDLFile

func ParseRDLFile(path string, verbose bool, pedantic bool, nowarn bool) (*Schema, error)

ParseRDLFile parses the specified file to produce a Schema object.

func RdlSchema

func RdlSchema() *Schema

func (Schema) String

func (s Schema) String() string

func (*Schema) UnmarshalJSON

func (self *Schema) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a Schema

func (*Schema) Validate

func (self *Schema) Validate() error

Validate - checks for missing required fields, etc

type SchemaBuilder

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

func NewSchemaBuilder

func NewSchemaBuilder(name string) *SchemaBuilder

func (*SchemaBuilder) AddResource

func (sb *SchemaBuilder) AddResource(r *Resource) *SchemaBuilder

func (*SchemaBuilder) AddType

func (sb *SchemaBuilder) AddType(t *Type) *SchemaBuilder

func (*SchemaBuilder) Base added in v1.4.12

func (sb *SchemaBuilder) Base(base string) *SchemaBuilder

func (*SchemaBuilder) Build

func (sb *SchemaBuilder) Build() *Schema

Build is legacy function preserved for API compatibility. Deprecated - use BuildParanoid instead, function may be removed in future releases.

func (*SchemaBuilder) BuildParanoid added in v1.5.0

func (sb *SchemaBuilder) BuildParanoid() (*Schema, error)

BuildParanoid build the schema, returns a poiner to it on success, non-nil error otherwise.

func (*SchemaBuilder) Comment

func (sb *SchemaBuilder) Comment(comment string) *SchemaBuilder

func (*SchemaBuilder) Namespace

func (sb *SchemaBuilder) Namespace(ns string) *SchemaBuilder

func (*SchemaBuilder) Version

func (sb *SchemaBuilder) Version(version int32) *SchemaBuilder

type StringTest

type StringTest struct {
	Name   string   `json:"name"`
	Parent string   `json:"parent"`
	Names  []string `json:"names,omitempty" rdl:"optional"`
	Enc    string   `json:"enc,omitempty" rdl:"optional"`
}

StringTest -

func NewStringTest

func NewStringTest(init ...*StringTest) *StringTest

NewStringTest - creates an initialized StringTest instance, returns a pointer to it

func (*StringTest) UnmarshalJSON

func (pTypeDef *StringTest) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a StringTest

func (*StringTest) Validate

func (pTypeDef *StringTest) Validate() error

Validate - checks for missing required fields, etc

type StringTypeBuilder

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

func NewStringTypeBuilder

func NewStringTypeBuilder(name string) *StringTypeBuilder

func (*StringTypeBuilder) Build

func (tb *StringTypeBuilder) Build() *Type

func (*StringTypeBuilder) Comment

func (tb *StringTypeBuilder) Comment(comment string) *StringTypeBuilder

func (*StringTypeBuilder) MaxSize

func (tb *StringTypeBuilder) MaxSize(maxsize int32) *StringTypeBuilder

func (*StringTypeBuilder) MinSize

func (tb *StringTypeBuilder) MinSize(minsize int32) *StringTypeBuilder

func (*StringTypeBuilder) Pattern

func (tb *StringTypeBuilder) Pattern(pattern string) *StringTypeBuilder

type StringTypeDef

type StringTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// A regular expression that must be matched. Mutually exclusive with values
	//
	Pattern string `json:"pattern,omitempty" rdl:"optional"`

	//
	// A set of allowable values
	//
	Values []string `json:"values,omitempty" rdl:"optional"`

	//
	// Min size
	//
	MinSize *int32 `json:"minSize,omitempty" rdl:"optional"`

	//
	// Max size
	//
	MaxSize *int32 `json:"maxSize,omitempty" rdl:"optional"`
}

StringTypeDef - Strings allow the restriction by regular expression pattern or by an explicit set of values. An optional maximum size may be asserted

func NewStringTypeDef

func NewStringTypeDef(init ...*StringTypeDef) *StringTypeDef

NewStringTypeDef - creates an initialized StringTypeDef instance, returns a pointer to it

func (StringTypeDef) String

func (s StringTypeDef) String() string

func (*StringTypeDef) UnmarshalJSON

func (self *StringTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a StringTypeDef

func (*StringTypeDef) Validate

func (self *StringTypeDef) Validate() error

Validate - checks for missing required fields, etc

type Struct

type Struct map[Symbol]interface{}

Struct - A typedef for a "naked" struct with no field definitions.

Structs can be tested for equality, along with all RDL types.

func (Struct) Equal

func (s Struct) Equal(another Struct) bool

func (Struct) String

func (s Struct) String() string

type StructFieldDef

type StructFieldDef struct {

	//
	// The name of the field
	//
	Name Identifier `json:"name"`

	//
	// The type of the field
	//
	Type TypeRef `json:"type"`

	//
	// The field may be omitted even if specified
	//
	Optional bool `json:"optional,omitempty" rdl:"default=false"`

	//
	// If field is absent, what default value should be assumed.
	//
	Default interface{} `json:"default,omitempty" rdl:"optional"`

	//
	// The comment for the field
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// For map or array fields, the type of the items
	//
	Items TypeRef `json:"items,omitempty" rdl:"optional"`

	//
	// For map type fields, the type of the keys
	//
	Keys TypeRef `json:"keys,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`
}

StructFieldDef - Each field in a struct_field_spec is defined by this type

func NewStructFieldDef

func NewStructFieldDef(init ...*StructFieldDef) *StructFieldDef

NewStructFieldDef - creates an initialized StructFieldDef instance, returns a pointer to it

func (StructFieldDef) String

func (f StructFieldDef) String() string

func (*StructFieldDef) UnmarshalJSON

func (self *StructFieldDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a StructFieldDef

func (*StructFieldDef) Validate

func (self *StructFieldDef) Validate() error

Validate - checks for missing required fields, etc

type StructTypeBuilder

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

func NewStructTypeBuilder

func NewStructTypeBuilder(supertype string, name string) *StructTypeBuilder

func (*StructTypeBuilder) ArrayField

func (tb *StructTypeBuilder) ArrayField(fname string, fitems string, optional bool, comment string) *StructTypeBuilder

func (*StructTypeBuilder) Build

func (tb *StructTypeBuilder) Build() *Type

func (*StructTypeBuilder) Comment

func (tb *StructTypeBuilder) Comment(comment string) *StructTypeBuilder

func (*StructTypeBuilder) Field

func (tb *StructTypeBuilder) Field(fname string, ftype string, optional bool, def interface{}, comment string) *StructTypeBuilder

func (*StructTypeBuilder) MapField

func (tb *StructTypeBuilder) MapField(fname string, fkeys string, fitems string, optional bool, comment string) *StructTypeBuilder

type StructTypeDef

type StructTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// The fields in this struct. By default, open Structs can have any fields in
	// addition to these
	//
	Fields []*StructFieldDef `json:"fields"`

	//
	// indicates that only the specified fields are acceptable. Default is open
	// (any fields)
	//
	Closed bool `json:"closed,omitempty" rdl:"default=false"`
}

StructTypeDef - A struct can restrict specific named fields to specific types. By default, any field not specified is allowed, and can be of any type. Specifying closed means only those fields explicitly

func NewStructTypeDef

func NewStructTypeDef(init ...*StructTypeDef) *StructTypeDef

NewStructTypeDef - creates an initialized StructTypeDef instance, returns a pointer to it

func (*StructTypeDef) Init

func (self *StructTypeDef) Init() *StructTypeDef

Init - sets up the instance according to its default field values, if any

func (StructTypeDef) String

func (s StructTypeDef) String() string

func (*StructTypeDef) UnmarshalJSON

func (self *StructTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a StructTypeDef

func (*StructTypeDef) Validate

func (self *StructTypeDef) Validate() error

Validate - checks for missing required fields, etc

type SymTest

type SymTest struct {
	Symmap map[Symbol]string `json:"symmap"`
	Symary []Symbol          `json:"symary"`
	Sym    Symbol            `json:"sym"`
}

SymTest -

func NewSymTest

func NewSymTest(init ...*SymTest) *SymTest

NewSymTest - creates an initialized SymTest instance, returns a pointer to it

func (*SymTest) Init

func (pTypeDef *SymTest) Init() *SymTest

Init - sets up the instance according to its default field values, if any

func (*SymTest) UnmarshalJSON

func (pTypeDef *SymTest) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a SymTest

func (*SymTest) Validate

func (pTypeDef *SymTest) Validate() error

Validate - checks for missing required fields, etc

type Symbol

type Symbol string

Symbol - a wrapper for string that marshals according to the RDL Symbol spec

These symbols are not interned (no global symbtable), this is just for encoding.

type Test

type Test struct {
	Name         string     `json:"name"`
	Utfname      string     `json:"utfname"`
	Bool         bool       `json:"bool"`
	Bool2        bool       `json:"bool2"`
	Int          int32      `json:"int"`
	Mylong       int64      `json:"mylong"`
	Mydbl        float64    `json:"mydbl"`
	Intarray     ArrayOfInt `json:"intarray,omitempty" rdl:"optional"`
	My_int_array []int32    `json:"my_int_array"`
	My_str_array []string   `json:"my_str_array"`
	Myuuid       UUID       `json:"myuuid"`
	Myaz         string     `json:"myaz"`
	Myyear       int32      `json:"myyear"`
	Mypi         float64    `json:"mypi"`
	Myotherlong  int64      `json:"myotherlong"`
	Mytime       Timestamp  `json:"mytime"`
	Myoptions    Options    `json:"myoptions"`
	Co1          string     `json:"co1"`
	Co2          string     `json:"co2"`
	Co3          string     `json:"co3"`
	Symtest      *SymTest   `json:"symtest"`
}

Test -

func NewTest

func NewTest(init ...*Test) *Test

NewTest - creates an initialized Test instance, returns a pointer to it

func (*Test) Init

func (pTypeDef *Test) Init() *Test

Init - sets up the instance according to its default field values, if any

func (*Test) UnmarshalJSON

func (pTypeDef *Test) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a Test

func (*Test) Validate

func (pTypeDef *Test) Validate() error

Validate - checks for missing required fields, etc

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp - a wrapper for time.Time that marshals according to the RDL Timestamp spec

func NewTimestamp

func NewTimestamp(t time.Time) Timestamp

NewTimestamp - create a new Timestamp from the specified time.Time

func TimestampFromEpoch

func TimestampFromEpoch(secondsSinceEpoch float64) Timestamp

TimestampFromEpoch creates a new Timestamp from the specified time.Time

func TimestampNow

func TimestampNow() Timestamp

TimestampNow - returns a Timestamp representing the current time

func TimestampParse

func TimestampParse(s string) (Timestamp, error)

TimestampParse - parses the string and returns a Timestamp, or error

func (Timestamp) Equal

func (ts Timestamp) Equal(ts2 Timestamp) bool

Equal - returns true if two timestamps have the same value, to millisecond accuracy The JSON representation of dates is only millisecond resolution.

func (Timestamp) MarshalJSON

func (ts Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON - marshal the Timestamp in RDL format (RFC3339, UTC, millisecond resolution)

func (Timestamp) Micros

func (ts Timestamp) Micros() int64

Micros - returns the number of microseconds, as an int64, since the epoch (Jan 1, 1970).

func (Timestamp) Millis

func (ts Timestamp) Millis() int64

Millis - returns the number of milliseconds, as an int64, since the epoch (Jan 1, 1970). This is compatible with Java timestamps.

func (Timestamp) SecondsSinceEpoch

func (ts Timestamp) SecondsSinceEpoch() float64

SecondsSinceEpoch - returns the number of seconds, as a float64, since the epoch (Jan 1, 1970). This is compatible with Python timestamps.

func (Timestamp) String

func (ts Timestamp) String() string

String - Show the Timestamp in RFC3339 format, UTC, millisecond resolution

func (*Timestamp) UnmarshalJSON

func (ts *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON - parse a Timestamp from a JSON string

func (Timestamp) Validate

func (ts Timestamp) Validate() error

Validate - return an error if the timestamp is not valid

type TimestampTest

type TimestampTest struct {
	Mytime Timestamp `json:"mytime"`
}

TimestampTest -

func NewTimestampTest

func NewTimestampTest(init ...*TimestampTest) *TimestampTest

NewTimestampTest - creates an initialized TimestampTest instance, returns a pointer to it

func (*TimestampTest) UnmarshalJSON

func (pTypeDef *TimestampTest) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a TimestampTest

func (*TimestampTest) Validate

func (pTypeDef *TimestampTest) Validate() error

Validate - checks for missing required fields, etc

type Type

type Type struct {
	Variant       TypeVariantTag `json:"-" rdl:"union"`
	BaseType      *BaseType      `json:"BaseType,omitempty"`
	StructTypeDef *StructTypeDef `json:"StructTypeDef,omitempty"`
	MapTypeDef    *MapTypeDef    `json:"MapTypeDef,omitempty"`
	ArrayTypeDef  *ArrayTypeDef  `json:"ArrayTypeDef,omitempty"`
	EnumTypeDef   *EnumTypeDef   `json:"EnumTypeDef,omitempty"`
	UnionTypeDef  *UnionTypeDef  `json:"UnionTypeDef,omitempty"`
	StringTypeDef *StringTypeDef `json:"StringTypeDef,omitempty"`
	BytesTypeDef  *BytesTypeDef  `json:"BytesTypeDef,omitempty"`
	NumberTypeDef *NumberTypeDef `json:"NumberTypeDef,omitempty"`
	AliasTypeDef  *AliasTypeDef  `json:"AliasTypeDef,omitempty"`
}

Type - A Type can be specified by any of the above specialized Types, determined by the value of the the 'type' field

func (Type) String

func (u Type) String() string

func (*Type) UnmarshalJSON

func (p *Type) UnmarshalJSON(b []byte) error

UnmarshalJSON for Type

func (*Type) Validate

func (p *Type) Validate() error

Validate for Type

type TypeDef

type TypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`
}

TypeDef - TypeDef is the basic type definition.

func NewTypeDef

func NewTypeDef(init ...*TypeDef) *TypeDef

NewTypeDef - creates an initialized TypeDef instance, returns a pointer to it

func (TypeDef) String

func (s TypeDef) String() string

func (*TypeDef) UnmarshalJSON

func (self *TypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a TypeDef

func (*TypeDef) Validate

func (self *TypeDef) Validate() error

Validate - checks for missing required fields, etc

type TypeName

type TypeName string

TypeName - The identifier for an already-defined type

type TypeRef

type TypeRef string

TypeRef - A type reference can be a simple name, or also a namespaced name.

type TypeRegistry

type TypeRegistry interface {
	Name() string
	FindType(name TypeRef) *Type
	BaseType(t *Type) BaseType
	BaseTypeName(tn TypeRef) TypeName
	FindBaseType(typeName TypeRef) BaseType
	IsBaseTypeName(name TypeRef) bool
	IsStringType(t *Type) bool
	IsStringTypeName(tn TypeRef) bool
	IsArrayType(t *Type) bool
	IsArrayTypeName(tn TypeRef) bool
}

TypeRegistry is a set of related types, usually initialized from a schema.

func NewTypeRegistry

func NewTypeRegistry(schema *Schema) TypeRegistry

NewTypeRegistry creates and returns a new TypeRegistry, initialized with the specified schema

type TypeVariantTag

type TypeVariantTag int

TypeVariantTag - generated to support Type

const (
	TypeVariantBaseType TypeVariantTag
	TypeVariantStructTypeDef
	TypeVariantMapTypeDef
	TypeVariantArrayTypeDef
	TypeVariantEnumTypeDef
	TypeVariantUnionTypeDef
	TypeVariantStringTypeDef
	TypeVariantBytesTypeDef
	TypeVariantNumberTypeDef
	TypeVariantAliasTypeDef
)

Supporting constants

type UUID

type UUID []byte

UUID - a wrapper around a 16 byte slice representing a UUID.

func NewUUID

func NewUUID(b []byte) UUID

NewUUID - wrap an existing byte array as a UUID. Returns nil if not 16 bytes in length

func ParseUUID

func ParseUUID(s string) UUID

ParseUUID - parse the string to produce a UUID

func (UUID) Equal

func (u UUID) Equal(another UUID) bool

Equal - return true if another UUID is equal to this one

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

MarshalJSON produces the standard format for a UUID as a JSON string.

func (UUID) String

func (u UUID) String() string

String produces the standard "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" representaion of a UUID.

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a JSON string in standard UUID format.

type UUIDTest

type UUIDTest struct {
	Myid UUID `json:"myid"`
}

UUIDTest -

func NewUUIDTest

func NewUUIDTest(init ...*UUIDTest) *UUIDTest

NewUUIDTest - creates an initialized UUIDTest instance, returns a pointer to it

func (*UUIDTest) UnmarshalJSON

func (pTypeDef *UUIDTest) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a UUIDTest

func (*UUIDTest) Validate

func (pTypeDef *UUIDTest) Validate() error

Validate - checks for missing required fields, etc

type UnionTypeBuilder

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

func NewUnionTypeBuilder

func NewUnionTypeBuilder(supertype string, name string) *UnionTypeBuilder

func (*UnionTypeBuilder) Build

func (tb *UnionTypeBuilder) Build() *Type

func (*UnionTypeBuilder) Comment

func (tb *UnionTypeBuilder) Comment(comment string) *UnionTypeBuilder

func (*UnionTypeBuilder) Variant

func (tb *UnionTypeBuilder) Variant(variant string) *UnionTypeBuilder

type UnionTypeDef

type UnionTypeDef struct {

	//
	// The type this type is derived from. For base types, it is the same as the
	// name
	//
	Type TypeRef `json:"type"`

	//
	// The name of the type
	//
	Name TypeName `json:"name"`

	//
	// The comment for the type
	//
	Comment string `json:"comment,omitempty" rdl:"optional"`

	//
	// additional annotations starting with "x_"
	//
	Annotations map[ExtendedAnnotation]string `json:"annotations,omitempty" rdl:"optional"`

	//
	// The type names of constituent types. Union types get expanded, this is a
	// flat list
	//
	Variants []TypeRef `json:"variants"`
}

UnionTypeDef - Define a type as one of any other specified type.

func NewUnionTypeDef

func NewUnionTypeDef(init ...*UnionTypeDef) *UnionTypeDef

NewUnionTypeDef - creates an initialized UnionTypeDef instance, returns a pointer to it

func (*UnionTypeDef) Init

func (self *UnionTypeDef) Init() *UnionTypeDef

Init - sets up the instance according to its default field values, if any

func (UnionTypeDef) String

func (s UnionTypeDef) String() string

func (*UnionTypeDef) UnmarshalJSON

func (self *UnionTypeDef) UnmarshalJSON(b []byte) error

UnmarshalJSON is defined for proper JSON decoding of a UnionTypeDef

func (*UnionTypeDef) Validate

func (self *UnionTypeDef) Validate() error

Validate - checks for missing required fields, etc

type Validatable

type Validatable interface {
	Validate() error
}

Validatable - if implemented, this can be called directly to validate. Otherwise, introspection is used.

type Validation

type Validation struct {
	Valid   bool        `json:"valid"`
	Type    string      `json:"type,omitempty"`
	Error   string      `json:"error,omitempty"`
	Value   interface{} `json:"value,omitempty"`
	Context string      `json:"context,omitempty"`
}

Validation is the result of a call to the validator. When sucessful, the Valid field is true, and when not, it is false, with other optional fields providing extra information

func Validate

func Validate(schema *Schema, typename string, data interface{}) Validation

Validate tests the provided generic data against a type in the specified schema. If the typename is empty, an attempt to guess the type is made, otherwise the check is done against the single type.

func (Validation) String

func (v Validation) String() string

Directories

Path Synopsis
Stub to satisfy go 1.6 complaint about no buildable source files Future documentation placeholder
Stub to satisfy go 1.6 complaint about no buildable source files Future documentation placeholder

Jump to

Keyboard shortcuts

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