cPanel-APIClient
view release on metacpan or search on metacpan
lib/cPanel/APIClient/Response/WHM1.pm view on Meta::CPAN
}
#----------------------------------------------------------------------
=head2 @results = I<OBJ>->parse_batch()
Interprets the API response as from the C<batch> API call and returns
a list of instances of this class that represents the elements of that
response.
=cut
sub parse_batch {
my ($self) = @_;
Cpanel::Context::must_be_list();
my $class = ref $self;
return map { $class->new($_) } @{ $self->get_data() };
}
#----------------------------------------------------------------------
=head2 $messages_ar = I<OBJ>->get_nonfatal_messages()
Returns a reference to an array of two-member arrays, thus:
[
[ info => 'Hey, by the way â¦' ],
[ warn => 'Hey, this might cause a problem â¦' ],
]
The first value of each two-member array is either C<info> or C<warn>,
and the value is the actual message. Note that error messages are not
part of this structure; for that, use C<get_error()>.
This follows a pattern from CJT1 and CJT2.
=cut
my %type_xform = qw(
warnings warn
messages info
);
sub get_nonfatal_messages {
my ($self) = @_;
my @messages;
my $metadata = $self->{'metadata'};
if ( $metadata && ( my $output = $metadata->{'output'} ) ) {
for my $type (qw( warnings messages )) {
my $msgs = $output->{$type};
next if !$msgs;
if ( !ref $msgs ) {
$msgs = [ split m<\n>, $msgs ];
}
if ( 'ARRAY' eq ref $msgs ) {
push @messages, [ $type_xform{$type} => $_ ] for @$msgs;
}
else {
warn "Unexpected type for metadata.output.$type: $msgs";
}
}
}
return \@messages;
}
=head1 LICENSE
Copyright 2020 cPanel, L. L. C. All rights reserved. L<http://cpanel.net>
This is free software; you can redistribute it and/or modify it under the
same terms as Perl itself. See L<perlartistic>.
=cut
1;
( run in 1.497 second using v1.01-cache-2.11-cpan-71847e10f99 )