schema

package
v0.0.0-...-172bf2a Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 8 Imported by: 13

Documentation

Index

Constants

View Source
const (
	CommonAttributeID         = "id"
	CommonAttributeExternalID = "externalId"
	CommonAttributeMeta       = "meta"
)

Keys for the Common Attributes: https://tools.ietf.org/html/rfc7643#section-3.1

View Source
const (
	// UserSchema is the URI for the User resource.
	UserSchema = "urn:ietf:params:scim:schemas:core:2.0:User"

	// GroupSchema is the URI for the Group resource.
	GroupSchema = "urn:ietf:params:scim:schemas:core:2.0:Group"
)

Variables

This section is empty.

Functions

func SetAllowStringValues

func SetAllowStringValues(enabled bool)

SetAllowStringValues sets whether string values are allowed. If enabled, string values are allowed for booleans, integer and decimal attributes. NOTE: This is NOT a standard SCIM behaviour, and should only be used for compatibility with non-compliant SCIM clients, such as the one provided by Microsoft Azure.

Types

type AttributeDataType

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

AttributeDataType is a single keyword indicating the derived data type from JSON.

func AttributeTypeDecimal

func AttributeTypeDecimal() AttributeDataType

AttributeTypeDecimal indicates that the data type is a real number with at least one digit to the left and right of the period. This is the default value.

func AttributeTypeInteger

func AttributeTypeInteger() AttributeDataType

AttributeTypeInteger indicates that the data type is a whole number with no fractional digits or decimal.

type AttributeMutability

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

AttributeMutability is a single keyword indicating the circumstances under which the value of the attribute can be (re)defined.

func AttributeMutabilityImmutable

func AttributeMutabilityImmutable() AttributeMutability

AttributeMutabilityImmutable indicates that the attribute MAY be defined at resource creation (e.g., POST) or at record replacement via a request (e.g., a PUT). The attribute SHALL NOT be updated.

func AttributeMutabilityReadOnly

func AttributeMutabilityReadOnly() AttributeMutability

AttributeMutabilityReadOnly indicates that the attribute SHALL NOT be modified.

func AttributeMutabilityReadWrite

func AttributeMutabilityReadWrite() AttributeMutability

AttributeMutabilityReadWrite indicates that the attribute MAY be updated and read at any time. This is the default value.

func AttributeMutabilityWriteOnly

func AttributeMutabilityWriteOnly() AttributeMutability

AttributeMutabilityWriteOnly indicates that the attribute MAY be updated at any time. Attribute values SHALL NOT be returned (e.g., because the value is a stored hash). Note: An attribute with a mutability of "writeOnly" usually also has a returned setting of "never".

type AttributeReferenceType

type AttributeReferenceType string

AttributeReferenceType is a single keyword indicating the reference type of the SCIM resource that may be referenced. This attribute is only applicable for attributes that are of type "reference".

const (
	// AttributeReferenceTypeExternal indicates that the resource is an external resource.
	AttributeReferenceTypeExternal AttributeReferenceType = "external"
	// AttributeReferenceTypeURI indicates that the reference is to a service endpoint or an identifier.
	AttributeReferenceTypeURI AttributeReferenceType = "uri"
)

type AttributeReturned

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

AttributeReturned is a single keyword indicating the circumstances under which an attribute and associated values are returned in response to a GET request or in response to a PUT, POST, or PATCH request.

func AttributeReturnedAlways

func AttributeReturnedAlways() AttributeReturned

AttributeReturnedAlways indicates that the attribute is always returned.

func AttributeReturnedDefault

func AttributeReturnedDefault() AttributeReturned

AttributeReturnedDefault indicates that the attribute is returned by default in all SCIM operation responses where attribute values are returned.

func AttributeReturnedNever

func AttributeReturnedNever() AttributeReturned

AttributeReturnedNever indicates that the attribute is never returned.

func AttributeReturnedRequest

func AttributeReturnedRequest() AttributeReturned

AttributeReturnedRequest indicates that the attribute is returned in response to any PUT, POST, or PATCH operations if the attribute was specified by the client (for example, the attribute was modified).

type AttributeUniqueness

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

AttributeUniqueness is a single keyword value that specifies how the service provider enforces uniqueness of attribute values.

func AttributeUniquenessGlobal

func AttributeUniquenessGlobal() AttributeUniqueness

AttributeUniquenessGlobal indicates that the value SHOULD be globally unique (e.g., an email address, a GUID, or other value). No two resources on any server SHOULD possess the same value.

func AttributeUniquenessNone

func AttributeUniquenessNone() AttributeUniqueness

AttributeUniquenessNone indicates that the values are not intended to be unique in any way. This is the default value.

func AttributeUniquenessServer

func AttributeUniquenessServer() AttributeUniqueness

