spec

package
v0.0.0-...-986c4a6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: MIT Imports: 5 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SchemaHub = &schemaHub{schemaById: make(map[string]*Schema)}

Central repository for schemas

Functions

This section is empty.

Types

type Attribute

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

Enhanced SCIM attribute model. Attribute is the basic unit that describes data requirement in SCIM. It includes the data requirement defined in RFC7643. It also includes additional metadata that makes actual SCIM processing easier.

func (*Attribute) CaseExact

func (attr *Attribute) CaseExact() bool

Return true if the attribute's value is case sensitive. Note that case sensitivity only applies to string type attributes. The API does not provide a version in reverse form (i.e. CaseInExact) because they are too similar, and may potentially confuse developers, leading to bugs. Too check for case insensitivity, just use !attribute.CaseExact()

func (*Attribute) CountAnnotations

func (attr *Attribute) CountAnnotations() int

Return the number of total annotations on this attribute.

func (*Attribute) CountCanonicalValues

func (attr *Attribute) CountCanonicalValues() int

Return the total number of defined canonical values.

func (*Attribute) CountReferenceTypes

func (attr *Attribute) CountReferenceTypes() int

Return the total number of reference types

func (*Attribute) CountSubAttributes

func (attr *Attribute) CountSubAttributes() int

Return the total number of sub attributes.

func (*Attribute) DFS

func (attr *Attribute) DFS(callback func(a *Attribute))

Perform a depth-first-traversal on the given attribute.

func (*Attribute) Description

func (attr *Attribute) Description() string

Return human-readable text to describe the attribute.

func (*Attribute) Equals

func (attr *Attribute) Equals(other *Attribute) bool

Returns true if the two attributes are equal. This method checks pointer equality first. If does not match, goes on to check whether id matches.

func (*Attribute) FindSubAttribute

func (attr *Attribute) FindSubAttribute(criteria func(subAttr *Attribute) bool) *Attribute

Find the sub attribute that matches the criteria, or nil

func (*Attribute) ForEachAnnotation

func (attr *Attribute) ForEachAnnotation(callback func(annotation string))

Iterate through all annotations on this attribute and invoke callback function on each.

func (*Attribute) ForEachCanonicalValue

func (attr *Attribute) ForEachCanonicalValue(callback func(canonicalValue string))

Iterate through all canonical values and invoke the callback function on each value.

func (*Attribute) ForEachReferenceType

func (attr *Attribute) ForEachReferenceType(callback func(referenceType string))

Iterate through all reference types and invoke the callback function on each value.

func (*Attribute) ForEachSubAttribute

func (attr *Attribute) ForEachSubAttribute(callback func(subAttribute *Attribute))

Iterate through all sub attributes and invoke the callback function on each value. This method is designed to preserve the SOLID principal. The callback SHALL NOT block the executing Goroutine.

func (*Attribute) GoesBy

func (attr *Attribute) GoesBy(name string) bool

Return true if this attribute can be addressed by the given name. The method performs a case insensitive comparision of the provided name against the attribute's id, path, and name. If any matches, the attribute is considered addressable by that name.

func (*Attribute) HasAnnotation

func (attr *Attribute) HasAnnotation(annotation string) bool

Returns true if this attribute is annotated with the given value

func (*Attribute) HasCanonicalValue

func (attr *Attribute) HasCanonicalValue(criteria func(value string) bool) bool

Returns true if the a certain canonical value that meets the given criteria is defined among the canonical values of this attribute.

func (*Attribute) HasIdentitySubAttributes

func (attr *Attribute) HasIdentitySubAttributes() bool

Return true if one or more of this attribute's sub attributes is marked as identity

func (*Attribute) HasPrimarySubAttribute

func (attr *Attribute) HasPrimarySubAttribute() bool

Return true if one of this attribute's sub attribute is marked as primary.

func (*Attribute) HasReferenceType

func (attr *Attribute) HasReferenceType(criteria func(value string) bool) bool

Returns true if the a certain reference type that meets the given criteria is defined among the reference types of this attribute.

func (*Attribute) ID

func (attr *Attribute) ID() string

Return ID of the attribute that uniquely identifies an attribute globally. ID shall be in the format of <schema_urn>:<full_path>. Core attributes has no need to prefix the schema URN. For instance, "schemas", "meta.version", "urn:ietf:params:scim:schemas:core:2.0:Group:displayName"

func (*Attribute) Index

func (attr *Attribute) Index() int

Return relative index of this attribute within its parent attribute, or on the top level. This index is used to sort the attribute, or the property carrying this attribute in ascending order within the scope of its container. The intention is to provide a stable iteration order, despite Golang's map does not range in a predictable order. The actual value of the index does not matter as long as they can be sorted in ascending order correctly.

