From 0b49ec43f3ee3f38a109c3cbe9f88868137ca24e Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 14 Mar 2017 17:19:55 +0100 Subject: [PATCH] TT#12905 ngcp-panel API will change, '_embedded' will be an array Change-Id: I320cdffe66c321fd8a71a0857549992e24027fa8 --- bin/ngcp-create_subscriber | 7 ++++++- bin/ngcp-delete_domain | 8 +++++++- bin/ngcp-terminate_subscriber | 7 ++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bin/ngcp-create_subscriber b/bin/ngcp-create_subscriber index 70d54a9..6abd39e 100755 --- a/bin/ngcp-create_subscriber +++ b/bin/ngcp-create_subscriber @@ -63,7 +63,12 @@ sub main { # domain_id my $dom = $client->request("GET", "/api/domains/?domain=".$opts->{domain}); if ($dom->as_hash->{total_count} == 1) { - $data{domain_id} = $dom->as_hash->{_embedded}->{'ngcp:domains'}->{id}; + my $tmp = $dom->as_hash->{_embedded}->{'ngcp:domains'}; + if (ref $tmp eq 'ARRAY') { + $data{domain_id} = $tmp[0]->{id}; + } else { + $data{domain_id} = $tmp->{id}; + } } else { usage("Domain not found"); } diff --git a/bin/ngcp-delete_domain b/bin/ngcp-delete_domain index c8eadae..bf3fcd7 100755 --- a/bin/ngcp-delete_domain +++ b/bin/ngcp-delete_domain @@ -55,8 +55,14 @@ sub main { $client->set_verbose($opts->{verbose}); # domain_id my $dom = $client->request("GET", "/api/domains/?domain=".$opts->{domain}); + my $dom_id; if ($dom->as_hash->{total_count} == 1) { - my $dom_id = $dom->as_hash->{_embedded}->{'ngcp:domains'}->{id}; + my $tmp = $dom->as_hash->{_embedded}->{'ngcp:domains'}; + if (ref $tmp eq 'ARRAY') { + $dom_id = $tmp[0]->{id}; + } else { + $dom_id = $tmp->{id}; + } usage("Domain not found") unless $dom_id; $uri .= $dom_id; } else { diff --git a/bin/ngcp-terminate_subscriber b/bin/ngcp-terminate_subscriber index 27f6592..e3d3b4b 100755 --- a/bin/ngcp-terminate_subscriber +++ b/bin/ngcp-terminate_subscriber @@ -52,7 +52,12 @@ sub main { my $sub = $client->request("GET", $uri); my $sub_id; if ($sub->as_hash->{total_count} == 1) { - $sub_id = $sub->as_hash->{_embedded}->{'ngcp:subscribers'}->{id}; + my $tmp = $sub->as_hash->{_embedded}->{'ngcp:subscribers'}; + if (ref $tmp eq 'ARRAY') { + $sub_id = $tmp[0]->{id}; + } else { + $sub_id = $tmp->{id}; + } usage("Wrong subscriber id found") unless $sub_id =~ /^\d$/; } else { usage("Subscriber not found");