TT#12905 ngcp-panel API will change, '_embedded' will be an array

Change-Id: I320cdffe66c321fd8a71a0857549992e24027fa8
changes/03/12003/2
Victor Seva 8 years ago
parent fe0850d0ca
commit 0b49ec43f3

@ -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");
}

@ -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 {

@ -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");

Loading…
Cancel
Save