shared

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathOperand = FilterNodeType(iota + 1)
	ConstantOperand
	LogicalOperator
	RelationalOperator
	Parenthesis
)
View Source
const (
	And = "and"
	Or  = "or"
	Not = "not"
	Eq  = "eq"
	Ne  = "ne"
	Sw  = "sw"
	Ew  = "ew"
	Co  = "co"
	Pr  = "pr"
	Gt  = "gt"
	Ge  = "ge"
	Lt  = "lt"
	Le  = "le"
)
View Source
const (
	Add     = "add"
	Remove  = "remove"
	Replace = "replace"
)
View Source
const (
	UserUrn         = "urn:ietf:params:scim:schemas:core:2.0:User"
	GroupUrn        = "urn:ietf:params:scim:schemas:core:2.0:Group"
	ResourceTypeUrn = "urn:ietf:params:scim:schemas:core:2.0:resourceType"
	SPConfigUrn     = "urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"
	SchemaUrn       = "urn:ietf:params:scim:schemas:core:2.0:Schema"
	ErrorUrn        = "urn:ietf:params:scim:api:messages:2.0:Error"
	ListResponseUrn = "urn:ietf:params:scim:api:messages:2.0:ListResponse"
	PatchOpUrn      = "urn:ietf:params:scim:api:messages:2.0:PatchOp"
	SearchUrn       = "urn:ietf:params:scim:api:messages:2.0:SearchRequest"
	BulkRequestUrn  = "urn:ietf:params:scim:api:messages:2.0:BulkRequest"
	BulkResponseUrn = "urn:ietf:params:scim:api:messages:2.0:BulkResponse"

	TypeString    = "string"
	TypeBoolean   = "boolean"
	TypeBinary    = "binary"
	TypeDecimal   = "decimal"
	TypeInteger   = "integer"
	TypeDateTime  = "datetime"
	TypeReference = "reference"
	TypeComplex   = "complex"

	ReadOnly  = "readOnly"
	ReadWrite = "readWrite"
	Immutable = "immutable"
	WriteOnly = "writeOnly"

	Always  = "always"
	Never   = "never"
	Default = "default"
	Request = "request"

	None   = "none"
	Server = "server"
	Global = "global"

	External = "external"
	Uri      = "uri"

	UserResourceType                  = "User"
	GroupResourceType                 = "Group"
	SchemaResourceType                = "Schema"
	ResourceTypeResourceType          = "ResourceType"
	ServiceProviderConfigResourceType = "ServiceProviderConfig"
)
View Source
const (
	GetUserById
	CreateUser
	ReplaceUser
	PatchUser
	QueryUser
	DeleteUser
	GetGroupById
	CreateGroup
	ReplaceGroup
	PatchGroup
	QueryGroup
	DeleteGroup
	RootQuery
	BulkOp
	GetSchemaById
	GetAllSchema
	GetSPConfig
	GetAllResourceType
)

Variables

This section is empty.

Functions

func ApplyPatch

func ApplyPatch(patch Patch, subj *Resource, sch *Schema, ctx context.Context) (err error)

func CompositeSearchFunc

func CompositeSearchFunc(
	repositories ...Repository,
) func(payload SearchRequest, ctx context.Context) (*ListResponse, error)

simple factory method to return a repository query method to easily put together a query only repository by composing several repositories, useful when implementing root query functions

func CorrectCase

func CorrectCase(subj *Resource, sch *Schema, ctx context.Context) (err error)

func MarshalJSON

func MarshalJSON(v interface{}, sch *Schema, attributes []string, excludedAttributes []string) ([]byte, error)

func NewQueue

func NewQueue(cap int) *queue

func NewQueueWithoutLimit

func NewQueueWithoutLimit() *queue

func NewStack

func NewStack(cap int) *stack

func NewStackWithoutLimit

func NewStackWithoutLimit() *stack

func ValidateMutability

func ValidateMutability(subj *Resource, ref *Resource, sch *Schema, ctx context.Context) (err error)

func ValidateRequired

func ValidateRequired(subj *Resource, sch *Schema, ctx context.Context) (err error)

func ValidateType

func ValidateType(subj *Resource, sch *Schema, ctx context.Context) (err error)

func ValidateUniqueness

