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