AttributeUniquenessServer indicates that the value SHOULD be unique within the context of the current SCIM endpoint (or tenancy). No two resources on the same server SHOULD possess the same value.

type Attributes

type Attributes []CoreAttribute

Attributes represent a list of Core Attributes.

func (Attributes) ContainsAttribute

func (as Attributes) ContainsAttribute(name string) (CoreAttribute, bool)

ContainsAttribute checks whether the list of Core Attributes contains an attribute with the given name.

type BinaryParams

type BinaryParams struct {
	Description optional.String
	MultiValued bool
	Mutability  AttributeMutability
	Name        string
	Required    bool
	Returned    AttributeReturned
}

BinaryParams are the parameters used to create a simple attribute with a data type of "binary". The attribute value MUST be base64 encoded. In JSON representation, the encoded values are represented as a JSON string. A binary is case exact and has no uniqueness.

type BooleanParams

type BooleanParams struct {
	Description optional.String
	MultiValued bool
	Mutability  AttributeMutability
	Name        string
	Required    bool
	Returned    AttributeReturned
}

BooleanParams are the parameters used to create a simple attribute with a data type of "boolean". The literal "true" or "false". A boolean has no case sensitivity or uniqueness.

type ComplexParams

type ComplexParams struct {
	Description   optional.String
	MultiValued   bool
	Mutability    AttributeMutability
	Name          string
	Required      bool
	Returned      AttributeReturned
	SubAttributes []SimpleParams
	Uniqueness    AttributeUniqueness
}

ComplexParams are the parameters used to create a complex attribute.

type CoreAttribute

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

CoreAttribute represents those attributes that sit at the top level of the JSON object together with the common attributes (such as the resource "id").

func CommonAttributes

func CommonAttributes() []CoreAttribute

CommonAttributes returns all the common attributes.

func ComplexCoreAttribute

func ComplexCoreAttribute(params ComplexParams) CoreAttribute

ComplexCoreAttribute creates a complex attribute based on given parameters.

func SchemasAttributes

func SchemasAttributes() CoreAttribute

SchemasAttributes represent the common attribute "schemas".

func SimpleCoreAttribute

func SimpleCoreAttribute(params SimpleParams) CoreAttribute

SimpleCoreAttribute creates a non-complex attribute based on given parameters.

func (CoreAttribute) AttributeType

func (a CoreAttribute) AttributeType() string

AttributeType returns the attribute type.

func (CoreAttribute) CanonicalValues

func (a CoreAttribute) CanonicalValues() []string

CanonicalValues returns the canonical values of the attribute.

func (CoreAttribute) CaseExact

func (a CoreAttribute) CaseExact() bool

CaseExact returns whether the attribute is case exact.

func (CoreAttribute) Description

func (a CoreAttribute) Description() string

Description returns whether the description of the attribute.

func (CoreAttribute) HasSubAttributes

func (a CoreAttribute) HasSubAttributes() bool

HasSubAttributes returns whether the attribute is complex and has sub attributes.

func (CoreAttribute) MultiValued

func (a CoreAttribute) MultiValued() bool

MultiValued returns whether the attribute is multi valued.

func (CoreAttribute) Mutability

func (a CoreAttribute) Mutability() string

Mutability returns the mutability of the attribute.

func (CoreAttribute) Name

func (a CoreAttribute) Name() string

Name returns the case insensitive name of the attribute.

func (CoreAttribute) ReferenceTypes

func (a CoreAttribute) ReferenceTypes() []AttributeReferenceType

ReferenceTypes returns the reference types of the attribute.

func (CoreAttribute) Required

func (a CoreAttribute) Required() bool

Required returns whether the attribute is required.

func (CoreAttribute) Returned

func (a CoreAttribute) Returned() string

Returned returns when the attribute need to be returned.

func (CoreAttribute) SubAttributes

func (a CoreAttribute) SubAttributes() Attributes

SubAttributes returns the sub attributes.

func (CoreAttribute) Uniqueness

func (a CoreAttribute) Uniqueness() string

Uniqueness returns the attributes uniqueness.

func (CoreAttribute) ValidateSingular

func (a CoreAttribute) ValidateSingular(attribute interface{}) (interface{}, *errors.ScimError)

ValidateSingular checks whether the given singular value matches the attribute data type. Unknown attributes in given complex value are ignored. The returned interface contains a (sanitised) version of the given attribute.

type DateTimeParams

type DateTimeParams struct {
	Description optional.String
	MultiValued bool
	Mutability  AttributeMutability
	Name        string
	Required    bool
	Returned    AttributeReturned
}

DateTimeParams are the parameters used to create a simple attribute with a data type of "dateTime". A DateTime value (e.g., 2008-01-23T04:56:22Z). A date time format has no case sensitivity or uniqueness.

