MT#6283 Add more query params to existing colls

agranig/selfsignup
Andreas Granig 11 years ago
parent 45a42b9b61
commit 861e38b649

@ -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');

@ -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');

@ -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');

@ -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');

@ -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');

@ -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');

@ -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 { $_ => {

@ -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');

@ -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};
}

Loading…
Cancel
Save