canarieapi.api

API definition.

This module defines the generic REST API for platforms and services as defined by the CANARIE API specification.

Module Contents

Functions

handle_exceptions(→ flask.typing.ResponseReturnValue)

Generate error response for raised exceptions.

home(→ flask.typing.ResponseReturnValue)

manual_test(→ flask.typing.ResponseReturnValue)

extern_html_error_handler(...)

Handle HTML errors from an external response.

information(→ flask.typing.ResponseReturnValue)

Info route required by CANARIE.

collect_monitoring_statuses(→ MonitorInfo)

Obtain all monitoring statuses for the requested service or platform.

collect_cron_access_stats(→ CronAccessStats)

Obtain access statuses of a service or platform from cron monitoring and logging jobs.

collect_cron_last_status(→ CronLastStatus)

Obtain the last time cron job have run (help to diagnose cron problem).

stats(→ flask.typing.ResponseReturnValue)

Stats route required by CANARIE.

status(→ flask.typing.ResponseReturnValue)

Extra route to know service status.

simple_requests_handler(→ flask.typing.ResponseReturnValue)

#Handle simple requests required by CANARIE.

close_connection(→ None)

Disconnect database.

Attributes

CronAccessStats

CronLastStatus

MonitorStatus

MonitorInfo

START_UTC_TIME

CANARIE_API_TYPE

CANARIE_API_VALID_REQUESTS

_required

HANDLED_HTML_ERRORS

HANDLED_HTML_ERRORS_STR

canarieapi.api.CronAccessStats[source]
canarieapi.api.CronLastStatus[source]
canarieapi.api.MonitorStatus[source]
canarieapi.api.MonitorInfo[source]
canarieapi.api.START_UTC_TIME[source]
canarieapi.api.CANARIE_API_TYPE = ['service', 'platform'][source]
canarieapi.api.CANARIE_API_VALID_REQUESTS[source]
canarieapi.api._required[source]
canarieapi.api.HANDLED_HTML_ERRORS = [400, 404, 405, 500, 503][source]
canarieapi.api.HANDLED_HTML_ERRORS_STR[source]
canarieapi.api.handle_exceptions(exception_instance: Exception) flask.typing.ResponseReturnValue[source]

Generate error response for raised exceptions.

Parameters:

exception_instance – Exception instance.

canarieapi.api.home() flask.typing.ResponseReturnValue[source]
canarieapi.api.manual_test() flask.typing.ResponseReturnValue[source]
canarieapi.api.extern_html_error_handler(status_code_str: str) flask.typing.ResponseReturnValue[source]

Handle HTML errors from an external response.

Handle errors that occur externally provided that Apache is configured so that it uses this route for handling errors.

For this add this line for each handled HTML errors in the Apache configuration:

ErrorDocument 400 <Rest root>/400
canarieapi.api.information(route_name: str, api_type: canarieapi.utility_rest.APIType) flask.typing.ResponseReturnValue[source]

Info route required by CANARIE.

canarieapi.api.collect_monitoring_statuses(route_name: str, *, database: sqlite3.Connection | None = None) MonitorInfo[source]

Obtain all monitoring statuses for the requested service or platform.

canarieapi.api.collect_cron_access_stats(route_name: str, *, database: sqlite3.Connection | None = None) CronAccessStats[source]

Obtain access statuses of a service or platform from cron monitoring and logging jobs.

canarieapi.api.collect_cron_last_status(*, database: sqlite3.Connection | None = None) CronLastStatus[source]

Obtain the last time cron job have run (help to diagnose cron problem).

canarieapi.api.stats(route_name: str, api_type: canarieapi.utility_rest.APIType) flask.typing.ResponseReturnValue[source]

Stats route required by CANARIE.

canarieapi.api.status(route_name: str, api_type: canarieapi.utility_rest.APIType) flask.typing.ResponseReturnValue[source]

Extra route to know service status.

canarieapi.api.simple_requests_handler(route_name: str, api_type: canarieapi.utility_rest.APIType, api_request: str = 'home') flask.typing.ResponseReturnValue[source]

#Handle simple requests required by CANARIE.

canarieapi.api.close_connection(_: Exception) None[source]

Disconnect database.

Parameters:

_ – Exception handled elsewhere, nothing to do with it