diff --git a/bin/ngcp-create-soundset b/bin/ngcp-create-soundset new file mode 100755 index 0000000..1f38ea0 --- /dev/null +++ b/bin/ngcp-create-soundset @@ -0,0 +1,174 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use English; +use Getopt::Long; +use Pod::Usage; +use NGCP::API::Client; +use Readonly; + +Readonly my @required => qw(reseller-id name); + +my $opts = { + type => 'sipaccount', + status => 'active', + verbose => 0, +}; + +GetOptions($opts, + 'help|h' => sub { usage() }, + 'reseller-id=i', + 'name=s', + 'description=s', + 'copy-from-default', + 'contract-default', + 'language=s', + 'loop-play', + 'verbose', +) or usage(); + +sub check_params { + my @missing; + + foreach my $param (@required) { + push @missing, $param unless $opts->{$param}; + } + usage(join(' ', @missing)) if scalar @missing; + + return; +} + +sub usage { + my $missing = shift; + + pod2usage( + -exitval => $missing ? 1 : 0, + -verbose => 99, + -sections => 'SYNOPSIS|REQUIRED ARGUMENTS|OPTIONS', + -message => $missing ? "Missing parameters: $missing" : '', + ); + + return; +} + +sub main { + check_params(); + + my $client = NGCP::API::Client->new(verbose => $opts->{verbose}); + + my $uri = '/api/soundsets/'; + my %data = map { + my $name = s/-/_/gr; + $name =~ s/loop_play/loopplay/; + $name => $opts->{$_}; + } grep { + length $opts->{$_} + } qw(reseller-id name description copy-from-default contract-default loop-play language status); + + my $res = $client->request('POST', $uri, \%data); + print $res->result . "\n"; + + return !$res->is_success; +} + +exit main(); + +__END__ + +=head1 NAME + +ngcp-create-soundset - create a soundset + +=head1 SYNOPSIS + +B [I...] I... + +=head1 DESCRIPTION + +B creates a soundset on the NGCP platform. + +=head1 REQUIRED ARGUMENTS + +=over 8 + +=item B<--reseller-id> I + +Reseller id. Default 1. + +=item B<--name> I + +Soundset name. + +=back + +=head1 OPTIONS + +=over 8 + +=item B<--contract-default> + +If enabled the sound set is used for all existing and new subscribers within the customer. + +=item B<--copy-from-default> + +Use system default sound files. + +=item B<--description> I + +Description of the soundset default empty. + +=item B<--language> I + +The language of the default sound files. + +=item B<--loop-play> + +Play files in a loop. + +=item B<--verbose> + +Show additional debug information. Default false. + +=item B<--help> + +Print a brief help message. + +=back + +=head1 EXIT STATUS + +Exit code 0 means everything is ok otherwise 1. + +=head1 SEE ALSO + +NGCP::API::Client + +=head1 BUGS AND LIMITATIONS + +Please report problems you notice to the Sipwise +Development Team . + +=head1 AUTHOR + +Alessio Garzi + +=head1 LICENSE + +Copyright (C) 2021 Sipwise GmbH, Austria + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +=cut diff --git a/debian/ngcp-provisioning-tools.install b/debian/ngcp-provisioning-tools.install index cc49e21..0e9469b 100644 --- a/debian/ngcp-provisioning-tools.install +++ b/debian/ngcp-provisioning-tools.install @@ -2,6 +2,7 @@ usr/bin/ngcp-api-admins usr/bin/ngcp-api-ping usr/bin/ngcp-create-customer usr/bin/ngcp-create-domain +usr/bin/ngcp-create-soundset usr/bin/ngcp-create-subscriber usr/bin/ngcp-delete-domain usr/bin/ngcp-get-customer diff --git a/debian/ngcp-provisioning-tools.manpages b/debian/ngcp-provisioning-tools.manpages index f5d351d..9c43920 100644 --- a/debian/ngcp-provisioning-tools.manpages +++ b/debian/ngcp-provisioning-tools.manpages @@ -2,6 +2,7 @@ usr/share/man/man1/ngcp-api-admins.1p usr/share/man/man1/ngcp-api-ping.1p usr/share/man/man1/ngcp-create-customer.1p usr/share/man/man1/ngcp-create-domain.1p +usr/share/man/man1/ngcp-create-soundset.1p usr/share/man/man1/ngcp-create-subscriber.1p usr/share/man/man1/ngcp-delete-domain.1p usr/share/man/man1/ngcp-get-customer.1p