NAME

App::Dochazka::REST::Dispatch - Implementation of top-level resources

DESCRIPTION

This module contains the init_router method as well as all the resource handlers referred to in the resource definitions.

PACKAGE VARIABLES

This module uses some package variables, which are essentially constants, to do its work.

FUNCTIONS

init

This function is called by bin/mrest.

init_router

The "router" (i.e., Path::Router instance) is initialized when the first request comes in, as a first step before any processing of the request takes place.

This happens when Web::MREST::Resource calls the init_router method.

App::Dochazka::REST implements its own init_router method, overriding the default one in Web::MREST::InitRouter.

Top-level handlers

These are largely (but not entirely) copy-pasted from Web::MREST::Dispatch.

handler_bugreport

Handler for the bugreport resource.

handler_configinfo

Handler for the configinfo resource.

handler_dbstatus

Handler for the dbstatus resource.

handler_docu

The definition of resource $docu_resource lacks a 'documentation' property EOH # if they want POD, give them POD; if they want HTML, give them HTML, etc. if ( $resource_name eq 'docu/pod' ) { $pl->{'format'} = 'POD'; $pl->{'documentation'} = $docs; } elsif ( $resource_name eq 'docu/html' ) { $pl->{'format'} = 'HTML'; $pl->{'documentation'} = pod_to_html( $docs ); } else { # fall back to plain text $pl->{'format'} = 'text'; $pl->{'documentation'} = pod_to_text( $docs ); } return $CELL->status_ok( 'DISPATCH_ONLINE_DOCUMENTATION', payload => $pl ); }

handler_echo

Echo request body back in the response

handler_forbidden

Handler for 'forbidden' resource.

handler_holiday_tsrange

Handler for 'holiday/:tsrange' resource.

handler_param

Handler for 'param/:type/:param' resource.

handler_noop

Generalized handler for resources that don't do anything.

Handler for the session resource.

handler_version

Handler for the version resource.

Activity handlers

handler_get_activity_all

Handler for 'GET activity/all'

handler_get_activity_all_disabled

Handler for 'GET activity/all/disabled'

handler_post_activity_aid

Handler for 'POST activity/aid' resource.

handler_post_activity_code

Handler for 'POST activity/code' resource. This is a little more complicated because it can be either create or modify.

handler_activity_aid

Handler for the 'activity/aid/:aid' resource.

handler_get_activity_code

Handler for the 'GET activity/code/:code' resource.

handler_delete_activity_code

Handler for the 'DELETE activity/code/:code' resource.

handler_put_activity_code

Handler for the 'PUT activity/code/:code' resource.

Component handlers

handler_get_component_all

Handler for 'GET component/all'

handler_post_component_cid

Handler for 'POST component/cid' resource.

handler_post_component_path

Handler for 'POST component/path' resource. This is a little more complicated because it can be either create or modify.

handler_component_cid

Handler for the 'component/cid/:cid' resource.

Employee handlers

handler_get_employee_count

Handler for 'GET employee/count/?:priv' resource.

handler_get_employee_list

Handler for 'GET employee/list/?:priv' resource.

handler_get_employee_team

Handler for 'GET employee/team' resource.

handler_whoami

Handler for GET requests on the 'whoami', 'employee/current', and 'employee/self' resources (which are all synonyms).

_handler_get_employee_full_pass2

handler_get_employee_self_full

Handler for GET requests on 'employee/self/full'

handler_get_employee_eid_full

Handler for GET requests on 'employee/eid/:eid/full'

handler_get_employee_nick_full

Handler for GET requests on 'employee/nick/:nick/full'

handler_put_employee_eid

Handler for 'PUT employee/eid/:eid' - can only be update.

handler_post_employee_eid

Handler for 'POST employee/eid' - can only be update.

handler_put_employee_nick

Handler for 'PUT employee/nick/:nick' - a little complicated because it can be insert or update, depending on whether or not the employee exists.

handler_post_employee_nick

Handler for 'POST employee/nick' - a little complicated because it can be insert or update, depending on whether or not the employee exists.

handler_post_employee_self

Handler for 'POST employee/{current,self}' resources. The request entity is supposed to contain a list of key:value pairs where the keys are properties of the employee object and the values are new values for those properties, e.g.:

{ 
    "fullname" : "Bubba Jones",
    "nick" : "bubba"
}

Note that it should be possible to set a property to null:

{ "fullname" : null }

The JSON will be converted into a Perl hashref, of course, and that will be handed off to the DBI for insertion into placeholders in an UPDATE statement.

handler_delete_employee_eid

Handler for 'DELETE employee/eid/:eid' resource.

handler_get_employee_eid

Handler for 'GET employee/eid/:eid'

_check_ldap

handler_get_employee_ldap

Handler for 'GET employee/nick/:nick/ldap' resource.

handler_put_employee_ldap

