foliolib.folio.usersImpl.UsersImpl

class foliolib.folio.usersImpl.UsersImpl(tenant: str)

Bases: foliolib.folio.FolioAPIImpl

Implentations of user related functions.

Parameters

tenant (str) – Tenant id

Methods

add_servicePoint(username, servicePointId)

Add a servicepoint to a user.

add_user(username, password[, permissions, ...])

Add a user.

delete_permission(username, permissionName)

Delete a permission for a user.

delete_permissions(username, permissionNames)

Delete given permissions for a user.

delete_user(name_or_id)

Delete a user by username or id.

get_permissions(username)

Get permissions of a user

get_servicePointsUser(username)

Get servicepoints of a user.

get_user(name_or_id)

Get a user by username or id

get_users([query])

Get users by query or get all users.

login(username, password)

Make a authentication.

modify_servicePointsUser(username, **kwargs)

Modify servicePointsUser obejct for a user.

modify_user(username[, permissions])

Modify a user by username.

remove_servicePoint(username, servicePointId)

Remove a servicepoint from a user.

set_defaultServicePoint(username, ...)

Set default servicepoint for a user.

set_password(username, password)

Set a new password for given username.

set_permission(username, permissionName)

Set permission for a user.

set_permissions(username, permissionNames)

Set permissions for a user.

add_servicePoint(username: str, servicePointId: str)

Add a servicepoint to a user.

Parameters
  • username (str) – Username or id.

  • servicePointId (str) – Servicepoint id.

Returns

ServicePointsUser object.

Return type

dict

add_user(username: str, password: str, permissions: list = None, userServicePoints: bool = True, **kwargs)

Add a user.

A Credential, PermissionUser and ServicePointUser object will be also created.

Parameters
  • username (str) – Username.

  • password (str) – Password.

  • permissions (list, optional) – List with permissions. Defaults to None.

  • userServicePoints (bool, optional) – Wether to bind all available servicepoints to the user. Defaults to True.

Keyword Arguments
  • uuid (str) – UUID of the user.

  • active (bool) – Wether user is active. Defaults to True.

  • barcode (str) – Barcode.

  • group (str) – Groupname or id.

  • departments (list, str) – Departments list with names, codes or ids, or a department name, code or id.

  • addresses (list, dict, UserAddress) – List of UserAddress or dict instances. Or Useraddress or dict Instance.

  • preferredContactTypeId (str) – AddressType name or id of user’s preferred contact type like Email, Mail or Text Message.

  • lastName (str) – The user’s surname. [personal]

  • firstName (str) – The user’s given name. [personal]

  • middleName (str) – The user’s middle name (if any). [personal]

  • preferredFirstName (str) – The user’s preferred name. [personal]

  • email (str) – The user’s email address. [personal]

  • phone (str) – The user’s primary phone number. [personal]

  • mobilePhone (str) – The user’s mobile phone number. [personal]

  • dateOfBirth (str) – The user’s birth date. [personal]

  • type (str) – The class of user like staff or patron; this is different from patronGroup.

  • enrollmentDate (str) – The date in which the user joined the organization (format: date-time).

  • expirationDate (str) – The date for when the user becomes inactive (format: date-time).

  • tags (list) – List of tags (str).

  • customFields (dict) – Dict that contains custom fields.

Raises
  • GroupNotFound – Group not found.

  • DepartmentNotFound – Department not found.

  • AddressTypeNotFound – AddressType not found.

Returns

user object.

Return type

dict

delete_permission(username: str, permissionName: str)

Delete a permission for a user.

Parameters
  • username (str) – Username or id.

  • permissionName (str) – Permission name.

delete_permissions(username: str, permissionNames: list)

Delete given permissions for a user.

Parameters
  • username (str) – Username or id.

  • permissionNames (list) – List with permissions.

delete_user(name_or_id: str)

Delete a user by username or id.

The coresponding Credential, PermissionUser and ServicePointUser object will be also removed.

Parameters

username (str) – Username or id

get_permissions(username: str)

Get permissions of a user

Parameters

username (str) – Username or id.

Returns

Dict with permissions

Return type

dict

get_servicePointsUser(username: str)

Get servicepoints of a user.

Parameters

username (str) – Username or id.

Returns

Dict with servicepoints

Return type

dict

get_user(name_or_id: str)

Get a user by username or id

Parameters

name_or_id (str) – Username or id

Raises

UserNotFound – User not found

Returns

Dict with user data

Return type

dict

get_users(query: str = None)

Get users by query or get all users.

Parameters

query (str, optional) – CQL string. Default to None, all objects will be returned.

Returns

List with user objects.

Return type

list

login(username: str, password: str)

Make a authentication.

Parameters
  • username (str) – Username

  • password (str) – Password

Returns

Object of the authenticated user.

Return type

dict

Raises

LoginFailed – login failed.

modify_servicePointsUser(username: str, **kwargs)

Modify servicePointsUser obejct for a user.

Parameters

username (str) – Username or id.

Keyword Arguments
  • servicePointsIds (list) – List with service point ids.

  • defaultServicePointId (str) – The default servicepoint of a user.

Returns

ServicePointsUser object.

Return type

dict

modify_user(username: str, permissions: list = None, **kwargs)

Modify a user by username.

If a keyword arg is None, the entry will be removed.

Parameters
  • username (str) – Username or id.

  • permissions (list, optional) – List with permissions to add to the user. Defaults to None.

Keyword Arguments
  • active (bool) – Wether user is active.

  • barcode (str) – Barcode.

  • group (str) – Groupname or id.

  • departments (list, str) – Departments list with names, codes or ids to replace. Or a department name, code or id to add.

  • preferredContactTypeId (str) – AddressType name or id of user’s preferred contact type like Email, Mail or Text Message.

  • lastName (str) – The user’s surname. [personal]

  • firstName (str) – The user’s given name. [personal]

  • middleName (str) – The user’s middle name (if any). [personal]

  • preferredFirstName (str) – The user’s preferred name. [personal]

  • email (str) – The user’s email address. [personal]

  • phone (str) – The user’s primary phone number. [personal]

  • mobilePhone (str) – The user’s mobile phone number. [personal]

  • dateOfBirth (str) – The user’s birth date. [personal]

  • addresses (list, dict, UserAddress) – List of UserAddress or dict instances to replace addresses. Or Useraddress or dict Instance, to add a address.

  • type (str) – The class of user like staff or patron; this is different from patronGroup.

  • enrollmentDate (str) – The date in which the user joined the organization (format: date-time).

  • expirationDate (str) – The date for when the user becomes inactive (format: date-time).

  • tags (list) – List of tags (str).

  • customFields (dict) – Dict that contains custom fields.

Raises
  • GroupNotFound – Group not found.

  • DepartmentNotFound – Department not found.

  • AddressTypeNotFound – AddressType not found.

Returns

user object.

Return type

dict

remove_servicePoint(username: str, servicePointId: str)

Remove a servicepoint from a user.

Parameters
  • username (str) – Username or id.

  • servicePointId (str) – Servicepoint id.

Returns

ServicePointsUser object.

Return type

dict

set_defaultServicePoint(username: str, defaultServicePointId: str)

Set default servicepoint for a user.

Parameters
  • username (str) – Username or id.

  • defaultServicePointId (str) – Servicepoint id.

Returns

ServicePointsUser object.

Return type

dict

set_password(username: str, password: str)

Set a new password for given username.

Parameters
  • username (str) – Username of the user.

  • password (str) – Password of the user.

Returns

Wether set password was successful.

Return type

bool

set_permission(username: str, permissionName: str)

Set permission for a user.

Parameters
  • username (str) – Username or id.

  • permissionName (str) – Permission name.

set_permissions(username: str, permissionNames: list)

Set permissions for a user.

Parameters
  • username (str) – Username or id.

  • permissionNames (list) – List with permissions.