| 1 | package Zenoss::Router::Report; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | use Moose::Role; | ||
| 5 | requires '_router_request', '_check_args'; | ||
| 6 | |||
| 7 | #************************************************************************** | ||
| 8 | # Attributes | ||
| 9 | #************************************************************************** | ||
| 10 | has 'REPORT_LOCATION' => ( | ||
| 11 | is => 'ro', | ||
| 12 | isa => 'Str', | ||
| 13 | default => 'zport/dmd/report_router', | ||
| 14 | init_arg => undef, | ||
| 15 | ); | ||
| 16 | |||
| 17 | has 'REPORT_ACTION' => ( | ||
| 18 | is => 'ro', | ||
| 19 | isa => 'Str', | ||
| 20 | default => 'ReportRouter', | ||
| 21 | init_arg => undef, | ||
| 22 | ); | ||
| 23 | |||
| 24 | #************************************************************************** | ||
| 25 | # Public Functions | ||
| 26 | #************************************************************************** | ||
| 27 | #====================================================================== | ||
| 28 | # report_getReportTypes | ||
| 29 | #====================================================================== | ||
| 30 | sub report_getReportTypes { | ||
| 31 | my ($self, $args) = @_; | ||
| 32 | $args = {} if !$args; | ||
| 33 | |||
| 34 | # Argument definition | ||
| 35 | my $definition = {}; | ||
| 36 | |||
| 37 | # Check the args | ||
| 38 | $self->_check_args($args, $definition); | ||
| 39 | |||
| 40 | # Route the request | ||
| 41 | $self->_router_request( | ||
| 42 | { | ||
| 43 | location => $self->REPORT_LOCATION, | ||
| 44 | action => $self->REPORT_ACTION, | ||
| 45 | method => 'getReportTypes', | ||
| 46 | data => [$args], | ||
| 47 | } | ||
| 48 | ); | ||
| 49 | } # END report_getReportTypes | ||
| 50 | |||
| 51 | #====================================================================== | ||
| 52 | # report_getTree | ||
| 53 | #====================================================================== | ||
| 54 | sub report_getTree { | ||
| 55 | my ($self, $args) = @_; | ||
| 56 | $args = {} if !$args; | ||
| 57 | |||
| 58 | # Argument definition | ||
| 59 | my $definition = { | ||
| 60 | defaults => { | ||
| 61 | id => '/zport/dmd/Reports', | ||
| 62 | }, | ||
| 63 | }; | ||
| 64 | |||
| 65 | # Check the args | ||
| 66 | $self->_check_args($args, $definition); | ||
| 67 | |||
| 68 | # Route the request | ||
| 69 | $self->_router_request( | ||
| 70 | { | ||
| 71 | location => $self->REPORT_LOCATION, | ||
| 72 | action => $self->REPORT_ACTION, | ||
| 73 | method => 'getTree', | ||
| 74 | data => [$args], | ||
| 75 | } | ||
| 76 | ); | ||
| 77 | } # END report_getTree | ||
| 78 | |||
| 79 | #====================================================================== | ||
| 80 | # report_addNode | ||
| 81 | #====================================================================== | ||
| 82 | sub report_addNode { | ||
| 83 | my ($self, $args) = @_; | ||
| 84 | $args = {} if !$args; | ||
| 85 | |||
| 86 | # Argument definition | ||
| 87 | my $definition = { | ||
| 88 | required => ['nodeType', 'contextUid', 'id'], | ||
| 89 | }; | ||
| 90 | |||
| 91 | # Check the args | ||
| 92 | $self->_check_args($args, $definition); | ||
| 93 | |||
| 94 | # Route the request | ||
| 95 | $self->_router_request( | ||
| 96 | { | ||
| 97 | location => $self->REPORT_LOCATION, | ||
| 98 | action => $self->REPORT_ACTION, | ||
| 99 | method => 'addNode', | ||
| 100 | data => [$args], | ||
| 101 | } | ||
| 102 | ); | ||
| 103 | } # END report_addNode | ||
| 104 | |||
| 105 | #====================================================================== | ||
| 106 | # report_deleteNode | ||
| 107 | #====================================================================== | ||
| 108 | sub report_deleteNode { | ||
| 109 | my ($self, $args) = @_; | ||
| 110 | $args = {} if !$args; | ||
| 111 | |||
| 112 | # Argument definition | ||
| 113 | my $definition = { | ||
| 114 | required => ['uid'], | ||
| 115 | }; | ||
| 116 | |||
| 117 | # Check the args | ||
| 118 | $self->_check_args($args, $definition); | ||
| 119 | |||
| 120 | # Route the request | ||
| 121 | $self->_router_request( | ||
| 122 | { | ||
| 123 | location => $self->REPORT_LOCATION, | ||
| 124 | action => $self->REPORT_ACTION, | ||
| 125 | method => 'deleteNode', | ||
| 126 | data => [$args], | ||
| 127 | } | ||
| 128 | ); | ||
| 129 | } # END report_deleteNode | ||
| 130 | |||
| 131 | #====================================================================== | ||
| 132 | # report_moveNode | ||
| 133 | #====================================================================== | ||
| 134 | sub report_moveNode { | ||
| 135 | my ($self, $args) = @_; | ||
| 136 | $args = {} if !$args; | ||
| 137 | |||
| 138 | # Argument definition | ||
| 139 | my $definition = { | ||
| 140 | required => ['uids', 'target'], | ||
| 141 | }; | ||
| 142 | |||
| 143 | # Check the args | ||
| 144 | $self->_check_args($args, $definition); | ||
| 145 | |||
| 146 | # Route the request | ||
| 147 | $self->_router_request( | ||
| 148 | { | ||
| 149 | location => $self->REPORT_LOCATION, | ||
| 150 | action => $self->REPORT_ACTION, | ||
| 151 | method => 'moveNode', | ||
| 152 | data => [$args], | ||
| 153 | } | ||
| 154 | ); | ||
| 155 | } # END report_moveNode | ||
| 156 | |||
| 157 | #************************************************************************** | ||
| 158 | # Package end | ||
| 159 | #************************************************************************** | ||
| 160 | no Moose; | ||
| 161 | |||
| 162 | 1; | ||
| 163 | |||
| 164 | __END__ |