| 1 | package SSH::RPC::Result; | ||
| 2 | |||
| 3 | 2 | our $VERSION = 1.201; | |
| 4 | |||
| 5 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | ▶ | use Class::InsideOut qw(private id register); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | SSH::RPC::Result - Provides methods for the response from a SSH::RPC::Client run() method request. | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | This module is never used directly by you. Instead you'll ge a reference to this object as it's created by L<SSH::RPC::Client>. | ||
| 15 | |||
| 16 | =head1 METHODS | ||
| 17 | |||
| 18 | The following methods are accessible from this class. | ||
| 19 | |||
| 20 | =cut | ||
| 21 | |||
| 22 | 2 | private response => my %response; | |
| 23 | |||
| 24 | #------------------------------------------------------------------- | ||
| 25 | |||
| 26 | =head2 getError () | ||
| 27 | |||
| 28 | Returns the human readable error message (if any). | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | sub getError { | ||
| 33 | 2 | ▶ | my $self = shift; |
|
Subroutine
getError: called CC=1 SCAR=0.0
Pod
documented
| |||
| 34 | 2 | return $response{id $self}{error}; | |
| 35 | } | ||
| 36 | |||
| 37 | #------------------------------------------------------------------- | ||
| 38 | |||
| 39 | =head2 getResponse () | ||
| 40 | |||
| 41 | Returns the return value(s) from the RPC, whether that be a scalar value, or a hash reference or array reference. | ||
| 42 | |||
| 43 | =cut | ||
| 44 | |||
| 45 | sub getResponse { | ||
| 46 | 5 | ▶ | my $self = shift; |
|
Subroutine
getResponse: called CC=1 SCAR=0.0
Pod
documented
| |||
| 47 | 5 | return $response{id $self}{response}; | |
| 48 | } | ||
| 49 | |||
| 50 | #------------------------------------------------------------------- | ||
| 51 | |||
| 52 | =head2 getShellVersion () | ||
| 53 | |||
| 54 | Returns the $VERSION from the shell. This is useful if you have different versions of your shell running on different machines, and you need to do something differently to account for that. | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | sub getShellVersion { | ||
| 59 | 1 | ▶ | my $self = shift; |
|
Subroutine
getShellVersion: called CC=1 SCAR=0.0
Pod
documented
| |||
| 60 | 1 | return $response{id $self}{version}; | |
| 61 | } | ||
| 62 | |||
| 63 | #------------------------------------------------------------------- | ||
| 64 | |||
| 65 | =head2 getStatus () | ||
| 66 | |||
| 67 | Returns a status code for the RPC. The built in status codes are: | ||
| 68 | |||
| 69 | 200 - Success. | ||
| 70 | 400 - Malform request received by shell. | ||
| 71 | 405 - RPC called a method that doesn't exist. | ||
| 72 | 406 - Error transmitting RPC. | ||
| 73 | 408 - Connection error. | ||
| 74 | 500 - An undefined error occured in the shell. | ||
| 75 | 510 - Error translating return document in client. | ||
| 76 | 511 - Error translating return document in shell. | ||
| 77 | |||
| 78 | =cut | ||
| 79 | |||
| 80 | sub getStatus { | ||
| 81 | 4 | ▶ | my $self = shift; |
|
Subroutine
getStatus: called CC=1 SCAR=0.0
Pod
documented
| |||
| 82 | 4 | return $response{id $self}{status}; | |
| 83 | } | ||
| 84 | |||
| 85 | #------------------------------------------------------------------- | ||
| 86 | |||
| 87 | =head2 isSuccess () | ||
| 88 | |||
| 89 | Returns true if the request was successful, or false if it wasn't. | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | sub isSuccess { | ||
| 94 | 2 | ▶ | my $self = shift; |
|
Subroutine
isSuccess: called CC=1 SCAR=0.0
Pod
documented
| |||
| 95 | 2 | return ($self->getStatus == 200); | |
| 96 | } | ||
| 97 | |||
| 98 | #------------------------------------------------------------------- | ||
| 99 | |||
| 100 | =head2 new ( result ) | ||
| 101 | |||
| 102 | Constructor. | ||
| 103 | |||
| 104 | =head3 result | ||
| 105 | |||
| 106 | Result hash ref data structure generated by SSH::RPC::Client. | ||
| 107 | |||
| 108 | =cut | ||
| 109 | |||
| 110 | sub new { | ||
| 111 | 4 | ▶ | my ($class, $result) = @_; |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 112 | 4 | my $self = register($class); | |
| 113 | 4 | $response{id $self} = $result; | |
| 114 | 4 | return $self; | |
| 115 | } | ||
| 116 | |||
| 117 | =head1 PREREQS | ||
| 118 | |||
| 119 | This package requires the following modules: | ||
| 120 | |||
| 121 | L<Class::InsideOut> | ||
| 122 | |||
| 123 | =head1 AUTHOR | ||
| 124 | |||
| 125 | JT Smith <jt_at_plainblack_com> | ||
| 126 | |||
| 127 | =head1 LEGAL | ||
| 128 | |||
| 129 | ------------------------------------------------------------------- | ||
| 130 | SSH::RPC::Result is Copyright 2008-2009 Plain Black Corporation | ||
| 131 | and is licensed under the same terms as Perl itself. | ||
| 132 | ------------------------------------------------------------------- | ||
| 133 | http://www.plainblack.com info@plainblack.com | ||
| 134 | ------------------------------------------------------------------- | ||
| 135 | |||
| 136 | =cut | ||
| 137 | |||
| 138 | |||
| 139 | 2 | 1; | |
| 140 | |||