func ValidateUniqueness(subj *Resource, sch *Schema, repo Repository, ctx context.Context) (err error)

Types

type Assist

type Assist struct {
	JSONName      string   `json:"_jsonName"`      // JSON field name used to render this field
	Path          string   `json:"_path"`          // period delimited field names, useful to retrieve nested fields
	FullPath      string   `json:"_full_path"`     // Path prefixed with the URN of this resource
	ArrayIndexKey []string `json:"_arrayIndexKey"` // the field names of the multiValued complex fields that can be used as a search index
}

type Attribute

type Attribute struct {
	Name            string       `json:"name,omitempty"`
	Type            string       `json:"type,omitempty"`
	SubAttributes   []*Attribute `json:"subAttributes,omitempty"`
	MultiValued     bool         `json:"multiValued"`
	Description     string       `json:"description,omitempty"`
	Required        bool         `json:"required"`
	CanonicalValues []string     `json:"canonicalValues,omitempty"`
	CaseExact       bool         `json:"caseExact,omitempty"`
	Mutability      string       `json:"mutability,omitempty"`
	Returned        string       `json:"returned,omitempty"`
	Uniqueness      string       `json:"uniqueness,omitempty"`
	ReferenceTypes  []string     `json:"referenceTypes,omitempty"`
	Assist          *Assist      `json:"_assist"`
}

func (*Attribute) Assigned

func (a *Attribute) Assigned(v reflect.Value) bool

func (*Attribute) Clone

func (a *Attribute) Clone() *Attribute

func (*Attribute) EqualsToPath

func (a *Attribute) EqualsToPath(p Path) bool

func (*Attribute) ExpectsBinary

func (a *Attribute) ExpectsBinary() bool

func (*Attribute) ExpectsBool

func (a *Attribute) ExpectsBool() bool

func (*Attribute) ExpectsComplex

func (a *Attribute) ExpectsComplex() bool

func (*Attribute) ExpectsComplexArray

func (a *Attribute) ExpectsComplexArray() bool

func (*Attribute) ExpectsFloat

func (a *Attribute) ExpectsFloat() bool

func (*Attribute) ExpectsInteger

func (a *Attribute) ExpectsInteger() bool

func (*Attribute) ExpectsString

func (a *Attribute) ExpectsString() bool

func (*Attribute) ExpectsStringArray

func (a *Attribute) ExpectsStringArray() bool

func (*Attribute) GetAttribute

func (a *Attribute) GetAttribute(p Path, recursive bool) *Attribute

func (*Attribute) MarshalJSON

func (a *Attribute) MarshalJSON() ([]byte, error)

func (*Attribute) TypeExpectation

func (a *Attribute) TypeExpectation() string

type AttributeSource

type AttributeSource interface {
	GetAttribute(p Path, recursive bool) *Attribute
}

type BulkReq

type BulkReq struct {
	Schemas      []string    `json:"schemas"`
	FailOnErrors int         `json:"failOnErrors"`
	Operations   []BulkReqOp `json:"Operations"`
}

func (BulkReq) Validate

func (br BulkReq) Validate(ps PropertySource) error

type BulkReqOp

type BulkReqOp struct {
	Path string          `json:"path"`
	Data json.RawMessage `json:"data"`
	// contains filtered or unexported fields
}

type BulkResp

type BulkResp struct {
	Schemas    []string      `json:"schemas"`
	Operations []*BulkRespOp `json:"Operations"`
}

type BulkRespOp

type BulkRespOp struct {
	Location string          `json:"location"`
	Response json.RawMessage `json:"response,omitempty"`
	Status   int             `json:"status"`
	// contains filtered or unexported fields
}

func (BulkRespOp) Populate

func (bro BulkRespOp) Populate(origReq BulkReqOp, resp WebResponse)

type Complex

type Complex map[string]interface{}

SCIM complex data structure, Not thread-safe

func (Complex) Evaluate

func (c Complex) Evaluate(filter FilterNode, guide AttributeSource) bool

Evaluate given predicate

func (Complex) Get

func (c Complex) Get(p Path, guide AttributeSource) chan interface{}

func (Complex) Set

func (c Complex) Set(p Path, value interface{}, guide AttributeSource) error

Set the value at the specified Path Path is a dot separated string that may contain filter

