| 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::Package; | ||
| 18 | |||
| 19 | =head1 NAME | ||
| 20 | |||
| 21 | Net::OBS::Client::Package - fetch package information | ||
| 22 | |||
| 23 | =head1 SYONPSIS | ||
| 24 | |||
| 25 | use Net::OBS::Client::Package; | ||
| 26 | |||
| 27 | my $obj = Net::OBS::Client::Package->new( | ||
| 28 | project => 'OBS:Server:Unstable', | ||
| 29 | name => 'obs-server', | ||
| 30 | repository => 'openSUSE_Factory', | ||
| 31 | arch => 'x86_64', | ||
| 32 | use_oscrc => 0, | ||
| 33 | apiurl => 'https://api.opensuse.org/public' | ||
| 34 | ); | ||
| 35 | |||
| 36 | my $s = $obj->fetch_status(); | ||
| 37 | |||
| 38 | print "code: ".$p->code($repo, $arch)."\n"; | ||
| 39 | |||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 44 | 0 | ▶ | use XML::Structured; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 45 | |||
| 46 | # define roles | ||
| 47 | with 'Net::OBS::Client::Roles::BuildStatus'; | ||
| 48 | with 'Net::OBS::Client::Roles::Client'; | ||
| 49 | |||
| 50 | =head1 ATTRIBUTES | ||
| 51 | |||
| 52 | =head2 project | ||
| 53 | |||
| 54 | =head2 repository | ||
| 55 | |||
| 56 | =head2 arch | ||
| 57 | |||
| 58 | =head2 details | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | has details => ( | ||
| 63 | is => 'rw', | ||
| 64 | isa => 'Str' | ||
| 65 | ); | ||
| 66 | |||
| 67 | has _status => ( | ||
| 68 | is => 'rw', | ||
| 69 | isa => 'HashRef', | ||
| 70 | lazy => 1, | ||
| 71 | default => \&fetch_status, | ||
| 72 | ); | ||
| 73 | |||
| 74 | =head1 SUBROUTINES/METHODS | ||
| 75 | |||
| 76 | =head2 fetch_status - | ||
| 77 | |||
| 78 | my $s = $ojb->fetch_status(); | ||
| 79 | |||
| 80 | =cut | ||
| 81 | |||
| 82 | sub fetch_status { | ||
| 83 | my ($self, @args) = @_; | ||
| 84 | |||
| 85 | my $api_path = join q{/}, '/build', $self->project, $self->repository, $self->arch, $self->name, '_status'; | ||
| 86 | |||
| 87 | my $list = $self->request(GET=>$api_path); | ||
| 88 | |||
| 89 | my $data = XMLin($self->dtd->buildstatus,$list); | ||
| 90 | |||
| 91 | return $data; | ||
| 92 | } | ||
| 93 | |||
| 94 | =head2 code - get package build code | ||
| 95 | |||
| 96 | my $c = $obj->code; | ||
| 97 | |||
| 98 | =cut | ||
| 99 | |||
| 100 | sub code { | ||
| 101 | my ($self) = @_; | ||
| 102 | return $self->_status->{code}; | ||
| 103 | } | ||
| 104 | |||
| 105 | |||
| 106 | __PACKAGE__->meta->make_immutable(); | ||
| 107 | |||
| 108 | =head1 AUTHOR | ||
| 109 | |||
| 110 | Frank Schreiner, C<< <frank at samaxi.de> >> | ||
| 111 | |||
| 112 | =head1 SEE ALSO | ||
| 113 | |||
| 114 | You can find some examples in the L<contrib/> directory | ||
| 115 | |||
| 116 | |||
| 117 | =head1 COPYRIGHT | ||
| 118 | |||
| 119 | Copyright 2016 Frank Schreiner <frank@samaxi.de> | ||
| 120 | |||
| 121 | This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||
| 122 | |||
| 123 | =cut | ||
| 124 | |||
| 125 | 1; | ||
| 126 | |||