From 37a1996a9a6dcb31ed73dd282be4c894922bd366 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Mon, 5 Dec 2016 09:18:41 +0200 Subject: [PATCH] TT#5954 Readonly SoundGroups interface Change-Id: I06cdb731bbfea459a43344aa66c61735bd156f1a --- lib/NGCP/Panel/Controller/API/SoundGroups.pm | 32 +++++++++++++++++++ .../Panel/Controller/API/SoundGroupsItem.pm | 16 ++++++++++ lib/NGCP/Panel/Role/API/SoundGroups.pm | 27 ++++++++++++++++ t/api-rest/api-root.t | 1 + 4 files changed, 76 insertions(+) create mode 100644 lib/NGCP/Panel/Controller/API/SoundGroups.pm create mode 100644 lib/NGCP/Panel/Controller/API/SoundGroupsItem.pm create mode 100644 lib/NGCP/Panel/Role/API/SoundGroups.pm diff --git a/lib/NGCP/Panel/Controller/API/SoundGroups.pm b/lib/NGCP/Panel/Controller/API/SoundGroups.pm new file mode 100644 index 0000000000..3bc1b7950a --- /dev/null +++ b/lib/NGCP/Panel/Controller/API/SoundGroups.pm @@ -0,0 +1,32 @@ +package NGCP::Panel::Controller::API::SoundGroups; + + +use Sipwise::Base; +use parent qw/NGCP::Panel::Role::Entities NGCP::Panel::Role::API::SoundGroups/; + +use HTTP::Status qw(:constants); +use NGCP::Panel::Utils::Security; + +__PACKAGE__->set_config(); + +sub allowed_methods { + return [qw/GET OPTIONS HEAD/]; +} + +sub api_description { + return 'Defines sound handles groups.'; +} + +sub query_params { + return [ + { + param => 'name', + description => 'Filter for sound groups with a specific name', + query_type => 'string_like', + }, + ]; +} + +1; + +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Controller/API/SoundGroupsItem.pm b/lib/NGCP/Panel/Controller/API/SoundGroupsItem.pm new file mode 100644 index 0000000000..75830514ae --- /dev/null +++ b/lib/NGCP/Panel/Controller/API/SoundGroupsItem.pm @@ -0,0 +1,16 @@ +package NGCP::Panel::Controller::API::SoundGroupsItem; + +use Sipwise::Base; +use parent qw/NGCP::Panel::Role::EntitiesItem NGCP::Panel::Role::API::SoundGroups/; + +use HTTP::Status qw(:constants); + +__PACKAGE__->set_config(); + +sub allowed_methods{ + return [qw/GET OPTIONS HEAD/]; +} + +1; + +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Role/API/SoundGroups.pm b/lib/NGCP/Panel/Role/API/SoundGroups.pm new file mode 100644 index 0000000000..63f61a02ea --- /dev/null +++ b/lib/NGCP/Panel/Role/API/SoundGroups.pm @@ -0,0 +1,27 @@ +package NGCP::Panel::Role::API::SoundGroups; + +use Sipwise::Base; + +use parent qw/NGCP::Panel::Role::API/; + +use NGCP::Panel::Utils::Generic qw(:all); +use boolean qw(true); +use HTTP::Status qw(:constants); + +sub item_name { + return 'soundgroups'; +} + +sub resource_name{ + return 'soundgroups'; +} + +sub _item_rs { + my ($self, $c) = @_; + my $item_rs; + $item_rs = $c->model('DB')->resultset('voip_sound_groups'); + return $item_rs; +} + +1; +# vim: set tabstop=4 expandtab: diff --git a/t/api-rest/api-root.t b/t/api-rest/api-root.t index 1b1bc494fc..6e822dab8f 100644 --- a/t/api-rest/api-root.t +++ b/t/api-rest/api-root.t @@ -125,6 +125,7 @@ $ua->credentials($netloc, "api_admin_http", $user, $pass); sms => 1, soundfilerecordings => 1, soundfiles => 1, + soundgroups => 1, soundhandles => 1, soundsets => 1, speeddials => 1,