User Groups (v1.0)

http://github.com/org/folio/mod-users

Table of contents

mod-users Departments API

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

/departments

Collection of department items.

GET /departments

Return a list of departmants

GET /departments
Query Parameters
  • query: (string)

    A query expressed as a CQL string (see 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: (integer - default: 0 - minimum: 0 - maximum: 2147483647)

    Skip over a number of elements by specifying an offset value for the query

    Example:

    0
  • limit: (integer - default: 10 - minimum: 0 - maximum: 2147483647)

    Limit the number of elements returned in the response

    Example:

    10
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns a list of department items

Body

Media type: application/json

Type: json

Content:

{
  "$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"]
}

Example:

{
  "departments": [
    {
      "id": "b4b5e97a-0a99-4db9-97df-4fdf406ec74d",
      "name": "Accounting",
      "code": "ACC",
      "usageNumber": 0
    },
    {
      "id": "4bb563d9-3f9d-4e1e-8d1d-04e75666d68f",
      "name": "History",
      "code": "HIS",
      "usageNumber": 2
    }
  ],
  "totalRecords": 2
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

unable to list departments -- malformed parameter 'query', syntax error at column 6

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to list departments -- unauthorized

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

POST /departments

Create a departmant

POST /departments
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$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
    },
    "metadata": {
      "description": "Metadata about creation and changes to department records",
      "$ref": "raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "required": [
    "name",
    "code"
  ]
}

Example:

{
  "id": "b4b5e97a-0a99-4db9-97df-4fdf406ec74d",
  "name": "Accounting",
  "code": "ACC",
  "usageNumber": 10
}

Response 201

Returns a newly created item, with server-controlled fields like 'id' populated

Headers
  • Location: required (string)

    URI to the created department item

Body

Media type: application/json

Type: any

Example:

{
  "id": "b4b5e97a-0a99-4db9-97df-4fdf406ec74d",
  "name": "Accounting",
  "code": "ACC",
  "usageNumber": 10
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to add department -- malformed JSON at 13:3"

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to create departments -- unauthorized

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

PUT /departments/{departmentId}

Update department item with given {departmentId}

PUT /departments/{departmentId}
URI Parameters
  • departmentId: required (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$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
    },
    "metadata": {
      "description": "Metadata about creation and changes to department records",
      "$ref": "raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "required": [
    "name",
    "code"
  ]
}

Example:

{
  "id": "b4b5e97a-0a99-4db9-97df-4fdf406ec74d",
  "name": "Accounting",
  "code": "ACC",
  "usageNumber": 10
}

Response 204

Item successfully updated

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to update department -- malformed JSON at 13:4"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"department not found"

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

GET /departments/{departmentId}

Retrieve department item with given {departmentId}

GET /departments/{departmentId}
URI Parameters
  • departmentId: required (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns item with a given ID

Body

Media type: application/json

Type: json

Content:

{
  "$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
    },
    "metadata": {
      "description": "Metadata about creation and changes to department records",
      "$ref": "raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "required": [
    "name",
    "code"
  ]
}

Example:

{
  "id": "b4b5e97a-0a99-4db9-97df-4fdf406ec74d",
  "name": "Accounting",
  "code": "ACC",
  "usageNumber": 10
}

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"department not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

DELETE /departments/{departmentId}

Delete department item with given {departmentId}

DELETE /departments/{departmentId}
URI Parameters
  • departmentId: required (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 204

Item deleted successfully

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to delete department -- constraint violation"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"department not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator