diff --git a/lib/NGCP/Panel/Controller/API/BillingProfiles.pm b/lib/NGCP/Panel/Controller/API/BillingProfiles.pm index e94ebfeb9d..8ec94b1eba 100644 --- a/lib/NGCP/Panel/Controller/API/BillingProfiles.pm +++ b/lib/NGCP/Panel/Controller/API/BillingProfiles.pm @@ -22,6 +22,24 @@ class_has 'api_description' => ( 'Defines a collection of <a href="#billingfees">Billing Fees</a> and <a href="#billingzones">Billing Zones</a> and can be assigned to <a href="#customers">Customers</a> and <a href="#contracts">System Contracts</a>.' ); +class_has 'query_params' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub {[ + { + param => 'reseller_id', + description => 'Filter for billing profiles belonging to a specific reseller', + query => { + first => sub { + my $q = shift; + { reseller_id => $q }; + }, + second => sub {}, + }, + }, + ]}, +); + with 'NGCP::Panel::Role::API::BillingProfiles'; class_has('resource_name', is => 'ro', default => 'billingprofiles'); diff --git a/lib/NGCP/Panel/Controller/API/Contracts.pm b/lib/NGCP/Panel/Controller/API/Contracts.pm index ccacc96313..416c4bdb14 100644 --- a/lib/NGCP/Panel/Controller/API/Contracts.pm +++ b/lib/NGCP/Panel/Controller/API/Contracts.pm @@ -23,6 +23,35 @@ class_has 'api_description' => ( 'Defines a billing container for peerings and resellers. A <a href="#billingprofiles">Billing Profile</a> is assigned to a contract, and it has <a href="#contractbalances">Contract Balances</a> indicating the saldo of the contract for current and past billing intervals.' ); +class_has 'query_params' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub {[ + { + param => 'contact_id', + description => 'Filter for contracts with a specific contact id', + query => { + first => sub { + my $q = shift; + { contact_id => $q }; + }, + second => sub {}, + }, + }, + { + param => 'status', + description => 'Filter for contracts with a specific status (except "terminated")', + query => { + first => sub { + my $q = shift; + { status => $q }; + }, + second => sub {}, + }, + }, + ]}, +); + with 'NGCP::Panel::Role::API::Contracts'; class_has('resource_name', is => 'ro', default => 'contracts'); diff --git a/lib/NGCP/Panel/Controller/API/CustomerContacts.pm b/lib/NGCP/Panel/Controller/API/CustomerContacts.pm index 6ddbaaff4f..9a8fd40b08 100644 --- a/lib/NGCP/Panel/Controller/API/CustomerContacts.pm +++ b/lib/NGCP/Panel/Controller/API/CustomerContacts.pm @@ -23,6 +23,35 @@ class_has 'api_description' => ( 'Defines a physical or legal person\'s address (postal and/or email) to be used to identify <a href="#customers">Customers</a>.' ); +class_has 'query_params' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub {[ + { + param => 'email', + description => 'Filter for contacts matching an email pattern', + query => { + first => sub { + my $q = shift; + { email => { like => $q } }; + }, + second => sub {}, + }, + }, + { + param => 'reseller_id', + description => 'Filter for contacts belonging to a specific reseller', + query => { + first => sub { + my $q = shift; + { reseller_id => $q }; + }, + second => sub {}, + }, + }, + ]}, +); + with 'NGCP::Panel::Role::API::CustomerContacts'; class_has('resource_name', is => 'ro', default => 'customercontacts'); diff --git a/lib/NGCP/Panel/Controller/API/Customers.pm b/lib/NGCP/Panel/Controller/API/Customers.pm index f774f58385..4b4efaeb03 100644 --- a/lib/NGCP/Panel/Controller/API/Customers.pm +++ b/lib/NGCP/Panel/Controller/API/Customers.pm @@ -23,6 +23,37 @@ class_has 'api_description' => ( 'Defines a billing container for end customers. Customers usually have one or more <a href="#subscribers">Subscribers</a>. A <a href="#billingprofiles">Billing Profile</a> is assigned to a customer, and it has <a href="#contractbalances">Contract Balances</a> indicating the saldo of the customer for current and past billing intervals.' ); +class_has 'query_params' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub {[ + { + param => 'reseller_id', + description => 'Filter for customers belonging to a specific reseller', + query => { + first => sub { + my $q = shift; + { 'contact.reseller_id' => $q }; + }, + second => sub { + { join => 'contact' }; + }, + }, + }, + { + param => 'contact_id', + description => 'Filter for customers belonging to a specific contact', + query => { + first => sub { + my $q = shift; + { contact_id => $q }; + }, + second => sub { }, + }, + }, + ]}, +); + with 'NGCP::Panel::Role::API::Customers'; class_has('resource_name', is => 'ro', default => 'customers'); diff --git a/lib/NGCP/Panel/Controller/API/Domains.pm b/lib/NGCP/Panel/Controller/API/Domains.pm index 2474ebc189..dca1357222 100644 --- a/lib/NGCP/Panel/Controller/API/Domains.pm +++ b/lib/NGCP/Panel/Controller/API/Domains.pm @@ -23,6 +23,37 @@ class_has 'api_description' => ( 'Specifies a SIP Domain to be used as host part for SIP <a href="#subscribers">Subscribers</a>. You need a domain before you can create a subscriber. Multiple domains can be created. A domain could also be an IPv4 or IPv6 address (whereas the latter needs to be enclosed in square brackets, e.g. [::1]).' ); +class_has 'query_params' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub {[ + { + param => 'reseller_id', + description => 'Filter for domains belonging to a specific reseller', + query => { + first => sub { + my $q = shift; + { 'domain_resellers.reseller_id' => $q }; + }, + second => sub { + { join => 'domain_resellers' }; + }, + }, + }, + { + param => 'domain', + description => 'Filter for domains matching the given pattern', + query => { + first => sub { + my $q = shift; + { domain => { like => $q } }; + }, + second => sub { }, + }, + }, + ]}, +); + with 'NGCP::Panel::Role::API::Domains'; class_has('resource_name', is => 'ro', default => 'domains'); diff --git a/lib/NGCP/Panel/Controller/API/Resellers.pm b/lib/NGCP/Panel/Controller/API/Resellers.pm index 4026684afe..e412bc36cc 100644 --- a/lib/NGCP/Panel/Controller/API/Resellers.pm +++ b/lib/NGCP/Panel/Controller/API/Resellers.pm @@ -22,6 +22,24 @@ class_has 'api_description' => ( 'Defines a reseller on the system. A reseller can manage his own <a href="#domains">Domains</a> and <a href="#customers">Customers</a>.' ); +class_has 'query_params' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub {[ + { + param => 'name', + description => 'Filter for resellers matching the given name pattern', + query => { + first => sub { + my $q = shift; + { name => { like => $q } }; + }, + second => sub {}, + }, + }, + ]}, +); + with 'NGCP::Panel::Role::API::Resellers'; class_has('resource_name', is => 'ro', default => 'resellers'); diff --git a/lib/NGCP/Panel/Controller/API/RewriteRules.pm b/lib/NGCP/Panel/Controller/API/RewriteRules.pm index 27aef716e3..8697cbed53 100644 --- a/lib/NGCP/Panel/Controller/API/RewriteRules.pm +++ b/lib/NGCP/Panel/Controller/API/RewriteRules.pm @@ -21,12 +21,6 @@ class_has 'api_description' => ( 'Defines a set of Rewrite Rules which are grouped in <a href="#rewriterulesets">Rewrite Rule Sets</a>. They can be used to alter incoming and outgoing numbers.', ); -with 'NGCP::Panel::Role::API::RewriteRules'; - -class_has('resource_name', is => 'ro', default => 'rewriterules'); -class_has('dispatch_path', is => 'ro', default => '/api/rewriterules/'); -class_has('relation', is => 'ro', default => 'http://purl.org/sipwise/ngcp-api/#rel-rewriterules'); - class_has 'query_params' => ( is => 'ro', isa => 'ArrayRef', @@ -56,6 +50,13 @@ class_has 'query_params' => ( ]}, ); + +with 'NGCP::Panel::Role::API::RewriteRules'; + +class_has('resource_name', is => 'ro', default => 'rewriterules'); +class_has('dispatch_path', is => 'ro', default => '/api/rewriterules/'); +class_has('relation', is => 'ro', default => 'http://purl.org/sipwise/ngcp-api/#rel-rewriterules'); + __PACKAGE__->config( action => { map { $_ => { diff --git a/lib/NGCP/Panel/Controller/API/SystemContacts.pm b/lib/NGCP/Panel/Controller/API/SystemContacts.pm index fc1e3713a1..6a8d3e12d3 100644 --- a/lib/NGCP/Panel/Controller/API/SystemContacts.pm +++ b/lib/NGCP/Panel/Controller/API/SystemContacts.pm @@ -23,6 +23,24 @@ class_has 'api_description' => ( 'Defines a physical or legal person\'s address (postal and/or email) to be used in <a href="#contracts">System Contracts</a> (contracts for peerings and resellers).' ); +class_has 'query_params' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub {[ + { + param => 'email', + description => 'Filter for contacts matching an email pattern', + query => { + first => sub { + my $q = shift; + { email => { like => $q } }; + }, + second => sub {}, + }, + }, + ]}, +); + with 'NGCP::Panel::Role::API::SystemContacts'; class_has('resource_name', is => 'ro', default => 'systemcontacts'); diff --git a/lib/NGCP/Panel/Role/API.pm b/lib/NGCP/Panel/Role/API.pm index fc1b09ddda..c82b5d3b6a 100644 --- a/lib/NGCP/Panel/Role/API.pm +++ b/lib/NGCP/Panel/Role/API.pm @@ -82,7 +82,6 @@ sub validate_form { # move {xxx_id} into {xxx}{id} for FormHandler foreach my $key(keys %{ $resource } ) { if($key =~ /^(.+)_id$/ && $key ne "external_id") { - $c->log->debug("++++++++++++ moving key $key with value " . ($resource->{$key} // '<null>') . " to $1/id"); push @normalized, $1; $resource->{$1}{id} = delete $resource->{$key}; } @@ -92,7 +91,6 @@ sub validate_form { my %fields = map { $_->name => undef } $form->fields; for my $k (keys %{ $resource }) { unless(exists $fields{$k}) { - $c->log->debug("+++++++++ deleting unknown key '$k' from message"); # TODO: user, message trace, ... delete $resource->{$k}; }