Sample-Module (v1)

http://github.com/org/folio/sample-module

Table of contents

Sample Module

CRUD API

/eresource

Collection of eresource items.

GET /eresource

Get list of eresources

GET /eresource
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.

    with valid searchable fields: for example code

    Example:

    (username=="ab*" or personal.firstName=="ab*" or personal.lastName=="ab*") and active=="true" sortby personal.lastName personal.firstName barcode
    
    ["code", "MEDGRANT", "="]
    
  • 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 eresource items

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "collection of eresource records",
  "type": "object",
  "properties": {
    "eresources": {
      "description": "collection of eresource records",
      "type": "array",
      "id": "eresources",
      "items": {
        "type": "object",
        "$ref": "eresource.json"
      }
    },
    "total_records": {
      "description": "The number of objects contained in this collection",
      "type": "integer"
    },
    "first": {
      "description": "The index of the first object contained in this collection",
      "type": "integer"
    },
    "last": {
      "description": "The index of the last object contained in this collection",
      "type": "integer"
    }
  },
  "additionalProperties": false,
  "required": [
    "eresources",
    "total_records"
  ]
}

Example:

{
    "eresources":
        [
          {
            "id": "468b679c-378b-4009-9a17-a6711cefc85f",
            "access_provider": "ba3f3d45-247d-41f6-8dc9-6488adcad329",
            "activated": false,
            "activation_due": 10,
            "create_inventory": true,
            "expected_activation": "2018-10-09T00:00:00.000Z",
            "license": "7c063655-b384-4a6f-b367-3c2f95f7a49c",
            "trial": false,
            "user_limit": 10,
            "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
          }
        ],
    "total_records": 1,
    "first": 1,
    "last": 1
}

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 eresource -- 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 eresource -- 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 /eresource

Create a new eresource item.

POST /eresource
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#",
  "description": "purchase order line e-resource details",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this eresource record",
      "type": "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}$"
    },
    "activated": {
      "description": "whether or not this resource is activated",
      "type": "boolean"
    },
    "activation_due": {
      "description": "number of days until activation, from date of order placement",
      "type": "integer"
    },
    "create_inventory": {
      "description": "whether or not to create an inventory record for this resource",
      "type": "boolean"
    },
    "trial": {
      "description": "whether or not this is a trial",
      "type": "boolean"
    },
    "expected_activation": {
      "description": "expected date the resource will be activated",
      "type": "string",
      "format": "date-time"
    },
    "user_limit": {
      "description": "the concurrent user-limit",
      "type": "integer"
    },
    "access_provider": {
      "description": "UUID of the access provider",
      "type": "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}$"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this record is associated with",
      "type": "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}$"
    },
    "license": {
      "description": "UUID of the license record",
      "type": "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}$"
    }
  },
  "additionalProperties": false
}

Example:

{
  "id": "468b679c-378b-4009-9a17-a6711cefc85f",
  "access_provider": "ba3f3d45-247d-41f6-8dc9-6488adcad329",
  "activated": false,
  "activation_due": 10,
  "create_inventory": true,
  "expected_activation": "2018-10-09T00:00:00.000Z",
  "license": "7c063655-b384-4a6f-b367-3c2f95f7a49c",
  "trial": false,
  "user_limit": 10,
  "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
}

Response 201

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

Headers
  • Location: required (string)

    URI to the created eresource item

Body

Media type: application/json

Type: any

Example:

{
  "id": "468b679c-378b-4009-9a17-a6711cefc85f",
  "access_provider": "ba3f3d45-247d-41f6-8dc9-6488adcad329",
  "activated": false,
  "activation_due": 10,
  "create_inventory": true,
  "expected_activation": "2018-10-09T00:00:00.000Z",
  "license": "7c063655-b384-4a6f-b367-3c2f95f7a49c",
  "trial": false,
  "user_limit": 10,
  "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
}

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 eresource -- malformed JSON at 13:3"

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to create eresource -- unauthorized

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /eresource/{id}

Retrieve eresource item with given {eresourceId}

GET /eresource/{id}
URI Parameters
  • id: required (string)
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#",
  "description": "purchase order line e-resource details",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this eresource record",
      "type": "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}$"
    },
    "activated": {
      "description": "whether or not this resource is activated",
      "type": "boolean"
    },
    "activation_due": {
      "description": "number of days until activation, from date of order placement",
      "type": "integer"
    },
    "create_inventory": {
      "description": "whether or not to create an inventory record for this resource",
      "type": "boolean"
    },
    "trial": {
      "description": "whether or not this is a trial",
      "type": "boolean"
    },
    "expected_activation": {
      "description": "expected date the resource will be activated",
      "type": "string",
      "format": "date-time"
    },
    "user_limit": {
      "description": "the concurrent user-limit",
      "type": "integer"
    },
    "access_provider": {
      "description": "UUID of the access provider",
      "type": "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}$"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this record is associated with",
      "type": "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}$"
    },
    "license": {
      "description": "UUID of the license record",
      "type": "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}$"
    }
  },
  "additionalProperties": false
}

Example:

{
  "access_provider": "ba3f3d45-247d-41f6-8dc9-6488adcad329",
  "activated": false,
  "activation_due": 10,
  "create_inventory": true,
  "expected_activation": "2018-10-09T00:00:00.000Z",
  "license": "7c063655-b384-4a6f-b367-3c2f95f7a49c",
  "trial": false,
  "user_limit": 10,
  "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
}

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"eresource 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 /eresource/{id}

Delete eresource item with given {eresourceId}

DELETE /eresource/{id}
URI Parameters
  • id: required (string)
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 eresource -- constraint violation"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"eresource 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

PUT /eresource/{id}

Update eresource item with given {eresourceId}

PUT /eresource/{id}
URI Parameters
  • id: required (string)
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#",
  "description": "purchase order line e-resource details",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this eresource record",
      "type": "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}$"
    },
    "activated": {
      "description": "whether or not this resource is activated",
      "type": "boolean"
    },
    "activation_due": {
      "description": "number of days until activation, from date of order placement",
      "type": "integer"
    },
    "create_inventory": {
      "description": "whether or not to create an inventory record for this resource",
      "type": "boolean"
    },
    "trial": {
      "description": "whether or not this is a trial",
      "type": "boolean"
    },
    "expected_activation": {
      "description": "expected date the resource will be activated",
      "type": "string",
      "format": "date-time"
    },
    "user_limit": {
      "description": "the concurrent user-limit",
      "type": "integer"
    },
    "access_provider": {
      "description": "UUID of the access provider",
      "type": "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}$"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this record is associated with",
      "type": "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}$"
    },
    "license": {
      "description": "UUID of the license record",
      "type": "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}$"
    }
  },
  "additionalProperties": false
}

Example:

{
  "access_provider": "ba3f3d45-247d-41f6-8dc9-6488adcad329",
  "activated": false,
  "activation_due": 10,
  "create_inventory": true,
  "expected_activation": "2018-10-09T00:00:00.000Z",
  "license": "7c063655-b384-4a6f-b367-3c2f95f7a49c",
  "trial": false,
  "user_limit": 10,
  "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
}

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 eresource -- malformed JSON at 13:4"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"eresource 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