| 1 | package Zenoss::Router::ZenPack; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | use Moose::Role; | ||
| 5 | requires '_router_request', '_check_args'; | ||
| 6 | |||
| 7 | #************************************************************************** | ||
| 8 | # Attributes | ||
| 9 | #************************************************************************** | ||
| 10 | has 'ZENPACK_LOCATION' => ( | ||
| 11 | is => 'ro', | ||
| 12 | isa => 'Str', | ||
| 13 | default => 'zport/dmd/zenpack_router', | ||
| 14 | init_arg => undef, | ||
| 15 | ); | ||
| 16 | |||
| 17 | has 'ZENPACK_ACTION' => ( | ||
| 18 | is => 'ro', | ||
| 19 | isa => 'Str', | ||
| 20 | default => 'ZenPackRouter', | ||
| 21 | init_arg => undef, | ||
| 22 | ); | ||
| 23 | |||
| 24 | #************************************************************************** | ||
| 25 | # Public Functions | ||
| 26 | #************************************************************************** | ||
| 27 | #====================================================================== | ||
| 28 | # zenpack_getEligiblePacks | ||
| 29 | #====================================================================== | ||
| 30 | sub zenpack_getEligiblePacks { | ||
| 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->ZENPACK_LOCATION, | ||
| 44 | action => $self->ZENPACK_ACTION, | ||
| 45 | method => 'getEligiblePacks', | ||
| 46 | data => [$args], | ||
| 47 | } | ||
| 48 | ); | ||
| 49 | } # END zenpack_getEligiblePacks | ||
| 50 | |||
| 51 | #====================================================================== | ||
| 52 | # zenpack_addToZenPack | ||
| 53 | #====================================================================== | ||
| 54 | sub zenpack_addToZenPack { | ||
| 55 | my ($self, $args) = @_; | ||
| 56 | $args = {} if !$args; | ||
| 57 | |||
| 58 | # Argument definition | ||
| 59 | my $definition = { | ||
| 60 | required => ['topack', 'zenpack'], | ||
| 61 | }; | ||
| 62 | |||
| 63 | # Check the args | ||
| 64 | $self->_check_args($args, $definition); | ||
| 65 | |||
| 66 | # Route the request | ||
| 67 | $self->_router_request( | ||
| 68 | { | ||
| 69 | location => $self->ZENPACK_LOCATION, | ||
| 70 | action => $self->ZENPACK_ACTION, | ||
| 71 | method => 'addToZenPack', | ||
| 72 | data => [$args], | ||
| 73 | } | ||
| 74 | ); | ||
| 75 | } # END zenpack_addToZenPack | ||
| 76 | |||
| 77 | #************************************************************************** | ||
| 78 | # Package end | ||
| 79 | #************************************************************************** | ||
| 80 | no Moose; | ||
| 81 | |||
| 82 | 1; | ||
| 83 | |||
| 84 | __END__ |