| 1 | package WWW::Gitea::API::Repos; | ||||||||||||
| 2 | |||||||||||||
| 3 | # ABSTRACT: Gitea repositories 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::Repo; | ||||||||||
|
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
_build_openapi_operations: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||
| 21 | return { | ||||||||||||
| 22 | 0 | 'repos.get' => { method => 'GET', path => '/repos/{owner}/{repo}' }, | |||||||||||
| 23 | 'repos.edit' => { method => 'PATCH', path => '/repos/{owner}/{repo}' }, | ||||||||||||
| 24 | 'repos.delete' => { method => 'DELETE', path => '/repos/{owner}/{repo}' }, | ||||||||||||
| 25 | 'repos.search' => { method => 'GET', path => '/repos/search' }, | ||||||||||||
| 26 | 'repos.fork' => { method => 'POST', path => '/repos/{owner}/{repo}/forks' }, | ||||||||||||
| 27 | 'repos.create_current' => { method => 'POST', path => '/user/repos' }, | ||||||||||||
| 28 | 'repos.create_org' => { method => 'POST', path => '/orgs/{org}/repos' }, | ||||||||||||
| 29 | 'repos.list_current' => { method => 'GET', path => '/user/repos' }, | ||||||||||||
| 30 | 'repos.list_user' => { method => 'GET', path => '/users/{username}/repos' }, | ||||||||||||
| 31 | }; | ||||||||||||
| 32 | }, | ||||||||||||
| 33 | 5 | ); | |||||||||||
| 34 | |||||||||||||
| 35 | |||||||||||||
| 36 | 5 | with 'WWW::Gitea::Role::OpenAPI'; | |||||||||||
| 37 | |||||||||||||
| 38 | 0 | ▶ | sub _wrap { | ||||||||||
|
Subroutine
_wrap: not called CC=1 SCAR=6.9
| |||||||||||||
| 39 | 0 | my ($self, $data) = @_; | |||||||||||
| 40 | 0 | return WWW::Gitea::Repo->new(client => $self->client, data => $data); | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 0 | ▶ | sub get { | ||||||||||
|
Subroutine
get: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 44 | 0 | my ($self, $owner, $repo) = @_; | |||||||||||
| 45 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | 0 | my $data = $self->call_operation('repos.get', | |||||||||||
| 48 | path => { owner => $owner, repo => $repo }); | ||||||||||||
| 49 | 0 | return $self->_wrap($data); | |||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | |||||||||||||
| 53 | 0 | ▶ | sub create { | ||||||||||
|
Subroutine
create: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 54 | 0 | my ($self, %args) = @_; | |||||||||||
| 55 | 0 | ▶ | croak 'name required' unless defined $args{name}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 56 | 0 | my $org = delete $args{org}; | |||||||||||
| 57 | 0 | my $body = { %args }; | |||||||||||
| 58 | 0 | my $data; | |||||||||||
| 59 | 0 | ▶ | if (defined $org) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 60 | 0 | $data = $self->call_operation('repos.create_org', | |||||||||||
| 61 | path => { org => $org }, body => $body); | ||||||||||||
| 62 | } | ||||||||||||
| 63 | else { | ||||||||||||
| 64 | 0 | $data = $self->call_operation('repos.create_current', body => $body); | |||||||||||
| 65 | } | ||||||||||||
| 66 | 0 | return $self->_wrap($data); | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | |||||||||||||
| 70 | 0 | ▶ | sub edit { | ||||||||||
|
Subroutine
edit: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 71 | 0 | my ($self, $owner, $repo, %args) = @_; | |||||||||||
| 72 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 73 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 74 | 0 | my $data = $self->call_operation('repos.edit', | |||||||||||
| 75 | path => { owner => $owner, repo => $repo }, body => \%args); | ||||||||||||
| 76 | 0 | return $self->_wrap($data); | |||||||||||
| 77 | } | ||||||||||||
| 78 | |||||||||||||
| 79 | |||||||||||||
| 80 | 0 | ▶ | sub delete { | ||||||||||
|
Subroutine
delete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 81 | 0 | my ($self, $owner, $repo) = @_; | |||||||||||
| 82 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 83 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 84 | 0 | return $self->call_operation('repos.delete', | |||||||||||
| 85 | path => { owner => $owner, repo => $repo }); | ||||||||||||
| 86 | } | ||||||||||||
| 87 | |||||||||||||
| 88 | |||||||||||||
| 89 | 0 | ▶ | sub search { | ||||||||||
|
Subroutine
search: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 90 | 0 | my ($self, %query) = @_; | |||||||||||
| 91 | 0 | my $data = $self->call_operation('repos.search', query => \%query); | |||||||||||
| 92 | 0 | ▶ | return [ map { $self->_wrap($_) } @{ $data->{data} || [] } ]; | ||||||||||
|
Condition0%0/2
$data->{'data'} || []
MC/DC0%0/1
$data->{'data'} || []
$data->{'data'}
Truth table0%0/2
A
A= $data->{'data'}
| |||||||||||||
| 93 | } | ||||||||||||
| 94 | |||||||||||||
| 95 | |||||||||||||
| 96 | 0 | ▶ | sub fork { | ||||||||||
|
Subroutine
fork: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 97 | 0 | my ($self, $owner, $repo, %args) = @_; | |||||||||||
| 98 | 0 | ▶ | croak 'owner required' unless defined $owner; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 99 | 0 | ▶ | croak 'repo required' unless defined $repo; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 100 | 0 | my $data = $self->call_operation('repos.fork', | |||||||||||
| 101 | path => { owner => $owner, repo => $repo }, body => \%args); | ||||||||||||
| 102 | 0 | return $self->_wrap($data); | |||||||||||
| 103 | } | ||||||||||||
| 104 | |||||||||||||
| 105 | |||||||||||||
| 106 | 0 | ▶ | sub list { | ||||||||||
|
Subroutine
list: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 107 | 0 | my ($self, %args) = @_; | |||||||||||
| 108 | 0 | my $username = delete $args{username}; | |||||||||||
| 109 | 0 | my $data; | |||||||||||
| 110 | 0 | ▶ | if (defined $username) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 111 | 0 | $data = $self->call_operation('repos.list_user', | |||||||||||
| 112 | path => { username => $username }, query => \%args); | ||||||||||||
| 113 | } | ||||||||||||
| 114 | else { | ||||||||||||
| 115 | 0 | $data = $self->call_operation('repos.list_current', query => \%args); | |||||||||||
| 116 | } | ||||||||||||
| 117 | 0 | ▶ | return [ map { $self->_wrap($_) } @{ $data || [] } ]; | ||||||||||
|
Condition0%0/2
$data || []
MC/DC0%0/1
$data || []
$data
Truth table0%0/2
A
A= $data
| |||||||||||||
| 118 | } | ||||||||||||
| 119 | |||||||||||||
| 120 | |||||||||||||
| 121 | |||||||||||||
| 122 | 5 | 1; | |||||||||||
| 123 | |||||||||||||
| 124 | __END__ | ||||||||||||