| 1 | # Copyright (c) 2015 SUSE LLC | ||
| 2 | # | ||
| 3 | # This program is free software; you can redistribute it and/or modify | ||
| 4 | # it under the terms of the GNU General Public License version 2 as | ||
| 5 | # published by the Free Software Foundation. | ||
| 6 | # | ||
| 7 | # This program is distributed in the hope that it will be useful, | ||
| 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 10 | # GNU General Public License for more details. | ||
| 11 | # | ||
| 12 | # You should have received a copy of the GNU General Public License | ||
| 13 | # along with this program (see the file COPYING); if not, write to the | ||
| 14 | # Free Software Foundation, Inc., | ||
| 15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
| 16 | # | ||
| 17 | package Net::OBS::Client::BuildResults; | ||
| 18 | |||
| 19 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 0 | ▶ | use Net::OBS::Client; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 21 | use Net::OBS::Client::DTD; | ||
| 22 | use XML::Structured; | ||
| 23 | use Data::Dumper; | ||
| 24 | |||
| 25 | with 'Net::OBS::Client::Roles::Client'; | ||
| 26 | |||
| 27 | =head1 NAME | ||
| 28 | |||
| 29 | Net::OBS::Client::BuildResults - fetch binarylist and fileinfo | ||
| 30 | |||
| 31 | =head1 SYNOPSIS | ||
| 32 | |||
| 33 | use Net::OBS::Client::BuildResults; | ||
| 34 | |||
| 35 | my $obj = Net::OBS::Client::BuildResults->new( | ||
| 36 | apiurl => $apiurl, | ||
| 37 | project => $project, | ||
| 38 | package => $package, | ||
| 39 | repository => $repo, | ||
| 40 | arch => $arch, | ||
| 41 | ); | ||
| 42 | |||
| 43 | my $bin = $obj->binarylist; | ||
| 44 | |||
| 45 | my $inf = $obj->fileinfo($filename); | ||
| 46 | |||
| 47 | |||
| 48 | =head1 ATTRIBUTES | ||
| 49 | |||
| 50 | |||
| 51 | =head2 project | ||
| 52 | |||
| 53 | |||
| 54 | =head2 package | ||
| 55 | |||
| 56 | |||
| 57 | =head2 repository | ||
| 58 | |||
| 59 | |||
| 60 | =head2 arch | ||
| 61 | |||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | has project => ( | ||
| 66 | is => 'rw', | ||
| 67 | isa => 'Str', | ||
| 68 | ); | ||
| 69 | |||
| 70 | has repository => ( | ||
| 71 | is => 'rw', | ||
| 72 | isa => 'Str', | ||
| 73 | ); | ||
| 74 | |||
| 75 | has arch => ( | ||
| 76 | is => 'rw', | ||
| 77 | isa => 'Str', | ||
| 78 | ); | ||
| 79 | |||
| 80 | has package => ( | ||
| 81 | is => 'rw', | ||
| 82 | isa => 'Str', | ||
| 83 | ); | ||
| 84 | |||
| 85 | has api_path => ( | ||
| 86 | is => 'rw', | ||
| 87 | isa => 'Str', | ||
| 88 | ); | ||
| 89 | |||
| 90 | =head1 SUBROUTINES/METHODS | ||
| 91 | |||
| 92 | =head2 binarylist - fetch list of binary buildresults | ||
| 93 | |||
| 94 | my $bin = $obj->binarylist(); | ||
| 95 | |||
| 96 | =cut | ||
| 97 | |||
| 98 | sub binarylist { | ||
| 99 | my ($self) = @_; | ||
| 100 | |||
| 101 | $self->api_path('/build/' | ||
| 102 | . join | ||
| 103 | q{/}, | ||
| 104 | $self->project, | ||
| 105 | $self->repository, | ||
| 106 | $self->arch, | ||
| 107 | $self->package, | ||
| 108 | ); | ||
| 109 | |||
| 110 | my $binarylist = $self->request(GET=>$self->api_path); | ||
| 111 | |||
| 112 | my $dtd = Net::OBS::Client::DTD->new()->binarylist(); | ||
| 113 | |||
| 114 | return XMLin($dtd, $binarylist)->{binary}; | ||
| 115 | } | ||
| 116 | |||
| 117 | =head2 fileinfo - get detailed information about a specific package | ||
| 118 | |||
| 119 | my $bin = $obj->fileinfo($filename); | ||
| 120 | |||
| 121 | =cut | ||
| 122 | |||
| 123 | sub fileinfo { | ||
| 124 | my ($self, $binary) = @_; | ||
| 125 | |||
| 126 | # /build/OBS:Server:Unstable/images/x86_64/OBS-Appliance-qcow2/obs-server.x86_64-2.5.51-Build6.4.qcow2?view=fileinfo | ||
| 127 | # | ||
| 128 | $self->api_path('/build/' | ||
| 129 | . join | ||
| 130 | q{/}, | ||
| 131 | $self->project, | ||
| 132 | $self->repository, | ||
| 133 | $self->arch, | ||
| 134 | $self->package, | ||
| 135 | $binary, | ||
| 136 | . '?view=fileinfo' | ||
| 137 | ); | ||
| 138 | |||
| 139 | my $binarylist = $self->request(GET=>$self->api_path); | ||
| 140 | |||
| 141 | my $dtd = Net::OBS::Client::DTD->new()->fileinfo(); | ||
| 142 | |||
| 143 | return XMLin($dtd, $binarylist); | ||
| 144 | } | ||
| 145 | |||
| 146 | __PACKAGE__->meta->make_immutable(); | ||
| 147 | |||
| 148 | =head1 AUTHOR | ||
| 149 | |||
| 150 | Frank Schreiner, C<< <frank at samaxi.de> >> | ||
| 151 | |||
| 152 | =head1 SEE ALSO | ||
| 153 | |||
| 154 | You can find some examples in the L<contrib/> directory | ||
| 155 | |||
| 156 | |||
| 157 | =head1 COPYRIGHT | ||
| 158 | |||
| 159 | Copyright 2016 Frank Schreiner <frank@samaxi.de> | ||
| 160 | |||
| 161 | This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||
| 162 | |||
| 163 | =cut | ||
| 164 | |||
| 165 | 1; | ||