diff --git a/lib/NGCP/Panel/Controller/API/CFBNumberSetsItem.pm b/lib/NGCP/Panel/Controller/API/CFBNumberSetsItem.pm index 0bc6bf0b33..136169a775 100644 --- a/lib/NGCP/Panel/Controller/API/CFBNumberSetsItem.pm +++ b/lib/NGCP/Panel/Controller/API/CFBNumberSetsItem.pm @@ -31,6 +31,15 @@ __PACKAGE__->set_config({ Journal => [qw/admin reseller ccareadmin ccare/], }, PATCH => { ops => [qw/add replace remove copy/] }, + DELETE => { + query_params => [ + { + param => 'unassign_first', + description => 'When provided, the set is unassigned from the places where it is used and only then deleted', + query_type => 'integer', + }, + ], + }, }); sub get_journal_methods{ diff --git a/lib/NGCP/Panel/Controller/API/CFSourceSets.pm b/lib/NGCP/Panel/Controller/API/CFSourceSets.pm index 8fead877e2..82f1fbca5f 100644 --- a/lib/NGCP/Panel/Controller/API/CFSourceSets.pm +++ b/lib/NGCP/Panel/Controller/API/CFSourceSets.pm @@ -66,6 +66,15 @@ sub relation{ __PACKAGE__->set_config({ allowed_roles => [qw/admin reseller ccareadmin ccare subscriberadmin subscriber/], + DELETE => { + query_params => [ + { + param => 'unassign_first', + description => 'When provided, the set is unassigned from the places where it is used first and only then deleted', + query_type => 'integer', + }, + ], + }, }); sub GET :Allow { diff --git a/lib/NGCP/Panel/Controller/API/CFSourceSetsItem.pm b/lib/NGCP/Panel/Controller/API/CFSourceSetsItem.pm index 72436ede50..ae545e8dae 100644 --- a/lib/NGCP/Panel/Controller/API/CFSourceSetsItem.pm +++ b/lib/NGCP/Panel/Controller/API/CFSourceSetsItem.pm @@ -41,7 +41,16 @@ __PACKAGE__->set_config({ allowed_roles => { Default => [qw/admin reseller ccareadmin ccare subscriberadmin subscriber/], Journal => [qw/admin reseller ccareadmin ccare/], - } + }, + DELETE => { + query_params => [ + { + param => 'unassign_first', + description => 'When provided, the set is unassigned from the places where it is used and only then deleted', + query_type => 'integer', + }, + ], + }, }); sub GET :Allow { diff --git a/lib/NGCP/Panel/Controller/API/CFTimeSetsItem.pm b/lib/NGCP/Panel/Controller/API/CFTimeSetsItem.pm index 42956f496b..5d7aa00b32 100644 --- a/lib/NGCP/Panel/Controller/API/CFTimeSetsItem.pm +++ b/lib/NGCP/Panel/Controller/API/CFTimeSetsItem.pm @@ -43,6 +43,15 @@ __PACKAGE__->set_config({ Journal => [qw/admin reseller ccareadmin ccare/], }, PATCH => { ops => [qw/add replace remove copy/] }, + DELETE => { + query_params => [ + { + param => 'unassign_first', + description => 'When provided, the set is unassigned from the places where it is used and only then deleted', + query_type => 'integer', + }, + ], + }, }); sub delete_item { diff --git a/lib/NGCP/Panel/Utils/API.pm b/lib/NGCP/Panel/Utils/API.pm index 7fbe6edd0c..d9d79d0537 100644 --- a/lib/NGCP/Panel/Utils/API.pm +++ b/lib/NGCP/Panel/Utils/API.pm @@ -348,6 +348,20 @@ sub generate_swagger_datastructure { }, } }; + + my $query_params = $col->{item_config}->{action}->{PUT}->{query_params}; + + push @{$item_p->{put}{parameters}}, + { '$ref' => '#/components/parameters/ItemIdParameter' }; + + for my $query_param (@{ $query_params // [] }) { + push @{$item_p->{put}{parameters}}, { + name => $query_param->{param}, + description => $query_param->{description}, + in => 'query', + schema => {type => $query_param->{query_type} // 'string'}, + }; + } } if (grep {m/^PATCH$/} @{ $col->{item_actions} }) { @@ -374,6 +388,20 @@ sub generate_swagger_datastructure { }, } }; + + my $query_params = $col->{item_config}->{action}->{PATCH}->{query_params}; + + push @{$item_p->{patch}{parameters}}, + { '$ref' => '#/components/parameters/ItemIdParameter' }; + + for my $query_param (@{ $query_params // [] }) { + push @{$item_p->{patch}{parameters}}, { + name => $query_param->{param}, + description => $query_param->{description}, + in => 'query', + schema => {type => $query_param->{query_type} // 'string'}, + }; + } } if (grep {m/^DELETE$/} @{ $col->{item_actions} }) { @@ -387,15 +415,26 @@ sub generate_swagger_datastructure { }, } }; + + my $query_params = $col->{item_config}->{action}->{DELETE}->{query_params}; + + push @{$item_p->{delete}{parameters}}, + { '$ref' => '#/components/parameters/ItemIdParameter' }; + + for my $query_param (@{ $query_params // [] }) { + push @{$item_p->{delete}{parameters}}, { + name => $query_param->{param}, + description => $query_param->{description}, + in => 'query', + schema => {type => $query_param->{query_type} // 'string'}, + }; + } } #push @paths, $p; $paths{'/'.$chapter.'/'} = $p; if (keys %{ $item_p }) { $item_p->{description} = $col->{description}; - $item_p->{parameters} = [ - { '$ref' => '#/components/parameters/ItemIdParameter' }, - ]; $paths{'/'.$chapter.'/{id}'} = $item_p; }