func (*Attribute) IsElementAttributeOf

func (attr *Attribute) IsElementAttributeOf(other *Attribute) bool

Returns true if this attribute is the derived element attribute of the other attribute.

func (*Attribute) IsIdentity

func (attr *Attribute) IsIdentity() bool

Return true if this attribute is considered an identity attribute. An identity attribute is annotated with annotations.Identity (@Identity). When one or more sub attributes for a complex attribute is annotated with @Identity, they will collectively be used to determine the identity of the complex attribute. Other attributes that were not annotated with @Identity no longer participates in operations like equality which involves identity.

func (*Attribute) IsPrimary

func (attr *Attribute) IsPrimary() bool

Return true if this attribute is considered a primary attribute. A primary attribute is annotated with annotations.Primary (@Primary). It is only effective when it is annotated on a singular boolean attribute as a sub attribute of a multiValued complex attribute. The purpose is that among all the element boolean properties carrying this attribute, at most one can assume a true value.

func (*Attribute) Len

func (attr *Attribute) Len() int

func (*Attribute) Less

func (attr *Attribute) Less(i, j int) bool

func (*Attribute) MarshalJSON

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

func (*Attribute) MultiValued

func (attr *Attribute) MultiValued() bool

Return true if the attribute is multiValued.

func (*Attribute) MustValidate

func (attr *Attribute) MustValidate()

Validate the attribute. This method panics if encounters any error.

func (*Attribute) Mutability

func (attr *Attribute) Mutability() Mutability

Return the mutability of the attribute.

func (*Attribute) Name

func (attr *Attribute) Name() string

Return the name of the attribute.

func (*Attribute) NewElementAttribute

func (attr *Attribute) NewElementAttribute(annotations ...string) *Attribute

Create the element attribute from this attribute. The element attribute is a derived attribute design for elements of a multiValued attribute. The ID of the attribute is suffixed with elemSuffix ("$elem"), and the multiValued attribute is set to false. All other attributes are carried over.

func (*Attribute) Optional

func (attr *Attribute) Optional() bool

Return true if the attribute is optional, which is the opposite of required.

func (*Attribute) Path

func (attr *Attribute) Path() string

Return the full path of this attribute. The full path will be the name of the attribute if this attribute is on the top level. If the attribute is a sub attribute, it will be attribute names delimited by period (".").

func (*Attribute) Required

func (attr *Attribute) Required() bool

Return true if the attribute is required.

func (*Attribute) Returned

func (attr *Attribute) Returned() Returned

Return the return-ability of the attribute.

func (*Attribute) SingleValued

func (attr *Attribute) SingleValued() bool

Return true if the attribute is singular.

func (*Attribute) Sort

func (attr *Attribute) Sort()

Sort the sub attributes recursively based on the index.

func (*Attribute) String

func (attr *Attribute) String() string

Return a string representation of the attribute. This method is intended to assist debugger printing, and does not intend to display all data.

func (*Attribute) SubAttributeForName

func (attr *Attribute) SubAttributeForName(name string) *Attribute

Return the sub attribute that goes by the name, or nil

func (*Attribute) Swap

func (attr *Attribute) Swap(i, j int)

func (*Attribute) Type

func (attr *Attribute) Type() Type

Return the data type of the attribute. The data type cannot be used to definitively determine the nature of the attribute unless combined with the method MultiValued.

func (*Attribute) Uniqueness

func (attr *Attribute) Uniqueness() Uniqueness

Return the uniqueness of the attribute.

func (*Attribute) UnmarshalJSON

func (attr *Attribute) UnmarshalJSON(raw []byte) error

type Mutability

type Mutability int

SCIM mutability definition

const (
	// SCIM mutability attribute defined in RFC7643
	MutabilityReadWrite Mutability = iota
	MutabilityReadOnly
	MutabilityWriteOnly
	MutabilityImmutable
)

func MustParseMutability

func MustParseMutability(value string) Mutability

Parse the given value to mutability type. Empty value is defaulted to readWrite. This function panics if the given value is invalid.

func (Mutability) MarshalJSON

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

func (Mutability) String

func (m Mutability) String() string

Return the standard string representation of this mutability

type ResourceType

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

A SCIM resource type is a collection of schemas to describe a resource.

func (*ResourceType) CountExtensions

func (t *ResourceType) CountExtensions() int

Return the number of schema extensions in this resource type

func (*ResourceType) Description

func (t *ResourceType) Description() string

Return the description of the resource type

func (*ResourceType) Endpoint

func (t *ResourceType) Endpoint() string

func (*ResourceType) ForEachExtension