type DataProvider

type DataProvider interface {
	GetId() string
	GetData() Complex
}

type DuplicateError

type DuplicateError struct {
	Path  string
	Value interface{}
}

Duplicate Error

func (DuplicateError) Error

func (e DuplicateError) Error() string

type ErrorFactory

type ErrorFactory interface {
	InvalidPath(path, detail string) error
	InvalidFilter(filter, detail string) error
	InvalidType(path, expect, got string) error
	NoAttribute(path string) error
	MissingRequiredProperty(path string) error
	MutabilityViolation(path string) error
	InvalidParam(name, expect, got string) error
	ResourceNotFound(id, version string) error
	Duplicate(path string, value interface{}) error
	Text(template string, args ...interface{}) error
}
var (
	Error ErrorFactory
)

type FilterNode

type FilterNode interface {
	Data() interface{}
	Type() FilterNodeType
	Left() FilterNode
	Right() FilterNode
	CorrectCase(guide AttributeSource)
}

interface to represent a node in the filter tree

func NewFilter

func NewFilter(text string) (FilterNode, error)

create a new filter from text

type FilterNodeType

type FilterNodeType int

type of the filter node

type InvalidFilterError

type InvalidFilterError struct {
	Filter string
	Detail string
}

Invalid Filter

func (InvalidFilterError) Error

func (e InvalidFilterError) Error() string

type InvalidParamError

type InvalidParamError struct {
	Name   string
	Expect string
	Got    string
}

func (*InvalidParamError) Error

func (e *InvalidParamError) Error() string

type InvalidPathError

type InvalidPathError struct {
	Path   string
	Detail string
}

Invalid Path

func (InvalidPathError) Error

func (e InvalidPathError) Error() string

type InvalidTypeError

type InvalidTypeError struct {
	Path   string
	Expect string
	Got    string
}

Invalid Type

func (*InvalidTypeError) Error

func (e *InvalidTypeError) Error() string

type ListResponse

type ListResponse struct {
	Schemas      []string
	TotalResults int
	ItemsPerPage int
	StartIndex   int
	Resources    []DataProvider
}

---------------------------------- List Response ----------------------------------

type Logger

type Logger interface {
	Info(template string, args ...interface{})
	Debug(template string, args ...interface{})
	Error(template string, args ...interface{})
}

Common abstraction for logging providers

type MissingRequiredPropertyError

type MissingRequiredPropertyError struct {
	Path string
}

func (*MissingRequiredPropertyError) Error

type Modification

type Modification struct {
	Schemas []string `json:"schemas"`
	Ops     []Patch  `json:"Operations"`
}

---------------------------------- Patch ----------------------------------

func (Modification) Validate

func (m Modification) Validate() error

type MultiValued

type MultiValued []interface{}

SCIM multivalued data structure, Not thread-safe

func (MultiValued) Add

func (c MultiValued) Add(value ...interface{}) MultiValued

func (MultiValued) Filter

func (c MultiValued) Filter(root FilterNode, guide AttributeSource) chan interface{}

func (MultiValued) Get

func (c MultiValued) Get(index int) interface{}

func (MultiValued) Len

func (c MultiValued) Len() int

func (MultiValued) Remove

func (c MultiValued) Remove(index int) MultiValued

func (MultiValued) Set

func (c MultiValued) Set(index int, value interface{})

type MutabilityViolationError

type MutabilityViolationError struct {
	Path string
}

func (*MutabilityViolationError) Error

func (e *MutabilityViolationError) Error() string

type NoAttributeError

type NoAttributeError struct {
	Path string
}

No Attribute

func (*NoAttributeError) Error

func (e *NoAttributeError) Error() string

type Number

type Number string

func (Number) Float64

func (n Number) Float64() (float64, error)

Float64 returns the number as a float64.

func (Number) String

func (n Number) String() string

String returns the literal text of the number.

type Patch

type Patch struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value"`
}

type Path

type Path interface {
	Next() Path                        // next Path, nil means this is the last one
	Value() string                     // text value, unprocessed
	Base() string                      // base Path value, i.e. 'groups' in 'groups[type Eq "direct"]'
	FilterRoot() FilterNode            // root of the filter tree, i.e. 'Eq' in 'type Eq "direct"'
	SeparateAtLast() (Path, Path)      // break up the path chain at the last node
	CollectValue() string              // all path value downstream, separated by period.
	CorrectCase(AttributeSource, bool) // correct the case to defined values, and whether process downstream as well
}

