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

Web.Scim.Class.User

Documentation

class (Monad m, AuthTypes tag, UserTypes tag) => UserDB tag m where Source #

Minimal complete definition

getUsers, getUser, postUser, putUser, deleteUser

Methods

getUsers :: AuthInfo tag -> Maybe Filter -> ScimHandler m (ListResponse (StoredUser tag)) Source #

Get all users, optionally filtered by a Filter.

getUser :: AuthInfo tag -> UserId tag -> ScimHandler m (StoredUser tag) Source #

Get a single user by ID.

Should throw notFound if the user doesn't exist.

postUser :: AuthInfo tag -> User tag -> ScimHandler m (StoredUser tag) Source #

Create a new user.

Should throw conflict if uniqueness constraints are violated.

putUser :: AuthInfo tag -> UserId tag -> User tag -> ScimHandler m (StoredUser tag) Source #

Overwrite an existing user.

Should throw notFound if the user doesn't exist, and conflict if uniqueness constraints are violated.

patchUser Source #

Arguments

:: AuthInfo tag 
-> UserId tag 
-> PatchOp tag

PATCH payload

-> ScimHandler m (StoredUser tag) 

Modify an existing user.

Should throw notFound if the user doesn't exist, and conflict if uniqueness constraints are violated.

https://tools.ietf.org/html/rfc7644#section-3.5.2

If the target location already contains the value specified, no changes SHOULD be made to the resource, and a success response SHOULD be returned. Unless other operations change the resource, this operation SHALL NOT change the modify timestamp of the resource.

Given that PUT has the same constraints, we can implement PATCH in terms of some magic in this library, GET and PUT.

SCIM's Patch semantics are hard to get right. So we advice using the library built-in implementation. we implement PATCH in terms of a GET followed by a PUT. GET will retrieve the entire record; we then modify this record by a series of PATCH operations, and then PUT the entire record.

default patchUser :: (Patchable (UserExtra tag), FromJSON (UserExtra tag)) => AuthInfo tag -> UserId tag -> PatchOp tag -> ScimHandler m (StoredUser tag) Source #

deleteUser :: AuthInfo tag -> UserId tag -> ScimHandler m () Source #

Delete a user.

Should throw notFound if the user doesn't exist.

type StoredUser tag = WithMeta (WithId (UserId tag) (User tag)) Source #

data UserSite tag route Source #

Constructors

UserSite 

Fields

Instances

Instances details
Generic (UserSite tag route) Source # 
Instance details

Defined in Web.Scim.Class.User

Associated Types

type Rep (UserSite tag route) :: Type -> Type #

Methods

from :: UserSite tag route -> Rep (UserSite tag route) x #

to :: Rep (UserSite tag route) x -> UserSite tag route #

type Rep (UserSite tag route) Source # 
Instance details

Defined in Web.Scim.Class.User

type Rep (UserSite tag route) = D1 ('MetaData "UserSite" "Web.Scim.Class.User" "hscim-0.3.6-JBBH5QJtoVCBhDdsGW2kZ7" 'False) (C1 ('MetaCons "UserSite" 'PrefixI 'True) ((S1 ('MetaSel ('Just "usGetUsers") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (route :- (QueryParam "filter" Filter :> Get '[SCIM] (ListResponse (StoredUser tag))))) :*: (S1 ('MetaSel ('Just "usGetUser") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (route :- (Capture "id" (UserId tag) :> Get '[SCIM] (StoredUser tag)))) :*: S1 ('MetaSel ('Just "usPostUser") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (route :- (ReqBody '[SCIM] (User tag) :> PostCreated '[SCIM] (StoredUser tag)))))) :*: (S1 ('MetaSel ('Just "usPutUser") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (route :- (Capture "id" (UserId tag) :> (ReqBody '[SCIM] (User tag) :> Put '[SCIM] (StoredUser tag))))) :*: (S1 ('MetaSel ('Just "usPatchUser") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (route :- (Capture "id" (UserId tag) :> (ReqBody '[SCIM] (PatchOp tag) :> Patch '[SCIM] (StoredUser tag))))) :*: S1 ('MetaSel ('Just "usDeleteUser") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (route :- (Capture "id" (UserId tag) :> DeleteNoContent)))))))

userServer :: forall tag m. (AuthDB tag m, UserDB tag m) => Maybe (AuthData tag) -> UserSite tag (AsServerT (ScimHandler m)) Source #