Handler for 'PUT employee/nick/:nick/ldap' resource.

handler_get_employee_minimal

Handler for 'GET employee/eid/:eid/minimal' resource. Handler for 'GET employee/nick/:nick/minimal' resource. Handler for 'GET employee/sec_id/:sec_id/minimal' resource.

handler_get_employee_eid_team

Handler for 'GET employee/eid/:eid/team'

handler_get_employee_nick_team

Handler for 'GET employee/nick/:nick/team'

handler_delete_employee_nick

Handler for 'DELETE employee/nick/:nick'

handler_get_employee_nick

Handler for 'GET employee/nick/:nick'

handler_get_employee_sec_id

Handler for 'GET employee/sec_id/:sec_id'

handler_get_employee_search_nick

Handler for 'GET employee/search/nick/:key'

Genreport handlers

handler_genreport

Handler for the 'POST genreport' resource.

History handlers

handler_history_self

Handler method for the '{priv,schedule}/history/self/?:tsrange' resource.

handler_history_get_single

Handler method for GET requests on the '/{priv,schedule}/history/eid/..' and '/{priv,schedule}/history/nick/..' resources (potentially returning a single record).

handler_history_get_multiple

Handler method for GET requests on the '/{priv,schedule}/history/eid/..' and '/{priv,schedule}/history/nick/..' resources (all potentially returning multiple records).

handler_history_post

Handler method for POST requests on the '/{priv,schedule}/history/eid/..' and '/{priv,schedule}/history/nick/..' resources.

handler_history_get_phid

Handler for 'GET priv/history/phid/:phid'

handler_history_post_phid

Handler for 'POST priv/history/phid/:phid'

handler_history_delete_phid

handler_history_get_shid

Handler for 'GET schedule/history/shid/:shid'

handler_history_post_shid

Handler for 'POST priv/history/shid/:shid'

handler_history_delete_shid

Interval handlers

handler_interval_eid

Handler for

GET interval/eid/:eid/:tsrange
DELETE interval/eid/:eid/:tsrange

#FIXME: implement a configurable limit on the tsrange

handler_get_lock_eid

Handler for 'GET lock/eid/:eid/:tsrange'

#FIXME: implement a configurable limit on the tsrange

handler_interval_nick

Handler for

GET interval/nick/:nick/:tsrange
DELETE interval/nick/:nick/:tsrange

#FIXME: implement a configurable limit on the tsrange

handler_get_lock_nick

Handler for 'GET lock/nick/:nick/:tsrange'

#FIXME: implement a configurable limit on the tsrange

handler_interval_self

Handler for

GET interval/self/:tsrange
DELETE interval/self/:tsrange

#FIXME: implement a configurable limit on the tsrange

handler_get_lock_self

Handler for 'GET lock/self/:tsrange'

#FIXME: implement a configurable limit on the tsrange

handler_interval_new

Handler for 'POST interval/new'

handler_post_interval_iid

Handler for 'POST interval/iid'.

handler_get_interval_iid

Handler for 'GET interval/iid/:iid' resource.

handler_interval_iid

Handler for 'interval/iid/:iid' resource.

handler_get_interval_summary

Handler for "GET interval/summary/eid/:eid/:tsrange"

Lock handlers

handler_lock_new

Handler for 'POST lock/new'

handler_post_lock_lid

Handler for 'POST lock/lid'.

handler_get_lock_lid

Handler for 'GET lock/lid/:lid' resource.

handler_lock_lid

Handler for 'lock/lid/:lid' resource.

Priv handlers

handler_priv_get_eid

handler_priv_get_nick

handler_priv_get_self

Schedule handlers

schedule_all

Works for both 'GET schedule/all' and 'GET schedule/all/disabled'

handler_get_schedule_eid

handler_fillup

Handler for POST interval/fillup. For a description of what we're trying to do, see https://github.com/smithfarm/dochazka-rest/issues/60

handler_get_schedule_nick

handler_get_schedule_self

handler_schedule_new

Handler for the 'schedule/new' resource.

handler_get_schedule_sid

Handler for '/schedule/sid/:sid'

handler_put_schedule_sid

Handler for 'PUT schedule/sid/:sid'

handler_delete_schedule_sid

Handler for '/schedule/sid/:sid'

handler_get_schedule_scode

Handler for '/schedule/scode/:scode'

handler_put_schedule_scode

Handler for 'PUT schedule/scode/:scode'

handler_delete_schedule_scode

Handler for '/schedule/scode/:scode'

Helper functions

_first_pass_always_exists

Boilerplate code for use in handlers of resources that always exist

_tsrange_from_context

Given a mapping containing either a tsrange property or, alternatively, a pair of properties ts and psqlint (i.e. a timestamp and a PostgreSQL interval), return a status object that, if the delta add operation is successful, will contain a proper timestamp.