| 1 | package WWW::Gitea::API::Labels; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | # ABSTRACT: Gitea repository labels API | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 5 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 5 | ▶ | use Carp qw(croak); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 5 | ▶ | use WWW::Gitea::Label; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 5 | ▶ | use namespace::clean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | |||||||||||||||
| 11 | 5 | has client => ( | |||||||||||||
| 12 | is => 'ro', | ||||||||||||||
| 13 | required => 1, | ||||||||||||||
| 14 | weak_ref => 1, | ||||||||||||||
| 15 | ); | ||||||||||||||
| 16 | |||||||||||||||
| 17 | |||||||||||||||
| 18 | has openapi_operations => ( | ||||||||||||||
| 19 | is => 'lazy', | ||||||||||||||
| 20 | 1 | ▶ | builder => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
_build_openapi_operations: called CC=1 SCAR=0.0
| |||||||||||||||
| 21 | return { | ||||||||||||||
| 22 | 1 | 'labels.list' => { method => 'GET', path => '/repos/{owner}/{repo}/labels' }, | |||||||||||||
| 23 | 'labels.create' => { method => 'POST', path => '/repos/{owner}/{repo}/labels' }, | ||||||||||||||
| 24 | 'labels.get' => { method => 'GET', path => '/repos/{owner}/{repo}/labels/{id}' }, | ||||||||||||||
| 25 | 'labels.edit' => { method => 'PATCH', path => '/repos/{owner}/{repo}/labels/{id}' }, | ||||||||||||||
| 26 | 'labels.delete' => { method => 'DELETE', path => '/repos/{owner}/{repo}/labels/{id}' }, | ||||||||||||||
| 27 | }; | ||||||||||||||
| 28 | }, | ||||||||||||||
| 29 | 5 | ); | |||||||||||||
| 30 | |||||||||||||||
| 31 | |||||||||||||||
| 32 | 5 | with 'WWW::Gitea::Role::OpenAPI'; | |||||||||||||
| 33 | |||||||||||||||
| 34 | 0 | ▶ | sub _wrap { | ||||||||||||
|
Subroutine
_wrap: not called CC=3 SCAR=24.8
| |||||||||||||||
| 35 | 0 | my ($self, $data, $owner, $repo) = @_; | |||||||||||||
| 36 | 0 | ▶ | return WWW::Gitea::Label->new( | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 37 | client => $self->client, | ||||||||||||||
| 38 | data => $data, | ||||||||||||||
| 39 | (defined $owner ? (owner => $owner) : ()), | ||||||||||||||
| 40 | (defined $repo ? (repo => $repo) : ()), | ||||||||||||||
| 41 | ); | ||||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 2 | ▶ | sub list { | ||||||||||||
|
Subroutine
list: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||
| 45 | 2 | my ($self, $owner, $repo, %query) = @_; | |||||||||||||
| 46 | 2 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 47 | 2 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 48 | 2 | my $data = $self->call_operation('labels.list', | |||||||||||||
| 49 | path => { owner => $owner, repo => $repo }, query => \%query); | ||||||||||||||
| 50 | 0 | ▶ | return [ map { $self->_wrap($_, $owner, $repo) } @{ $data || [] } ]; | ||||||||||||
|
Condition50%1/2
$data || []
MC/DC0%0/1
$data || []
$data
Truth table50%1/2
A
A= $data
| |||||||||||||||
| 51 | } | ||||||||||||||
| 52 | |||||||||||||||
| 53 | |||||||||||||||
| 54 | 0 | ▶ | sub create { | ||||||||||||
|
Subroutine
create: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||
| 55 | 0 | my ($self, $owner, $repo, %args) = @_; | |||||||||||||
| 56 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 57 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 58 | 0 | ▶ | croak 'name required' unless defined $args{name}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 59 | 0 | ▶ | croak 'color required' unless defined $args{color}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 60 | 0 | my $data = $self->call_operation('labels.create', | |||||||||||||
| 61 | path => { owner => $owner, repo => $repo }, body => \%args); | ||||||||||||||
| 62 | 0 | return $self->_wrap($data, $owner, $repo); | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | |||||||||||||||
| 66 | 0 | ▶ | sub get { | ||||||||||||
|
Subroutine
get: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 67 | 0 | my ($self, $owner, $repo, $id) = @_; | |||||||||||||
| 68 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 69 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 70 | 0 | ▶ | croak 'id required' unless defined $id; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 71 | 0 | my $data = $self->call_operation('labels.get', | |||||||||||||
| 72 | path => { owner => $owner, repo => $repo, id => $id }); | ||||||||||||||
| 73 | 0 | return $self->_wrap($data, $owner, $repo); | |||||||||||||
| 74 | } | ||||||||||||||
| 75 | |||||||||||||||
| 76 | |||||||||||||||
| 77 | 0 | ▶ | sub edit { | ||||||||||||
|
Subroutine
edit: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 78 | 0 | my ($self, $owner, $repo, $id, %args) = @_; | |||||||||||||
| 79 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 80 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 81 | 0 | ▶ | croak 'id required' unless defined $id; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 82 | 0 | my $data = $self->call_operation('labels.edit', | |||||||||||||
| 83 | path => { owner => $owner, repo => $repo, id => $id }, body => \%args); | ||||||||||||||
| 84 | 0 | return $self->_wrap($data, $owner, $repo); | |||||||||||||
| 85 | } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | |||||||||||||||
| 88 | 0 | ▶ | sub delete { | ||||||||||||
|
Subroutine
delete: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 89 | 0 | my ($self, $owner, $repo, $id) = @_; | |||||||||||||
| 90 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 91 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 92 | 0 | ▶ | croak 'id required' unless defined $id; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 93 | 0 | return $self->call_operation('labels.delete', | |||||||||||||
| 94 | path => { owner => $owner, repo => $repo, id => $id }); | ||||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | |||||||||||||||
| 98 | |||||||||||||||
| 99 | 5 | 1; | |||||||||||||
| 100 | |||||||||||||||
| 101 | __END__ | ||||||||||||||