foliolib.folio.api.ermUsage.Counterreports

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

Bases: foliolib.folio.FolioApi

mod-erm-usage API

This documents the API calls that can be made to query and manage counter reports

Parameters
  • tenant (str) – Tenant id

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

Methods

delete_counterReport(counterReportsId)

Delete report identified by id

get_codes()

Get counter/sushi error codes existent in counter reports

get_counterReport(counterReportsId)

Get one report identified by id

get_counterReports(**kwargs)

Get all reports.

get_download_by_counterReport(counterReportsId)

Download report in its original format

get_export(exportId, **kwargs)

Get the report identified by id as specified format (default is CSV)

get_sorted(udpId)

Get counter reports sorted by year and report

get_to(providerId, name, aversion, begin, ...)

Get report for several months as specified format (default is CSV)

get_types()

Get report types of available counter reports

modify_counterReport(counterReportsId, ...)

Put report identified by id

set_counterReport(counterReport)

Post new report

set_delete(delete)

Delete multiple counter reports

set_provider(providerId, provider, **kwargs)

POST /counter-reports/upload/provider/{providerId}

delete_counterReport(counterReportsId: str)

Delete report identified by id

DELETE /counter-reports/{counterReportsId}

Parameters

counterReportsId (str) –

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

get_codes()

Get counter/sushi error codes existent in counter reports

GET /counter-reports/errors/codes

Returns

See Schema below

Return type

dict

Raises

OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "List of error codes existent in saved counter reports",
  "properties": {
    "errorCodes": {
      "description": "Error codes",
      "type": "array",
      "minItems": 0,
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "errorCodes"
  ]
}
get_counterReport(counterReportsId: str)

Get one report identified by id

GET /counter-reports/{counterReportsId}

Parameters

counterReportsId (str) –

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Counter Report and Metadata",
  "title": "Counter Report Schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "downloadTime": {
      "description": "Date and time the report was downloaded",
      "type": "string",
      "format": "date-time"
    },
    "failedAttempts": {
      "description": "Count of failed download attempts",
      "type": "integer"
    },
    "failedReason": {
      "description": "Error message from failed download attempt",
      "type": "string"
    },
    "release": {
      "description": "Counter Report version",
      "type": "string"
    },
    "reportName": {
      "description": "Counter Report name",
      "type": "string"
    },
    "yearMonth": {
      "description": "Counter Report period (one month)",
      "type": "string",
      "format": "date-month"
    },
    "providerId": {
      "description": "Provider identifier",
      "type": "string"
    },
    "report": {
      "description": "Actual counter report data",
      "type": "object"
    },
    "metadata": {
      "description": "Metadata about creation and changes, provided by the server (client should not provide)",
      "type": "object",
      "$ref": "../raml-util/schemas/metadata.schema",
      "readonly": true
    },
    "reportEditedManually": {
      "description": "Report data has been edited manually",
      "type": "boolean"
    },
    "editReason": {
      "description": "Edit reason",
      "type": "string"
    }
  },
  "required": [
    "downloadTime",
    "release",
    "reportName",
    "yearMonth"
  ],
  "additionalProperties": true
}
get_counterReports(**kwargs)

Get all reports. If query parameter tiny is set to true, the reports’ metadata is returned without the actual counter reports.

GET /counter-reports

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

    • yearMonth=”2018-03” and reportName=”JR1”

  • orderBy (str) – Order by field:

  • order (str (desc|asc) – ): (default=desc) Order

  • 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#",
  "description": "List of CounterReports",
  "type": "object",
  "properties": {
    "counterReports": {
      "type": "array",
      "description": "Entries",
      "id": "counterReportData",
      "items": {
        "type": "object",
        "$ref": "counterreport.json"
      }
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "counterReports",
    "totalRecords"
  ]
}
get_download_by_counterReport(counterReportsId: str)

Download report in its original format

GET /counter-reports/{counterReportsId}/download

Parameters

counterReportsId (str) –

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiFatalError – Server Error

get_export(exportId: str, **kwargs)

Get the report identified by id as specified format (default is CSV)

GET /counter-reports/export/{exportId}

Parameters
  • exportId (str) –

  • **kwargs (properties) – Keyword Arguments

Keyword Arguments

format (str) – (default=csv)

Raises
  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

get_sorted(udpId: str)

Get counter reports sorted by year and report

GET /counter-reports/sorted/{udpId}

Parameters

