TT#36055 Introduce container_resource parameter for preferences

Change-Id: I0dac074f325e3911e266b3ead659a0d0860d2b8c
changes/63/21063/5
Irina Peshinskaya 8 years ago
parent 7b470abd31
commit 681d5e93c3

@ -15,6 +15,10 @@ sub allowed_methods{
return [qw/GET OPTIONS HEAD/];
}
sub container_resource_type{
return 'contracts';
}
sub api_description {
return 'Specifies certain properties (preferences) for a <a href="#customers">Customer</a>. The full list of properties can be obtained via <a href="/api/customerpreferencedefs/">CustomerPreferenceDefs</a>.';
};

@ -32,6 +32,10 @@ sub relation{
return 'http://purl.org/sipwise/ngcp-api/#rel-customerpreferences';
}
sub container_resource_type{
return 'contracts';
}
sub journal_query_params {
my($self,$query_params) = @_;
return $self->get_journal_query_params($query_params);

@ -41,6 +41,10 @@ sub relation{
return 'http://purl.org/sipwise/ngcp-api/#rel-domainpreferences';
}
sub container_resource_type{
return 'domains';
}
__PACKAGE__->set_config({
allowed_roles => [qw/admin reseller/],
});

@ -24,6 +24,10 @@ sub resource_name{
return 'domainpreferences';
}
sub container_resource_type{
return 'domains';
}
sub dispatch_path{
return '/api/domainpreferences/';
}

@ -24,6 +24,10 @@ sub resource_name{
return 'pbxdevicepreferences';
}
sub container_resource_type{
return 'pbxdevicemodels';
}
sub dispatch_path{
return '/api/pbxdevicepreferences/';
}

@ -32,6 +32,10 @@ sub relation{
return 'http://purl.org/sipwise/ngcp-api/#rel-pbxdevicepreferences';
}
sub container_resource_type {
return 'pbxdevicemodels';
}
sub journal_query_params {
my($self,$query_params) = @_;
return $self->get_journal_query_params($query_params);

@ -24,6 +24,10 @@ sub resource_name{
return 'pbxdeviceprofilepreferences';
}
sub container_resource_type{
return 'pbxdeviceprofiles';
}
sub dispatch_path{
return '/api/pbxdeviceprofilepreferences/';
}

@ -24,6 +24,10 @@ sub resource_name{
return 'pbxdeviceprofilepreferences';
}
sub container_resource_type{
return 'pbxdeviceprofiles';
}
sub dispatch_path{
return '/api/pbxdeviceprofilepreferences/';
}

@ -32,6 +32,10 @@ sub resource_name{
return 'peeringserverpreferences';
}
sub container_resource_type{
return 'peerings';
}
sub dispatch_path{
return '/api/peeringserverpreferences/';
}

@ -24,6 +24,10 @@ sub resource_name{
return 'peeringserverpreferences';
}
sub container_resource_type{
return 'peerings';
}
sub dispatch_path{
return '/api/peeringserverpreferences/';
}

@ -24,6 +24,10 @@ sub resource_name{
return 'profilepreferences';
}
sub container_resource_type{
return 'profiles';
}
sub dispatch_path{
return '/api/profilepreferences/';
}

@ -24,6 +24,10 @@ sub resource_name{
return 'profilepreferences';
}
sub container_resource_type{
return 'profiles';
}
sub dispatch_path{
return '/api/profilepreferences/';
}

@ -66,6 +66,10 @@ sub resource_name{
return 'subscriberpreferences';
}
sub container_resource_type{
return 'subscribers';
}
sub dispatch_path{
return '/api/subscriberpreferences/';
}

@ -25,6 +25,10 @@ sub resource_name{
return 'subscriberpreferences';
}
sub container_resource_type{
return 'subscribers';
}
sub dispatch_path{
return '/api/subscriberpreferences/';
}

@ -24,6 +24,7 @@ sub get_form {
sub hal_from_item {
my ($self, $c, $item, $type) = @_;
$type //= $self->container_resource_type;
my $print_type = $type;
$print_type = "customers" if $print_type eq "contracts";
my $hal = Data::HAL->new(
@ -60,6 +61,8 @@ sub _check_profile {
sub get_resource {
my ($self, $c, $item, $type) = @_;
$type //= $self->container_resource_type;
my $prefs;
my %profile_attrs = (); # for filtering profiles based list
my %profile_allowed_attrs; # for filtering subscriber attrs on its profile
@ -273,6 +276,7 @@ sub get_resource {
sub _item_rs {
my ($self, $c, $type) = @_;
my $item_rs;
$type //= $self->container_resource_type;
if($type eq "domains") {
# we actually return the domain rs here, as we can easily
@ -380,6 +384,7 @@ sub _item_rs {
sub item_by_id {
my ($self, $c, $id, $type) = @_;
$type //= $self->container_resource_type;
my $item_rs = $self->item_rs($c, $type);
return $item_rs->find($id);
}
@ -439,6 +444,12 @@ sub get_preference_rs {
sub update_item {
my ($self, $c, $item, $old_resource, $resource, $replace, $type) = @_;
if (ref $replace || !defined $replace) {
$replace = uc($c->request->method) eq 'PUT';
}
if (ref $type || !defined $type) {
$type = $self->container_resource_type;
}
delete $resource->{id};
my $accessor;
my $elem;

Loading…
Cancel
Save