TT#28460 Adapt already customized configs

Change-Id: Ia5c6201e7ff59081a8a9a15d2ef4f24b4e8a550a
changes/03/18303/12
Irina Peshinskaya 8 years ago
parent bad54e0780
commit d28b6b688c

@ -5,14 +5,9 @@ use NGCP::Panel::Utils::Generic qw(:all);
use parent qw/NGCP::Panel::Role::EntitiesItem NGCP::Panel::Role::API::Invoices/;
__PACKAGE__->set_config();
sub _set_config{
my ($self, $method) = @_;
return {
log_response => 0,
};
}
__PACKAGE__->set_config({
log_response => 0,
});
sub allowed_methods{
return [qw/GET OPTIONS HEAD DELETE/];

@ -7,28 +7,18 @@ use parent qw/NGCP::Panel::Role::EntitiesItem NGCP::Panel::Role::API::PbxDeviceM
use HTTP::Status qw(:constants);
__PACKAGE__->set_config();
__PACKAGE__->set_config({
GET => {
ReturnContentType => 'binary',
},
log_response => 0,
allowed_roles => [qw/admin reseller subscriberadmin subscriber/],
});
sub allowed_methods{
return [qw/GET OPTIONS HEAD/];
}
sub config_allowed_roles {
return [qw/admin reseller subscriberadmin subscriber/];
}
sub _set_config{
my ($self, $method) = @_;
if($method && 'GET' eq $method){
return {
ReturnContentType => 'binary',
};
}
return {
log_response => 0,
};
}
sub get_item_binary_data{
my($self, $c, $id, $item) = @_;
my $type = $c->req->param('type') // 'front';

@ -11,20 +11,16 @@ sub allowed_methods{
return [qw/GET POST OPTIONS HEAD/];
}
__PACKAGE__->set_config();
sub _set_config{
my ($self, $method) = @_;
$method //='';
if ('POST' eq $method){
return {
'ContentType' => ['multipart/form-data'],#,
'Uploads' => [qw/front_image mac_image/],
# Also correct way for the allowed_roles, and really the last word. Will be applied over all others.
# 'AllowedRole' => [qw/admin reseller/],
};
__PACKAGE__->set_config({
POST => {
'ContentType' => ['multipart/form-data'],
'Uploads' => [qw/front_image mac_image/],
},
allowed_roles => {
'Default' => [qw/admin reseller subscriberadmin subscriber/],
'POST' => [qw/admin reseller/],
}
return {};
}
});
# curl -v -X POST --user $USER --insecure -F front_image=@sandbox/spa504g-front.jpg -F mac_image=@sandbox/spa504g-back.jpg -F json='{"reseller_id":1, "vendor":"Cisco", "model":"SPA999", "linerange":[{"name": "Phone Keys", "can_private":true, "can_shared":true, "can_blf":true, "keys":[{"labelpos":"top", "x":5110, "y":5120},{"labelpos":"top", "x":5310, "y":5320}]}]}' https://localhost:4443/api/pbxdevicemodels/

@ -5,20 +5,17 @@ use NGCP::Panel::Utils::Generic qw(:all);
use parent qw/NGCP::Panel::Role::EntitiesItem NGCP::Panel::Role::API::PbxDeviceModels/;
__PACKAGE__->set_config();
sub _set_config{
my ($self, $method) = @_;
$method //='';
if ('PUT' eq $method || 'PATCH' eq $method){
return {
'ContentType' => ['multipart/form-data'],#,
'Uploads' => [qw/front_image mac_image/],
# Also correct way for the allowed_roles, and really the last word. Will be applied over all others.
# 'AllowedRole' => [qw/admin reseller/],
};
__PACKAGE__->set_config({
PUT => {
'ContentType' => ['multipart/form-data'],
'Uploads' => [qw/front_image mac_image/],
},
allowed_roles => {
'Default' => [qw/admin reseller subscriberadmin subscriber/],
'PUT' => [qw/admin reseller/],
'PATCH' => [qw/admin reseller/],
}
return {};
}
});
sub allowed_methods{
return [qw/GET OPTIONS HEAD PATCH PUT/];

@ -8,14 +8,9 @@ use HTTP::Status qw(:constants);
use NGCP::Panel::Utils::Rewrite;
__PACKAGE__->set_config();
sub _set_config{
my ($self, $method) = @_;
return {
own_transaction_control => { POST => 1 },
};
}
__PACKAGE__->set_config({
own_transaction_control => { POST => 1 },
});
sub allowed_methods{
return [qw/GET POST OPTIONS HEAD/];

@ -8,14 +8,9 @@ use HTTP::Status qw(:constants);
use NGCP::Panel::Utils::Rewrite;
__PACKAGE__->set_config();
sub _set_config{
my ($self, $method) = @_;
return {
own_transaction_control => { ALL => 1 },
};
}
__PACKAGE__->set_config({
own_transaction_control => { POST => 1 },
});
sub allowed_methods{
return [qw/GET OPTIONS HEAD PATCH PUT DELETE/];

@ -7,14 +7,10 @@ use NGCP::Panel::Utils::Generic qw(:all);
use HTTP::Status qw(:constants);
__PACKAGE__->set_config();
__PACKAGE__->set_config({
own_transaction_control => { POST => 1 },
});
sub _set_config{
my ($self, $method) = @_;
return {
own_transaction_control => { POST => 1 },
};
}
sub allowed_methods{
return [qw/GET POST OPTIONS HEAD/];

@ -6,14 +6,9 @@ use Sipwise::Base;
use NGCP::Panel::Utils::Generic qw(:all);
use HTTP::Status qw(:constants);
__PACKAGE__->set_config();
sub _set_config{
my ($self, $method) = @_;
return {
own_transaction_control => { ALL => 1 },
};
}
__PACKAGE__->set_config({
own_transaction_control => { POST => 1 },
});
sub allowed_methods{
return [qw/GET OPTIONS HEAD PATCH PUT DELETE/];

@ -5,7 +5,12 @@ use Sipwise::Base;
use parent qw/NGCP::Panel::Role::Entities NGCP::Panel::Role::API::VoicemailGreetings/;
__PACKAGE__->set_config();
__PACKAGE__->set_config({
POST => {
'ContentType' => ['multipart/form-data'],#,
'Uploads' => {'greetingfile' => ['audio/x-wav', 'application/octet-stream']},
},
});
sub allowed_methods{
return [qw/OPTIONS HEAD GET POST/];
@ -19,19 +24,6 @@ sub api_description {
return 'Defines the voicemail greetings. A GET on an item with Accept "audio/x-wav" returns the binary blob of the greeting.';
};
sub _set_config{
my ($self, $method) = @_;
$method //='';
if ('POST' eq $method || 'PUT' eq $method){
return {
'ContentType' => ['multipart/form-data'],#,
'Uploads' => {'greetingfile' => ['audio/x-wav', 'application/octet-stream']},
};
}
return {};
}
sub query_params {
return [
{

@ -4,7 +4,12 @@ use Sipwise::Base;
use NGCP::Panel::Utils::Generic qw(:all);
use parent qw/NGCP::Panel::Role::EntitiesItem NGCP::Panel::Role::API::VoicemailGreetings/;
__PACKAGE__->set_config();
__PACKAGE__->set_config({
PUT => {
'ContentType' => ['multipart/form-data'],#,
'Uploads' => {'greetingfile' => ['audio/x-wav', 'application/octet-stream']},
},
});
sub allowed_methods{
return [qw/GET OPTIONS HEAD PUT DELETE/];
@ -14,21 +19,6 @@ sub config_allowed_roles {
return [qw/admin reseller subscriberadmin subscriber/];
}
sub _set_config{
my ($self, $method) = @_;
$method //='';
#todo: cpommon parts can be moved to the "Role" parent
if ('POST' eq $method || 'PUT' eq $method){
return {
'ContentType' => ['multipart/form-data'],#,
'Uploads' => {'greetingfile' => ['audio/x-wav', 'application/octet-stream']},
#TODO: check requested mimetype against provided data
#'Accepted' => {'audio/x-wav' => [{'recording' => 'voicemail_greeting_[%dir%]_[%subscriber_id%]'}],
};
}
return {};
}
sub update_item_model{
my($self, $c, $item, $old_resource, $resource, $form, $process_extras) = @_;

Loading…
Cancel
Save