Mod-Users BL (v6.1)

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

Table of contents

Business Logic Users API

A front end for mod-users and mod-permissions

/bl-users

GET /bl-users

Get a number of user (and possibly related) records based on criteria in the user and related modules

GET /bl-users
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
    
    active=true
    
  • 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
  • include: (array of string)

    indicates which referenced fields should be populated (de-referenced) by the service

Response 200

Body

Media type: application/json

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 403

Access denied

Body

Media type: text/plain

Type: any

Example:

Access denied

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

DELETE /bl-users/by-id/{id}

Delete a user by id

DELETE /bl-users/by-id/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • include: (array of string)

    indicates which referenced fields should be populated (de-referenced) by the service

Response 204

User deleted successfully

Response 404

User with a given ID not found

Body

Media type: text/plain

Type: any

Response 409

Conflict, e.g. user cannot be deleted as there are open transactions

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "User Transactions Schema",
  "description": "Schema describing open transactions of a user",
  "type": "object",
  "properties": {
    "userId": {
      "type": "string",
      "description": "User's id"
    },
    "userBarcode": {
      "type": "string",
      "description": "User's barcode"
    },
    "hasOpenTransactions": {
      "type": "boolean",
      "description": "Specifies if the user has any open transactions (loans, requests, fees/fines, proxies, manual-blocks)"
    },
    "loans": {
      "type": "integer",
      "description": "Number of open loans"
    },
    "requests": {
      "type": "integer",
      "description": "Number of open requests"
    },
    "feesFines": {
      "type": "integer",
      "description": "Number of open fees/fines"
    },
    "proxies": {
      "type": "integer",
      "description": "Number of open proxies"
    },
    "blocks": {
      "type": "integer",
      "description": "Number of open blocks"
    }
  },
  "additionalProperties": false,
  "required": [
    "userId",
    "hasOpenTransactions",
    "loans",
    "requests",
    "feesFines",
    "proxies",
    "blocks"
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /bl-users/by-id/{id}

Get a user by id

GET /bl-users/by-id/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • include: (array of string)

    indicates which referenced fields should be populated (de-referenced) by the service

  • expandPermissions: (boolean - default: false)

    Whether or not to expand permissions listings

Response 200

Body

Media type: application/json

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 403

Access denied

Body

Media type: text/plain

Type: any

Example:

Access denied

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User not found

Response 422

Unprocessable Entity

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",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /bl-users/by-id/{id}/open-transactions

Check if user has any open transactions, and if so, how many. Identify user by id

GET /bl-users/by-id/{id}/open-transactions
URI Parameters
  • id: required (string)

Response 200

Body

Media type: application/json

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User not found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /bl-users/by-username/{username}

Get a user by username

GET /bl-users/by-username/{username}
URI Parameters
  • username: required (string)
Query Parameters
  • include: (array of string)

    indicates which referenced fields should be populated (de-referenced) by the service

  • expandPermissions: (boolean - default: false)

    Whether or not to expand permissions listings

Response 200

Body

Media type: application/json

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 403

Access denied

Body

Media type: text/plain

Type: any

Example:

Access denied

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User not found

Response 422

Unprocessable Entity

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",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /bl-users/by-username/{username}/open-transactions

Check if user has any open transactions, and if so, how many. Identify user by username

GET /bl-users/by-username/{username}/open-transactions
URI Parameters
  • username: required (string)

Response 200

Body

Media type: application/json

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User not found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /bl-users/_self

Get a user by self reference

GET /bl-users/_self
Query Parameters
  • include: (array of string)

    indicates which referenced fields should be populated (de-referenced) by the service

  • expandPermissions: (boolean - default: false)

    Whether or not to expand permissions listings

Response 200

Body

Media type: application/json

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 403

Access denied

Body

Media type: text/plain

Type: any

Example:

Access denied

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User not found

Response 422

Unprocessable Entity

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",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /bl-users/login

Allow a new user to login and return an authtoken, along with a composite user record

POST /bl-users/login
Headers
  • User-Agent: required (string)
  • X-Forwarded-For: required (string)
Query Parameters
  • expandPermissions: (boolean - default: false)

    Whether or not to expand permissions listings

  • include: (array of string)

    indicates which referenced fields should be populated (de-referenced) by the service

Body

Media type: application/json

Response 201

Headers
  • x-okapi-token: required (string)
Body

Media type: application/json

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 422

Unprocessable Entity

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",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /bl-users/forgotten/password

called when a user has forgotten a password

POST /bl-users/forgotten/password
Body

Media type: application/json

Response 204

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 422

Unprocessable Entity

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",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /bl-users/forgotten/username

called when a user has forgotten a username

POST /bl-users/forgotten/username
Body

Media type: application/json

Response 204

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 422

Unprocessable Entity

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",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /bl-users/settings/myprofile/password

Allow change password for user

POST /bl-users/settings/myprofile/password
Headers
  • User-Agent: required (string)
  • X-Forwarded-For: required (string)
Body

Media type: application/json

Type: json

Content:

{
  "title": "Update Credentials Schema",
  "type": "object",
  "description": "An entity that describes the necessary data to update a user password",
  "properties": {
    "username": {
      "description": "username",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "password": {
      "description": "The current password of the user who will be replaced by the new one",
      "type": "string"
    },
    "newPassword": {
      "description": "New user password",
      "type": "string"
    }
  }
}

Response 204

Successful update

Body

Media type: text/plain

Type: any

Response 400

Bad request

Body

Media type: application/json

Response 401

Unauthorized

Body

Media type: text/plain

Type: any

Example:

Unauthorized

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /bl-users/password-reset/link

Generate and send password reset link

POST /bl-users/password-reset/link
Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "Request to generate and send reset password link",
  "properties": {
    "userId": {
      "type": "string",
      "description": "Id of user to whom a reset password link is sent"
    }
  },
  "required": [
    "userId"
  ]
}

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "Response for reset password link generation",
  "properties": {
    "link": {
      "type": "string",
      "description": "Link for resetting password"
    }
  },
  "additionalProperties": false
}

POST /bl-users/password-reset/reset

Reset password

POST /bl-users/password-reset/reset
Headers
  • User-Agent: required (string)
  • X-Forwarded-For: required (string)
Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Password reset entity",
  "type": "object",
  "properties": {
    "newPassword": {
      "description": "New password",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "required": [
    "newPassword"
  ]
}

Response 204

Successful password reset

Response 422

Unprocessable Entity

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /bl-users/password-reset/validate

POST /bl-users/password-reset/validate

Response 204

Successful link validation

Response 422

Unprocessable Entity

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error