foliolib.folio.api.users.Departments

class foliolib.folio.api.users.Departments(tenant: str, okapi: Optional[foliolib.okapi.okapiClient.OkapiClient] = None)

Bases: foliolib.folio.FolioApi

mod-users Departments API

This documents the API calls that can be made to query and manage departments of the system

Parameters
  • tenant (str) – Tenant id

  • okapi (OkapiClient, optional) – Instance of OkapiClient. Defaults to None.

Methods

delete_department(departmentId)

Delete department item with given {departmentId}

get_department(departmentId)

Retrieve department item with given {departmentId}

get_departments(**kwargs)

Return a list of departmants

modify_department(departmentId, department)

Update department item with given {departmentId}

set_department(department)

Create a departmant

delete_department(departmentId: str)

Delete department item with given {departmentId}

DELETE /departments/{departmentId}

Parameters

departmentId (str) –

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

get_department(departmentId: str)

Retrieve department item with given {departmentId}

GET /departments/{departmentId}

Parameters

departmentId (str) –

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Department",
  "description": "Department object schema",
  "javaType": "org.folio.rest.jaxrs.model.Department",
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "id": {
      "description": "A UUID identifying this department",
      "$ref": "raml-util/schemas/uuid.schema",
      "example": "f973c3b6-85fc-4d35-bda8-f31b568957bf"
    },
    "name": {
      "description": "The unique name of this department",
      "type": "string",
      "example": "Accounting"
    },
    "code": {
      "description": "The unique code of this department",
      "type": "string",
      "example": "ACC"
    },
    "usageNumber": {
      "type": "integer",
      "description": "Number of users that have this department",
      "readonly": true
    },
    "source": {
      "description": "Origin of the department record, i.e. 'System' or 'User'",
      "type": "string"
    },
    "metadata": {
      "description": "Metadata about creation and changes to department records",
      "$ref": "raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "required": [
    "name",
    "code"
  ]
}
get_departments(**kwargs)

Return a list of departmants

GET /departments

Parameters

**kwargs (properties) – Keyword Arguments

Keyword Arguments
  • query (str) –

    A query expressed as a CQL string (see [dev.folio.org/reference/glossary#cql](https://dev.folio.org/reference/glossary#cql)) using valid searchable fields. The first example below shows the general form of a full CQL query, but those fields might not be relevant in this context.

    Example

    • (username==”ab*” or personal.firstName==”ab*” or personal.lastName==”ab*”) and active==”true” sortby personal.lastName personal.firstName barcode

    • attributes.code==”acc

  • offset (int) –

    (default=0) Skip over a number of elements by specifying an offset value for the query

    Example

    • 0

  • limit (int) –

    (default=10) Limit the number of elements returned in the response

    Example

    • 10

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Department Collection",
  "description": "Department collection object schema",
  "javaType": "org.folio.rest.jaxrs.model.DepartmentCollection",
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "departments": {
      "type": "array",
      "description": "List of departments",
      "items": {
        "type": "object",
        "$ref": "department.json"
      }
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "departments",
    "totalRecords"
  ]
}
modify_department(departmentId: str, department: dict)

Update department item with given {departmentId}

PUT /departments/{departmentId}

Parameters
  • departmentId (str) –

  • department (dict) – See Schema below

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Department",
  "description": "Department object schema",
  "javaType": "org.folio.rest.jaxrs.model.Department",
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "id": {
      "description": "A UUID identifying this department",
      "$ref": "raml-util/schemas/uuid.schema",
      "example": "f973c3b6-85fc-4d35-bda8-f31b568957bf"
    },
    "name": {
      "description": "The unique name of this department",
      "type": "string",
      "example": "Accounting"
    },
    "code": {
      "description": "The unique code of this department",
      "type": "string",
      "example": "ACC"
    },
    "usageNumber": {
      "type": "integer",
      "description": "Number of users that have this department",
      "readonly": true
    },
    "source": {
      "description": "Origin of the department record, i.e. 'System' or 'User'",
      "type": "string"
    },
    "metadata": {
      "description": "Metadata about creation and changes to department records",
      "$ref": "raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "required": [
    "name",
    "code"
  ]
}
set_department(department: dict)

Create a departmant

POST /departments

Parameters

department (dict) – See Schema below

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Headers

  • Location - URI to the created department item

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Department",
  "description": "Department object schema",
  "javaType": "org.folio.rest.jaxrs.model.Department",
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "id": {
      "description": "A UUID identifying this department",
      "$ref": "raml-util/schemas/uuid.schema",
      "example": "f973c3b6-85fc-4d35-bda8-f31b568957bf"
    },
    "name": {
      "description": "The unique name of this department",
      "type": "string",
      "example": "Accounting"
    },
    "code": {
      "description": "The unique code of this department",
      "type": "string",
      "example": "ACC"
    },
    "usageNumber": {
      "type": "integer",
      "description": "Number of users that have this department",
      "readonly": true
    },
    "source": {
      "description": "Origin of the department record, i.e. 'System' or 'User'",
      "type": "string"
    },
    "metadata": {
      "description": "Metadata about creation and changes to department records",
      "$ref": "raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "required": [
    "name",
    "code"
  ]
}