MT#18663 row bulk processing framework WIP #10
+reject invalid subscriber numbers by pattern +detect changed passwords in subscriber+username.xslx +separate --skip-errors option from --dry option +rest request classes for ngcp resources: +SystemContacts +Contracts +BillingProfiles +Resellers +BillingZones +BillingFees +Domains +CustomerContacts +Customers +Subscribers +making post, get, put, patch, delete work for NGCP rest-api Change-Id: Ic55caed7d5425716adfbba9e2bc6b9153334481cchanges/95/6995/6
parent
5e47afdfc9
commit
84575f90e6
@ -0,0 +1,132 @@
|
||||
package NGCP::BulkProcessor::Dao::Trunk::billing::contacts;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_billing_db
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::SqlProcessor qw(
|
||||
checktableinfo
|
||||
insert_record
|
||||
copy_row
|
||||
);
|
||||
use NGCP::BulkProcessor::SqlRecord qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::SqlRecord);
|
||||
our @EXPORT_OK = qw(
|
||||
gettablename
|
||||
check_table
|
||||
insert_row
|
||||
);
|
||||
|
||||
#my $logger = getlogger(__PACKAGE__);
|
||||
|
||||
my $tablename = 'contacts';
|
||||
my $get_db = \&get_billing_db;
|
||||
|
||||
my $expected_fieldnames = [
|
||||
'id',
|
||||
'reseller_id',
|
||||
'gender',
|
||||
'firstname',
|
||||
'lastname',
|
||||
'comregnum',
|
||||
'company',
|
||||
'street',
|
||||
'postcode',
|
||||
'city',
|
||||
'country',
|
||||
'phonenumber',
|
||||
'mobilenumber',
|
||||
'email',
|
||||
'newsletter',
|
||||
'modify_timestamp',
|
||||
'create_timestamp',
|
||||
'faxnumber',
|
||||
'iban',
|
||||
'bic',
|
||||
'vatnum',
|
||||
'bankname',
|
||||
'gpp0',
|
||||
'gpp1',
|
||||
'gpp2',
|
||||
'gpp3',
|
||||
'gpp4',
|
||||
'gpp5',
|
||||
'gpp6',
|
||||
'gpp7',
|
||||
'gpp8',
|
||||
'gpp9',
|
||||
];
|
||||
|
||||
my $indexes = {};
|
||||
# 'balance_interval' => [ 'contract_id','start','end' ],
|
||||
# 'invoice_idx' => [ 'invoice_id' ],
|
||||
#};
|
||||
|
||||
my $insert_unique_fields = []; #[ 'contract_id','start','end' ];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::SqlRecord->new($get_db,
|
||||
$tablename,
|
||||
$expected_fieldnames,$indexes);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$expected_fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub insert_row {
|
||||
|
||||
my ($data,$insert_ignore) = @_;
|
||||
check_table();
|
||||
#return insert_record($get_db,$tablename,$data,$insert_ignore,$unique_fields) = @_;
|
||||
|
||||
}
|
||||
|
||||
sub buildrecords_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my @records = ();
|
||||
my $record;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
foreach my $row (@$rows) {
|
||||
$record = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @records,$record;
|
||||
}
|
||||
}
|
||||
|
||||
return \@records;
|
||||
|
||||
}
|
||||
|
||||
sub gettablename {
|
||||
|
||||
return $tablename;
|
||||
|
||||
}
|
||||
|
||||
sub check_table {
|
||||
|
||||
return checktableinfo($get_db,
|
||||
$tablename,
|
||||
$expected_fieldnames,
|
||||
$indexes);
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,38 @@
|
||||
package NGCP::BulkProcessor::Projects::t::ApiTest;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::BillingProfiles qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
test
|
||||
);
|
||||
|
||||
sub test {
|
||||
|
||||
my $result = 1;
|
||||
|
||||
return $result && NGCP::BulkProcessor::RestRequests::Trunk::BillingProfiles::process_items(
|
||||
process_code => sub {
|
||||
my ($context,$records,$row_offset) = @_;
|
||||
my $rownum = $row_offset;
|
||||
print "!!!!!!$row_offset!!!!!!!\n";
|
||||
return 1;
|
||||
},
|
||||
init_process_context_code => sub {
|
||||
my ($context)= @_;
|
||||
},
|
||||
uninit_process_context_code => sub {
|
||||
my ($context)= @_;
|
||||
destroy_all_dbs();
|
||||
},
|
||||
load_recursive => 1,
|
||||
multithreading => 1,
|
||||
numofthreads => 4,
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,41 @@
|
||||
##general settings:
|
||||
#working_path = /var/sipwise/Migration/IPGallery
|
||||
cpucount = 4
|
||||
enablemultithreading = 1
|
||||
|
||||
##gearman/service listener config:
|
||||
jobservers = 127.0.0.1:4730
|
||||
|
||||
#provisioning_conf = /etc/ngcp-panel/provisioning.conf
|
||||
|
||||
##NGCP MySQL connectivity - "accounting" db:
|
||||
accounting_host = 127.0.0.1
|
||||
accounting_port = 3306
|
||||
accounting_databasename = accounting
|
||||
accounting_username = root
|
||||
accounting_password =
|
||||
|
||||
##NGCP MySQL connectivity - "billing" db:
|
||||
billing_host = 192.168.0.77
|
||||
billing_port = 3306
|
||||
billing_databasename = billing
|
||||
billing_username = root
|
||||
billing_password =
|
||||
|
||||
##NGCP REST-API connectivity:
|
||||
ngcprestapi_uri = https://127.0.0.1:1443
|
||||
ngcprestapi_username = administrator
|
||||
ngcprestapi_password = administrator
|
||||
ngcprestapi_realm = api_admin_http
|
||||
|
||||
##sending email:
|
||||
emailenable = 0
|
||||
erroremailrecipient =
|
||||
warnemailrecipient =
|
||||
completionemailrecipient = rkrenn@sipwise.com
|
||||
doneemailrecipient =
|
||||
|
||||
##logging:
|
||||
fileloglevel = OFF
|
||||
screenloglevel = INFO
|
||||
emailloglevel = OFF
|
||||
@ -0,0 +1,112 @@
|
||||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use File::Basename;
|
||||
use Cwd;
|
||||
use lib Cwd::abs_path(File::Basename::dirname(__FILE__) . '/../../../../');
|
||||
|
||||
use NGCP::BulkProcessor::LoadConfig qw(
|
||||
load_config
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::SystemContacts qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::Contracts qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::Resellers qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::BillingProfiles qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::BillingZones qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::BillingFees qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::Domains qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::CustomerContacts qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::Customers qw();
|
||||
use NGCP::BulkProcessor::RestRequests::Trunk::Subscribers qw();
|
||||
|
||||
load_config('config.cfg');
|
||||
|
||||
{
|
||||
my $t = time();
|
||||
my $systemcontact_id = NGCP::BulkProcessor::RestRequests::Trunk::SystemContacts::create_item({
|
||||
email => "test$t\@system.com",
|
||||
});
|
||||
my $contract_id = NGCP::BulkProcessor::RestRequests::Trunk::Contracts::create_item({
|
||||
contact_id => $systemcontact_id,
|
||||
billing_profile_id => 1, #default profile id
|
||||
type => 'reseller',
|
||||
status => 'active',
|
||||
});
|
||||
my $reseller_id = NGCP::BulkProcessor::RestRequests::Trunk::Resellers::create_item({
|
||||
contract_id => $contract_id,
|
||||
name => "reseller$t",
|
||||
status => 'active',
|
||||
});
|
||||
|
||||
my $billing_profile_id = NGCP::BulkProcessor::RestRequests::Trunk::BillingProfiles::create_item({
|
||||
handle => "profile$t",
|
||||
name => "profile$t",
|
||||
reseller_id => $reseller_id,
|
||||
});
|
||||
|
||||
my $billing_zone_id = NGCP::BulkProcessor::RestRequests::Trunk::BillingZones::create_item({
|
||||
billing_profile_id => $billing_profile_id,
|
||||
zone => "zone$t",
|
||||
});
|
||||
|
||||
my $billing_fee_id = NGCP::BulkProcessor::RestRequests::Trunk::BillingFees::create_item({
|
||||
billing_profile_id => $billing_profile_id,
|
||||
billing_zone_id => $billing_zone_id,
|
||||
direction => 'out',
|
||||
destination => '.*',
|
||||
onpeak_init_rate => 10,
|
||||
onpeak_init_interval => 1,
|
||||
onpeak_follow_rate => 5,
|
||||
onpeak_follow_interval => 2,
|
||||
offpeak_init_rate => 8,
|
||||
offpeak_init_interval => 1,
|
||||
offpeak_follow_rate => 4,
|
||||
offpeak_follow_interval => 2,
|
||||
});
|
||||
|
||||
my $success = NGCP::BulkProcessor::RestRequests::Trunk::BillingFees::delete_item($billing_fee_id);
|
||||
|
||||
my $contract = NGCP::BulkProcessor::RestRequests::Trunk::Contracts::set_item($contract_id,{
|
||||
contact_id => $systemcontact_id,
|
||||
billing_profile_id => $billing_profile_id,
|
||||
type => 'reseller',
|
||||
status => 'active',
|
||||
});
|
||||
|
||||
$contract = NGCP::BulkProcessor::RestRequests::Trunk::Contracts::update_item($contract_id,{
|
||||
contact_id => $systemcontact_id,
|
||||
billing_profile_id => $billing_profile_id,
|
||||
#type => 'reseller',
|
||||
status => 'active',
|
||||
});
|
||||
|
||||
my $domain_id = NGCP::BulkProcessor::RestRequests::Trunk::Domains::create_item({
|
||||
domain => "test$t.com",
|
||||
reseller_id => $reseller_id,
|
||||
});
|
||||
|
||||
my $customercontact_id = NGCP::BulkProcessor::RestRequests::Trunk::CustomerContacts::create_item({
|
||||
email => "test$t\@customer.com",
|
||||
reseller_id => $reseller_id,
|
||||
});
|
||||
|
||||
my $customer_id = NGCP::BulkProcessor::RestRequests::Trunk::Customers::create_item({
|
||||
contact_id => $customercontact_id,
|
||||
billing_profile_id => $billing_profile_id,
|
||||
status => "active",
|
||||
type => "sipaccount",
|
||||
});
|
||||
|
||||
my $subscriber_id = NGCP::BulkProcessor::RestRequests::Trunk::Subscribers::create_item({
|
||||
customer_id => $customer_id,
|
||||
domain_id => $domain_id,
|
||||
username => "subscriber$t",
|
||||
password => "subscriber$t",
|
||||
});
|
||||
|
||||
print "blah";
|
||||
}
|
||||
|
||||
exit;
|
||||
@ -0,0 +1,119 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::BillingFees;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
delete_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'billingfees';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'billing_zone_id',
|
||||
'destination',
|
||||
'direction',
|
||||
'offpeak_follow_interval',
|
||||
'offpeak_follow_rate',
|
||||
'offpeak_init_interval',
|
||||
'offpeak_init_rate',
|
||||
'onpeak_follow_interval',
|
||||
'onpeak_follow_rate',
|
||||
'onpeak_init_interval',
|
||||
'onpeak_init_rate',
|
||||
'purge_existing',
|
||||
'source',
|
||||
'use_free_time',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub delete_item {
|
||||
|
||||
my ($id,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
($id) = $restapi->delete(&$get_item_path_query($id),$headers);
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,98 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::BillingZones;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'billingzones';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'billing_profile_id',
|
||||
'detail',
|
||||
'zone',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,120 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::Contracts;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
set_item
|
||||
update_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'contracts';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'billing_profile_definition',
|
||||
'billing_profile_id',
|
||||
'billing_profiles',
|
||||
'contact_id',
|
||||
'external_id',
|
||||
'status',
|
||||
'type',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub set_item {
|
||||
|
||||
my ($id,$data,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->put(&$get_item_path_query($id),$data,$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub update_item {
|
||||
|
||||
my ($id,$data,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->patch(&$get_item_path_query($id),$data,$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,122 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::CustomerContacts;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'customercontacts';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'bankname',
|
||||
'bic',
|
||||
'city',
|
||||
'company',
|
||||
'comregnum',
|
||||
'country',
|
||||
'email',
|
||||
'faxnumber',
|
||||
'firstname',
|
||||
'gpp0',
|
||||
'gpp1',
|
||||
'gpp2',
|
||||
'gpp3',
|
||||
'gpp4',
|
||||
'gpp5',
|
||||
'gpp6',
|
||||
'gpp7',
|
||||
'gpp8',
|
||||
'gpp9',
|
||||
'iban',
|
||||
'lastname',
|
||||
'mobilenumber',
|
||||
'phonenumber',
|
||||
'postcode',
|
||||
'reseller_id',
|
||||
'street',
|
||||
'vatnum',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,128 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::Customers;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
set_item
|
||||
update_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'customers';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'add_vat',
|
||||
'billing_profile_definition',
|
||||
'billing_profile_id',
|
||||
'billing_profiles',
|
||||
'contact_id',
|
||||
'external_id',
|
||||
'invoice_email_template',
|
||||
'invoice_template',
|
||||
'max_subscribers',
|
||||
'passreset_email_template',
|
||||
'profile_package_id',
|
||||
'status',
|
||||
'subscriber_email_template',
|
||||
'type',
|
||||
'vat_rate',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub set_item {
|
||||
|
||||
my ($id,$data,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->put(&$get_item_path_query($id),$data,$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub update_item {
|
||||
|
||||
my ($id,$data,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->patch(&$get_item_path_query($id),$data,$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,98 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::Domains;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
process_collection
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'domains';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'domain',
|
||||
'reseller_id',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,100 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::Resellers;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'resellers';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'contract_id',
|
||||
'enable_rtc',
|
||||
'name',
|
||||
'rtc_networks',
|
||||
'status',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,145 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::Subscribers;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
set_item
|
||||
update_item
|
||||
delete_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'subscribers';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'administrative',
|
||||
'alias_numbers',
|
||||
'customer_id',
|
||||
'display_name',
|
||||
'domain',
|
||||
'domain_id',
|
||||
'email',
|
||||
'external_id',
|
||||
'is_pbx_group',
|
||||
'is_pbx_pilot',
|
||||
'lock',
|
||||
'password',
|
||||
'pbx_extension',
|
||||
'pbx_group_ids',
|
||||
'pbx_groupmember_ids_id',
|
||||
'primary_number',
|
||||
'profile_id',
|
||||
'profile_set_id',
|
||||
'status',
|
||||
'username',
|
||||
'webpassword',
|
||||
'webusername',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub set_item {
|
||||
|
||||
my ($id,$data,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->put(&$get_item_path_query($id),$data,$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub update_item {
|
||||
|
||||
my ($id,$data,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->patch(&$get_item_path_query($id),$data,$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub delete_item {
|
||||
|
||||
my ($id,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
($id) = $restapi->delete(&$get_item_path_query($id),$headers);
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -0,0 +1,121 @@
|
||||
package NGCP::BulkProcessor::RestRequests::Trunk::SystemContacts;
|
||||
use strict;
|
||||
|
||||
## no critic
|
||||
|
||||
use NGCP::BulkProcessor::ConnectorPool qw(
|
||||
get_ngcp_restapi
|
||||
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestProcessor qw(
|
||||
copy_row
|
||||
);
|
||||
|
||||
use NGCP::BulkProcessor::RestConnectors::NGCPRestApi qw();
|
||||
use NGCP::BulkProcessor::RestItem qw();
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter NGCP::BulkProcessor::RestItem);
|
||||
our @EXPORT_OK = qw(
|
||||
get_item
|
||||
create_item
|
||||
);
|
||||
|
||||
my $get_restapi = \&get_ngcp_restapi;
|
||||
my $resource = 'systemcontacts';
|
||||
my $item_relation = 'ngcp:' . $resource;
|
||||
my $get_item_path_query = sub {
|
||||
my ($id) = @_;
|
||||
return 'api/' . $resource . '/' . $id;
|
||||
};
|
||||
my $collection_path_query = 'api/' . $resource . '/';
|
||||
|
||||
my $fieldnames = [
|
||||
'bankname',
|
||||
'bic',
|
||||
'city',
|
||||
'company',
|
||||
'comregnum',
|
||||
'country',
|
||||
'email',
|
||||
'faxnumber',
|
||||
'firstname',
|
||||
'gpp0',
|
||||
'gpp1',
|
||||
'gpp2',
|
||||
'gpp3',
|
||||
'gpp4',
|
||||
'gpp5',
|
||||
'gpp6',
|
||||
'gpp7',
|
||||
'gpp8',
|
||||
'gpp9',
|
||||
'iban',
|
||||
'lastname',
|
||||
'mobilenumber',
|
||||
'phonenumber',
|
||||
'postcode',
|
||||
'street',
|
||||
'vatnum',
|
||||
];
|
||||
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = NGCP::BulkProcessor::RestItem->new($fieldnames);
|
||||
|
||||
bless($self,$class);
|
||||
|
||||
copy_row($self,shift,$fieldnames);
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub get_item {
|
||||
|
||||
my ($id,$load_recursive,$headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
return builditems_fromrows($restapi->get(&$get_item_path_query($id),$headers),$load_recursive);
|
||||
|
||||
}
|
||||
|
||||
sub create_item {
|
||||
|
||||
my ($data,$load,$load_recursive,$post_headers,$get_headers) = @_;
|
||||
my $restapi = &$get_restapi();
|
||||
if ($load) {
|
||||
return builditems_fromrows($restapi->post_get($collection_path_query,$data,$post_headers,$get_headers),$load_recursive);
|
||||
} else {
|
||||
my ($id) = $restapi->post($collection_path_query,$data,$post_headers);
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub builditems_fromrows {
|
||||
|
||||
my ($rows,$load_recursive) = @_;
|
||||
|
||||
my $item;
|
||||
|
||||
if (defined $rows and ref $rows eq 'ARRAY') {
|
||||
my @items = ();
|
||||
foreach my $row (@$rows) {
|
||||
$item = __PACKAGE__->new($row);
|
||||
|
||||
# transformations go here ...
|
||||
|
||||
push @items,$item;
|
||||
}
|
||||
return \@items;
|
||||
} elsif (defined $rows and ref $rows eq 'HASH') {
|
||||
$item = __PACKAGE__->new($rows);
|
||||
return $item;
|
||||
}
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Reference in new issue