interface to represent a single segment in a Path i.e. 'emails' in 'emails.value' i.e. 'groups[type Eq "direct"]' in 'groups[type Eq "direct"].value'

func NewPath

func NewPath(text string) (Path, error)

create a new Path from text

type PropertySource

type PropertySource interface {
	Get(key string) interface{}
	GetString(key string) string
	GetInt(key string) int
	GetBool(key string) bool
}

Common abstraction for property providers

type Queue

type Queue interface {
	Offer(item interface{})
	Poll() interface{}
	Peek() interface{}
	Size() int
	Clone() Queue
	Capacity() int
}

type ReadOnlyAssignment

type ReadOnlyAssignment interface {
	AssignValue(r *Resource, ctx context.Context) error
}

func NewGroupAssignment

func NewGroupAssignment(groupRepository Repository) ReadOnlyAssignment

func NewIdAssignment

func NewIdAssignment() ReadOnlyAssignment

func NewMetaAssignment

func NewMetaAssignment(properties PropertySource, resourceType string) ReadOnlyAssignment

type Repository

type Repository interface {
	Create(provider DataProvider, ctx context.Context) error

	Get(id, version string, ctx context.Context) (DataProvider, error)

	GetAll(ctx context.Context) ([]Complex, error)

	Count(query string, ctx context.Context) (int, error)

	Update(id, version string, provider DataProvider, ctx context.Context) error

	Delete(id, version string, ctx context.Context) error

	Search(payload SearchRequest, ctx context.Context) (*ListResponse, error)
}

func NewMapRepository

func NewMapRepository(initialData map[string]DataProvider) Repository

type RequestId

type RequestId struct{}

type RequestTimestamp

type RequestTimestamp struct{}

type RequestType

type RequestType struct{}

type Resource

type Resource struct {
	Complex
}

SCIM resource

func ParseResource

func ParseResource(filePath string) (*Resource, string, error)

func (*Resource) GetData

func (r *Resource) GetData() Complex

func (*Resource) GetId

func (r *Resource) GetId() string

type ResourceId

type ResourceId struct{}

type ResourceNotFoundError

type ResourceNotFoundError struct {
	Id      string
	Version string
}

func (ResourceNotFoundError) Error

func (e ResourceNotFoundError) Error() string

type Schema

type Schema struct {
	Schemas     []string     `json:"schemas,omitempty"`
	Id          string       `json:"id,omitempty"`
	Name        string       `json:"name,omitempty"`
	Description string       `json:"description,omitempty"`
	Attributes  []*Attribute `json:"attributes,omitempty"`
}

func ParseSchema

func ParseSchema(filePath string) (*Schema, string, error)

func (*Schema) GetAttribute

func (s *Schema) GetAttribute(p Path, recursive bool) *Attribute

func (*Schema) ToAttribute

func (s *Schema) ToAttribute() *Attribute

type SearchRequest

type SearchRequest struct {
	Schemas            []string `json:"schemas"`
	Attributes         []string `json:"attributes"`
	ExcludedAttributes []string `json:"excludedAttributes"`
	Filter             string   `json:"filter"`
	SortBy             string   `json:"sortBy"`
	SortOrder          string   `json:"sortOrder"`
	StartIndex         int      `json:"startIndex"`
	Count              int      `json:"count"`
}

---------------------------------- Search Request ----------------------------------

func (SearchRequest) Ascending

func (sr SearchRequest) Ascending() bool

func (SearchRequest) Validate

func (sr SearchRequest) Validate(guide AttributeSource) error

type Stack

type Stack interface {
	Push(item interface{})
	Peek() interface{}
	Pop() interface{}
	Size() int
	Capacity() int
	Clone() Stack
}

type WebRequest

type WebRequest interface {
	Target() string
	Method() string
	Header(name string) string
	Param(name string) string
	Body() ([]byte, error)
}

type WebResponse

type WebResponse interface {
	GetStatus() int
	GetHeader(name string) string
	GetBody() []byte
}

Jump to

Keyboard shortcuts

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