func (t *ResourceType) ForEachExtension(callback func(extension *Schema, required bool))

Iterate through all schema extensions and invoke the callback. The required parameter is the callback function indicates whether this schema extension is required. This method maintains SOLID principal. The callback SHALL NOT block.

func (*ResourceType) ID

func (t *ResourceType) ID() string

Return the id of the resource type

func (*ResourceType) MarshalJSON

func (t *ResourceType) MarshalJSON() ([]byte, error)

func (*ResourceType) Name

func (t *ResourceType) Name() string

Return the name of the resource type

func (*ResourceType) Schema

func (t *ResourceType) Schema() *Schema

Return the main schema of the resource type

func (*ResourceType) SuperAttribute

func (t *ResourceType) SuperAttribute(includeCore bool) *Attribute

Return a complex attribute that contains all schema attributes as its sub attributes.

func (*ResourceType) UnmarshalJSON

func (t *ResourceType) UnmarshalJSON(raw []byte) error

type Returned

type Returned int

SCIM returned definition

const (
	// SCIM returned attribute defined in RFC7643
	ReturnedDefault Returned = iota
	ReturnedAlways
	ReturnedRequest
	ReturnedNever
)

func MustParseReturned

func MustParseReturned(value string) Returned

Parse the given value to returned type. Empty value is defaulted to 'default'. This function panics if the given value is invalid.

func (Returned) MarshalJSON

func (r Returned) MarshalJSON() ([]byte, error)

func (Returned) String

func (r Returned) String() string

Return a standard definition of this return-ability

type Schema

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

A SCIM schema is a collection of attributes, used to describe a whole or a part of a resource.

func (*Schema) CountAttributes

func (s *Schema) CountAttributes() int

Return the number of top level attributes in this schema.

func (*Schema) Description

func (s *Schema) Description() string

Return the description of the schema

func (*Schema) ForEachAttribute

func (s *Schema) ForEachAttribute(callback func(attr *Attribute))

Iterate the top level attributes in this schema and invoke callback function. This method maintains SOLID principal. Callback function SHALL NOT block.

func (*Schema) ID

func (s *Schema) ID() string

Return the ID of the schema.

func (*Schema) MarshalJSON

func (s *Schema) MarshalJSON() ([]byte, error)

func (*Schema) Name

func (s *Schema) Name() string

Return the name of the schema.

func (*Schema) UnmarshalJSON

func (s *Schema) UnmarshalJSON(raw []byte) error

type ServiceProviderConfig

type ServiceProviderConfig struct {
	Schemas []string `json:"schemas"`
	DocURI  string   `json:"documentationUri"`
	Patch   struct {
		Supported bool `json:"supported"`
	} `json:"patch"`
	Bulk struct {
		Supported  bool `json:"supported"`
		MaxOp      int  `json:"maxOperations"`
		MaxPayload int  `json:"maxPayloadSize"`
	} `json:"bulk"`
	Filter struct {
		Supported  bool `json:"supported"`
		MaxResults int  `json:"maxResults"`
	} `json:"filter"`
	ChangePassword struct {
		Supported bool `json:"supported"`
	} `json:"changePassword"`
	Sort struct {
		Supported bool `json:"supported"`
	} `json:"sort"`
	ETag struct {
		Supported bool `json:"supported"`
	} `json:"etag"`
	AuthSchemes []struct {
		Type        string `json:"type"`
		Name        string `json:"name"`
		Description string `json:"description"`
		SpecURI     string `json:"specUri"`
		DocURI      string `json:"documentationUri"`
	} `json:"authenticationSchemes"`
}

Structure for the service provider config

type Type

type Type int

A SCIM data type

const (
	// SCIM data types defined in RFC7643
	TypeString Type = iota
	TypeInteger
	TypeDecimal
	TypeBoolean
	TypeDateTime
	TypeReference
	TypeBinary
	TypeComplex
)

func MustParseType

func MustParseType(value string) Type

Parse the given value to type. Empty value is defaulted to 'string'. This function panics if the given value is invalid.

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

func (Type) String

func (t Type) String() string

Return the standard string representation of this type

type Uniqueness

type Uniqueness int

SCIM uniqueness definition

const (
	// SCIM uniqueness attribute defined in RFC7643
	UniquenessNone Uniqueness = iota
	UniquenessServer
	UniquenessGlobal
)

func MustParseUniqueness

func MustParseUniqueness(value string) Uniqueness

Parse the given value to uniqueness type. Empty value is defaulted to 'none'. This function panics if the given value is invalid.

func (Uniqueness) MarshalJSON

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

func (Uniqueness) String

func (u Uniqueness) String() string

Return a standard definition of this uniqueness.

Jump to

Keyboard shortcuts

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