udpId (str) –

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "CounterReports sorted by year and report",
  "type": "object",
  "properties": {
    "counterReportsPerYear": {
      "type": "array",
      "description": "Counter reports grouped year",
      "id": "counterReportData",
      "items": {
        "type": "object",
        "properties": {
          "year": {
            "type": "integer",
            "description": "The current year"
          },
          "reportsPerType": {
            "type": "array",
            "description": "The reports of the current year",
            "items": {
              "type": "object",
              "properties": {
                "reportType": {
                  "type": "string",
                  "description": "The current report type"
                },
                "counterReports": {
                  "type": "array",
                  "description": "The reports of the current year and the current type",
                  "items": {
                    "type": "object",
                    "$ref": "counterreport.json"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
get_to(providerId: str, name: str, aversion: str, begin: str, end: str, **kwargs)

Get report for several months as specified format (default is CSV)

GET /counter-reports/export/provider/{providerId}/report/{name}/version/{aversion}/from/{begin}/to/{end}

Parameters
  • providerId (str) –

  • name (str) –

  • aversion (str) –

  • begin (str) –

  • end (str) –

  • **kwargs (properties) – Keyword Arguments

Keyword Arguments

format (str) – (default=csv)

Raises
  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

get_types()

Get report types of available counter reports

GET /counter-reports/reports/types

Returns

See Schema below

Return type

dict

Raises

OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "List of available counter report types",
  "properties": {
    "reportTypes": {
      "description": "Available report types",
      "type": "array",
      "minItems": 0,
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "reportTypes"
  ]
}
modify_counterReport(counterReportsId: str, counterReport: dict)

Put report identified by id

PUT /counter-reports/{counterReportsId}

Parameters
  • counterReportsId (str) –

  • counterReport (dict) – See Schema below

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Counter Report and Metadata",
  "title": "Counter Report Schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "downloadTime": {
      "description": "Date and time the report was downloaded",
      "type": "string",
      "format": "date-time"
    },
    "failedAttempts": {
      "description": "Count of failed download attempts",
      "type": "integer"
    },
    "failedReason": {
      "description": "Error message from failed download attempt",
      "type": "string"
    },
    "release": {
      "description": "Counter Report version",
      "type": "string"
    },
    "reportName": {
      "description": "Counter Report name",
      "type": "string"
    },
    "yearMonth": {
      "description": "Counter Report period (one month)",
      "type": "string",
      "format": "date-month"
    },
    "providerId": {
      "description": "Provider identifier",
      "type": "string"
    },
    "report": {
      "description": "Actual counter report data",
      "type": "object"
    },
    "metadata": {
      "description": "Metadata about creation and changes, provided by the server (client should not provide)",
      "type": "object",
      "$ref": "../raml-util/schemas/metadata.schema",
      "readonly": true
    },
    "reportEditedManually": {
      "description": "Report data has been edited manually",
      "type": "boolean"
    },
    "editReason": {
      "description": "Edit reason",
      "type": "string"
    }
  },
  "required": [
    "downloadTime",
    "release",
    "reportName",
    "yearMonth"
  ],
  "additionalProperties": true
}
set_counterReport(counterReport: dict)

Post new report

POST /counter-reports

Parameters

counterReport (dict) – See Schema below

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Headers

  • Location - URI to the created counterReport item

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Counter Report and Metadata",
  "title": "Counter Report Schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "downloadTime": {
      "description": "Date and time the report was downloaded",
      "type": "string",
      "format": "date-time"
    },
    "failedAttempts": {
      "description": "Count of failed download attempts",
      "type": "integer"
    },
    "failedReason": {
      "description": "Error message from failed download attempt",
      "type": "string"
    },
    "release": {
      "description": "Counter Report version",
      "type": "string"
    },
    "reportName": {
      "description": "Counter Report name",
      "type": "string"
    },
    "yearMonth": {
      "description": "Counter Report period (one month)",
      "type": "string",
      "format": "date-month"
    },
    "providerId": {
      "description": "Provider identifier",
      "type": "string"
    },
    "report": {
      "description": "Actual counter report data",
      "type": "object"
    },
    "metadata": {
      "description": "Metadata about creation and changes, provided by the server (client should not provide)",
      "type": "object",
      "$ref": "../raml-util/schemas/metadata.schema",
      "readonly": true
    },
    "reportEditedManually": {
      "description": "Report data has been edited manually",
      "type": "boolean"
    },
    "editReason": {
      "description": "Edit reason",
      "type": "string"
    }
  },
  "required": [
    "downloadTime",
    "release",
    "reportName",
    "yearMonth"
  ],
  "additionalProperties": true
}
set_delete(delete: dict)

Delete multiple counter reports

POST /counter-reports/reports/delete

Parameters

delete (dict) – See Schema below

Raises
  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

Schema

array
set_provider(providerId: str, provider: dict, **kwargs)

POST /counter-reports/upload/provider/{providerId}

Parameters
  • providerId (str) –

  • provider (dict) –

  • **kwargs (properties) – Keyword Arguments: See Schema below

Keyword Arguments

overwrite (bool) – (default=False) Overwrite existing reports?

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestNotFound – Not Found

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Document containing a base64 encoded counter report with additional metadata",
  "type": "object",
  "properties": {
    "reportMetadata": {
      "description": "Report metadata",
      "type": "object",
      "$ref": "report_metadata.json"
    },
    "contents": {
      "description": "Base64 encoded report file",
      "type": "object",
      "$ref": "report_data.json"
    }
  },
  "additionalProperties": false,
  "required": [
    "reportMetadata",
    "contents"
  ]
}