forked from IntelliHome/Google-at-Home
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebUI IntelliHome#7] Added RPC Ask service needed for WebUI interrog…
…ations
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |