hscim-0.3.6: hscim json schema and server implementation
Safe HaskellNone
LanguageHaskell2010

Web.Scim.Filter

Description

A query might specify a filter that should be applied to the results before returning them. This module implements a very limited subset of the specification: https://tools.ietf.org/html/rfc7644#section-3.4.2.2.

Supported:

  • All comparison operators (eq, le, etc)
  • The userName attribute

Not supported:

  • The pr operator
  • Boolean operators
  • Combined filters
  • Fully qualified attribute names (schema prefixes, attribute paths)
Synopsis

Filter type

data Filter Source #

A filter.

Our representation of filters is lax and doesn't attempt to ensure validity on the type level. If a filter does something silly (e.g. tries to compare a username with a boolean), it will be caught during filtering and an appropriate error message will be thrown (see filterUser).

TODO(arianvp): Implement the following grammar fully if we want to support more complex filters

FILTER = attrExp logExp valuePath / *1"not" "(" FILTER ")"

Constructors

FilterAttrCompare AttrPath CompareOp CompValue

Compare the attribute value with a literal

Instances

Instances details
Eq Filter Source # 
Instance details

Defined in Web.Scim.Filter

Methods

(==) :: Filter -> Filter -> Bool #

(/=) :: Filter -> Filter -> Bool #

Show Filter Source # 
Instance details

Defined in Web.Scim.Filter

ToHttpApiData Filter Source # 
Instance details

Defined in Web.Scim.Filter

FromHttpApiData Filter Source #

We currently only support filtering on core user schema

Instance details

Defined in Web.Scim.Filter

parseFilter :: [Schema] -> Text -> Either Text Filter Source #

PATH = attrPath / valuePath [subAttr]

Currently we don't support matching on lists in paths as we currently don't support filtering on arbitrary attributes yet e.g. "path":"members[value eq "2819c223-7f76-453a-919d-413861904646"].displayName" is not supported

Parse a filter. Spaces surrounding the filter will be stripped.

If parsing fails, returns a Left with an error description.

Note: this parser is written with Attoparsec because I don't know how to lift an Attoparsec parser (from Aeson) to Megaparsec

renderFilter :: Filter -> Text Source #

Render a filter according to the SCIM spec.

Constructing filters

data CompValue Source #

A value type. Attributes are compared against literal values.

Instances

Instances details
Eq CompValue Source # 
Instance details

Defined in Web.Scim.Filter

Ord CompValue Source # 
Instance details

Defined in Web.Scim.Filter

Show CompValue Source # 
Instance details

Defined in Web.Scim.Filter

data CompareOp Source #

A comparison operator.

Constructors

OpEq

Equal

OpNe

Not equal

OpCo

Contains

OpSw

Starts with

OpEw

Ends with

OpGt

Greater than

OpGe

Greater than or equal to

OpLt

Less than

OpLe

Less than or equal to

data AttrPath Source #

attrPath = [URI ":"] ATTRNAME *1subAtt

Instances

Instances details
Eq AttrPath Source # 
Instance details

Defined in Web.Scim.Filter

Show AttrPath Source # 
Instance details

Defined in Web.Scim.Filter

data ValuePath Source #

valuePath = attrPath "[" valFilter "]" TODO(arianvp): This is a slight simplification at the moment as we don't support the complete Filter grammar. This should be a valFilter, not a FILTER.

Constructors

ValuePath AttrPath Filter 

Instances

Instances details
Eq ValuePath Source # 
Instance details

Defined in Web.Scim.Filter

Show ValuePath Source # 
Instance details

Defined in Web.Scim.Filter

newtype SubAttr Source #

subAttr = "." ATTRNAME

Constructors

SubAttr AttrName 

Instances

Instances details
Eq SubAttr Source # 
Instance details

Defined in Web.Scim.Filter

Methods

(==) :: SubAttr -> SubAttr -> Bool #

(/=) :: SubAttr -> SubAttr -> Bool #

Show SubAttr Source # 
Instance details

Defined in Web.Scim.Filter

IsString SubAttr Source # 
Instance details

Defined in Web.Scim.Filter

Methods

fromString :: String -> SubAttr #

pAttrPath :: [Schema] -> Parser AttrPath Source #

ATTRNAME  = ALPHA *(nameChar)
attrPath  = [URI ":"] ATTRNAME *1subAtt

pValuePath :: [Schema] -> Parser ValuePath Source #

valuePath = attrPath "[" valFilter "]"

pSubAttr :: Parser SubAttr Source #

subAttr = "." ATTRNAME

pFilter :: [Schema] -> Parser Filter Source #

Filter parser.

rCompareOp :: CompareOp -> Text Source #

Comparison operator renderer.

compareStr :: CompareOp -> Text -> Text -> Bool Source #

Execute a comparison operator.

topLevelAttrPath :: Text -> AttrPath Source #

Smart constructor that refers to a toplevel field with default schema