Skip to content

Commit

Permalink
[WebUI IntelliHome#7] Added RPC Ask service needed for WebUI interrog…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
dgikiller committed Jul 26, 2014
1 parent 3b34b17 commit b708d3e
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions lib/IntelliHome/RPC/Service/Ask.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package IntelliHome::RPC::Service::Ask;

=head1 NAME
IntelliHome::RPC::Service::Ask - IntelliHome "ask" service for RPC server
=head1 DESCRIPTION
This object represent the "ask" service for the RPC server, it is available under C<rpcserver_ip:port/ask>
=head1 METHODS
IntelliHome::RPC::Service::Ask inherits all methods from L<IntelliHome::RPC::Service::Base> and implement the following new:
=over
=item gpio($tag)
Query the database backend, returning a list of GPIOs object (Schema dependant).
The C<$tag> must be a tagged gpio.
If C<$tag> is not given it returns all the elements.
=item nodes($query)
Query the database backend, returning a list of nodes object (Schema dependant).
The C<$query> must be an hashref of key => values that matches a gpio.
If C<$query> is not given it returns all the elements.
=back
=head1 ATTRIBUTES
IntelliHome::RPC::Service::Ask inherits all attributes from L<IntelliHome::RPC::Service::Base>
=head1 SEE ALSO
L<IntelliHome>, L<IntelliHome::Workers::Master::RPC> , L<MojoX::JSON::RPC::Service>
=cut

use Carp::Always;
use Mojo::Base 'IntelliHome::RPC::Service::Base';
has 'IntelliHome';

sub gpio {
my ( $self, $tx, $tag ) = @_;
return $self->IntelliHome->Parser->Backend->search_gpio( $tag ||= "." );
}

sub nodes {
my ( $self, $tx, $query ) = @_;
return $self->IntelliHome->Parser->Backend->getNodes($query);
}

__PACKAGE__->register_rpc_method_names( 'gpio', 'nodes' );

1;

0 comments on commit b708d3e

Please sign in to comment.