| 1 | package Zenoss::Router::Tree; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | use Moose::Role; | ||
| 5 | |||
| 6 | #************************************************************************** | ||
| 7 | # Public methods | ||
| 8 | #************************************************************************** | ||
| 9 | #====================================================================== | ||
| 10 | # addNode | ||
| 11 | #====================================================================== | ||
| 12 | sub addNode { | ||
| 13 | my ($self, $args, $router) = @_; | ||
| 14 | $args = {} if !$args; | ||
| 15 | |||
| 16 | # Get the router and action | ||
| 17 | my $LOCATION = uc($router) . '_LOCATION'; | ||
| 18 | my $ACTION = uc($router) . '_ACTION'; | ||
| 19 | |||
| 20 | # Argument definition | ||
| 21 | my $definition = { | ||
| 22 | required => ['type', 'contextUid', 'id'] | ||
| 23 | }; | ||
| 24 | |||
| 25 | # Check the args | ||
| 26 | $self->_check_args($args, $definition); | ||
| 27 | |||
| 28 | # Route the request | ||
| 29 | $self->_router_request( | ||
| 30 | { | ||
| 31 | location => $self->$LOCATION, | ||
| 32 | action => $self->$ACTION, | ||
| 33 | method => 'addNode', | ||
| 34 | data => [$args], | ||
| 35 | } | ||
| 36 | ); | ||
| 37 | } # END addNode | ||
| 38 | |||
| 39 | #====================================================================== | ||
| 40 | # deleteNode | ||
| 41 | #====================================================================== | ||
| 42 | sub deleteNode { | ||
| 43 | my ($self, $args, $router) = @_; | ||
| 44 | $args = {} if !$args; | ||
| 45 | |||
| 46 | # Get the router and action | ||
| 47 | my $LOCATION = uc($router) . '_LOCATION'; | ||
| 48 | my $ACTION = uc($router) . '_ACTION'; | ||
| 49 | |||
| 50 | # Argument definition | ||
| 51 | my $definition = { | ||
| 52 | required => ['uid'], | ||
| 53 | }; | ||
| 54 | |||
| 55 | # Check the args | ||
| 56 | $self->_check_args($args, $definition); | ||
| 57 | |||
| 58 | # Route the request | ||
| 59 | $self->_router_request( | ||
| 60 | { | ||
| 61 | location => $self->$LOCATION, | ||
| 62 | action => $self->$ACTION, | ||
| 63 | method => 'deleteNode', | ||
| 64 | data => [$args], | ||
| 65 | } | ||
| 66 | ); | ||
| 67 | } # END deleteNode | ||
| 68 | |||
| 69 | #====================================================================== | ||
| 70 | # moveOrganizer | ||
| 71 | #====================================================================== | ||
| 72 | sub moveOrganizer { | ||
| 73 | my ($self, $args, $router) = @_; | ||
| 74 | $args = {} if !$args; | ||
| 75 | |||
| 76 | # Get the router and action | ||
| 77 | my $LOCATION = uc($router) . '_LOCATION'; | ||
| 78 | my $ACTION = uc($router) . '_ACTION'; | ||
| 79 | |||
| 80 | # Argument definition | ||
| 81 | my $definition = { | ||
| 82 | required => ['uid'], | ||
| 83 | }; | ||
| 84 | |||
| 85 | # Check the args | ||
| 86 | $self->_check_args($args, $definition); | ||
| 87 | |||
| 88 | # Route the request | ||
| 89 | $self->_router_request( | ||
| 90 | { | ||
| 91 | location => $self->$LOCATION, | ||
| 92 | action => $self->$ACTION, | ||
| 93 | method => 'moveOrganizer', | ||
| 94 | data => [$args], | ||
| 95 | } | ||
| 96 | ); | ||
| 97 | } # END moveOrganizer | ||
| 98 | |||
| 99 | #************************************************************************** | ||
| 100 | # Package end | ||
| 101 | #************************************************************************** | ||
| 102 | no Moose; | ||
| 103 | |||
| 104 | 1; | ||
| 105 | |||
| 106 | __END__ |