type NumberParams

type NumberParams struct {
	Description optional.String
	MultiValued bool
	Mutability  AttributeMutability
	Name        string
	Required    bool
	Returned    AttributeReturned
	Type        AttributeDataType
	Uniqueness  AttributeUniqueness
}

NumberParams are the parameters used to create a simple attribute with a data type of "decimal" or "integer". A number has no case sensitivity.

type ReferenceParams

type ReferenceParams struct {
	Description    optional.String
	MultiValued    bool
	Mutability     AttributeMutability
	Name           string
	ReferenceTypes []AttributeReferenceType
	Required       bool
	Returned       AttributeReturned
	Uniqueness     AttributeUniqueness
}

ReferenceParams are the parameters used to create a simple attribute with a data type of "reference". A reference is case exact. A reference has a "referenceTypes" attribute that indicates what types of resources may be linked.

type Schema

type Schema struct {
	Attributes  Attributes
	Description optional.String
	ID          string
	Name        optional.String
}

Schema is a collection of attribute definitions that describe the contents of an entire or partial resource.

func CoreGroupSchema

func CoreGroupSchema() Schema

CoreGroupSchema returns the default "Group" Resource Schema. RFC: https://tools.ietf.org/html/rfc7643#section-4.2

func CoreUserSchema

func CoreUserSchema() Schema

CoreUserSchema returns the default "User" Resource Schema. RFC: https://tools.ietf.org/html/rfc7643#section-4.1

func Definition

func Definition() Schema

Definition return the Schema Definition. RFC: https://tools.ietf.org/html/rfc7643#section-7

func ExtensionEnterpriseUser

func ExtensionEnterpriseUser() Schema

ExtensionEnterpriseUser returns the default Enterprise User Schema Extension. RFC: https://tools.ietf.org/html/rfc7643#section-4.3

func ResourceTypeSchema

func ResourceTypeSchema() Schema

ResourceTypeSchema returns the Resource Type Schema. RFC: https://tools.ietf.org/html/rfc7643#section-6

func (Schema) MarshalJSON

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

MarshalJSON converts the schema struct to its corresponding json representation.

func (Schema) ToMap

func (s Schema) ToMap() map[string]interface{}

ToMap returns the map representation of a schema.

func (Schema) Validate

func (s Schema) Validate(resource interface{}) (map[string]interface{}, *errors.ScimError)

Validate validates given resource based on the schema. Does NOT validate mutability. NOTE: only used in POST and PUT requests where attributes MAY be (re)defined.

func (Schema) ValidateMutability

func (s Schema) ValidateMutability(resource interface{}) (map[string]interface{}, *errors.ScimError)

ValidateMutability validates given resource based on the schema, including strict immutability checks.

func (Schema) ValidatePatchOperation

func (s Schema) ValidatePatchOperation(operation string, operationValue map[string]interface{}, isExtension bool) *errors.ScimError

ValidatePatchOperation validates an individual operation and its related value.

func (Schema) ValidatePatchOperationValue

func (s Schema) ValidatePatchOperationValue(operation string, operationValue map[string]interface{}) *errors.ScimError

ValidatePatchOperationValue validates an individual operation and its related value.

type SimpleParams

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

SimpleParams are the parameters used to create a simple attribute.

func SimpleBinaryParams

func SimpleBinaryParams(params BinaryParams) SimpleParams

SimpleBinaryParams converts given binary parameters to their corresponding simple parameters.

func SimpleBooleanParams

func SimpleBooleanParams(params BooleanParams) SimpleParams

SimpleBooleanParams converts given boolean parameters to their corresponding simple parameters.

func SimpleDateTimeParams

func SimpleDateTimeParams(params DateTimeParams) SimpleParams

SimpleDateTimeParams converts given date time parameters to their corresponding simple parameters.

func SimpleNumberParams

func SimpleNumberParams(params NumberParams) SimpleParams

SimpleNumberParams converts given number parameters to their corresponding simple parameters.

func SimpleReferenceParams

func SimpleReferenceParams(params ReferenceParams) SimpleParams

SimpleReferenceParams converts given reference parameters to their corresponding simple parameters.

func SimpleStringParams

func SimpleStringParams(params StringParams) SimpleParams

SimpleStringParams converts given string parameters to their corresponding simple parameters.

type StringParams

type StringParams struct {
	CanonicalValues []string
	CaseExact       bool
	Description     optional.String
	MultiValued     bool
	Mutability      AttributeMutability
	Name            string
	Required        bool
	Returned        AttributeReturned
	Uniqueness      AttributeUniqueness
}

StringParams are the parameters used to create a simple attribute with a data type of "string". A string is a sequence of zero or more Unicode characters encoded using UTF-8.

Jump to

Keyboard shortcuts

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