Documentation
¶
Overview ¶
Package scimtag parses scim struct tags into RFC 7643 attribute characteristics and caches them for marshal, unmarshal, filter, patch, and schema generation.
Index ¶
Constants ¶
const TagName = "scim"
Variables ¶
This section is empty.
Functions ¶
func BuildAllSCIMCharacsCache ¶
func BuildAllSCIMCharacsCache(obj ...any)
func GetSCIMCharacsInSubAttributes ¶
func GetSCIMCharacsInSubAttributes(t reflect.Type) (map[string]CacheValue, error)
func MutabilityStrings ¶
func MutabilityStrings() []string
MutabilityStrings returns a slice of all String values of the enum
func UniquenessStrings ¶
func UniquenessStrings() []string
UniquenessStrings returns a slice of all String values of the enum
Types ¶
type CacheValue ¶
type CacheValue struct {
Field reflect.StructField
Tag Characteristics
}
type Characteristics ¶
type Characteristics struct {
Name string `pt:"0"` // MUST set, else it gets value from other's
Required bool `pt:"required"`
CaseExact bool `pt:"caseExact"`
Mutability Mutability `pt:"mutability"` // default 'readWrite'
Returned Returned `pt:"returned"` // default 'default'
Uniqueness Uniqueness `pt:"uniqueness"` // none (default), server, global
CanonicalValues []string `pt:"canonicalValues,split=space"` // like for email type, 'home', 'work','others'
ReferenceTypes []string `pt:"referenceTypes,split=space"` // like for groups's $ref, 'User', 'Group'
// special
IgnoreUnmarshal bool `pt:"ignoreUnmarshal"` // special for 'meta'
SQL string `pt:"sql"`
}
Characteristics (Characs) contains information about each field of Resource (Users, Groups), which controls how to handle this field/attribute. RFC: https://datatracker.ietf.org/doc/html/rfc7643#section-7
Characteristics MUST be specified by 'scim' tag in Resource struct and will parse to this struct, not specified in tag will be default value, like `scim:"userName,returned=always,required"`:
{
Name: "userName",
Returned: "always",
Required: true,
CaseExact: false, // default value
....
}
Those information controls how to handle this field or attribute. For example 'returned' controls marshal behavior.
func GetSCIMCharacs ¶
func GetSCIMCharacs(t reflect.Type, attributeName string) (reflect.StructField, Characteristics, error)
type Mutability ¶
type Mutability int
const ( ReadWrite Mutability = iota ReadOnly Immutable WriteOnly )
func MutabilityString ¶
func MutabilityString(s string) (Mutability, error)
MutabilityString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func MutabilityValues ¶
func MutabilityValues() []Mutability
MutabilityValues returns all values of the enum
func (Mutability) IsAMutability ¶
func (i Mutability) IsAMutability() bool
IsAMutability returns "true" if the value is listed in the enum definition. "false" otherwise
func (Mutability) MarshalText ¶
func (i Mutability) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for Mutability
func (Mutability) String ¶
func (i Mutability) String() string
func (*Mutability) UnmarshalText ¶
func (i *Mutability) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for Mutability
type Returned ¶
type Returned int
Returned is an characteristics of attributes. It controls how SCIM returned, in this implementation it controls marshal
const ( Default Returned = iota // will omit empty when marshal KeepEmpty // will marshal empty value (It's not in RFC and will marshal to 'default' in schema) Always // will alway marshal the field (even not request) Never // will never marshal the field (even requested) Request // will marshal when it's been requested )
func (Returned) MarshalText ¶
func (*Returned) UnmarshalText ¶
type Uniqueness ¶
type Uniqueness int
const ( None Uniqueness = iota Server Global )
RFC values: none server global
func UniquenessString ¶
func UniquenessString(s string) (Uniqueness, error)
UniquenessString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func UniquenessValues ¶
func UniquenessValues() []Uniqueness
UniquenessValues returns all values of the enum
func (Uniqueness) IsAUniqueness ¶
func (i Uniqueness) IsAUniqueness() bool
IsAUniqueness returns "true" if the value is listed in the enum definition. "false" otherwise
func (Uniqueness) MarshalText ¶
func (i Uniqueness) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for Uniqueness
func (Uniqueness) String ¶
func (i Uniqueness) String() string
func (*Uniqueness) UnmarshalText ¶
func (i *Uniqueness) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for Uniqueness