File: Actions.pm

package info (click to toggle)
libnet-github-perl 1.05-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 376 kB
  • sloc: perl: 2,073; makefile: 8
file content (158 lines) | stat: -rw-r--r-- 4,218 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package Net::GitHub::V3::Actions;

use Moo;

our $VERSION   = '1.05';
our $AUTHORITY = 'cpan:FAYLAND';

use Carp;
use URI::Escape;
use URI;
use HTTP::Request::Common qw(POST);

with 'Net::GitHub::V3::Query';

## build methods on fly
my %__methods = (

    ### -------------------------------------------------------------------------------
    ### Artifacts
    ### -------------------------------------------------------------------------------

    # List artifacts for a repository
    artifacts => { v => 2,  url => '/repos/:owner/:repo/actions/artifacts', method => 'GET', paginate => 1 },

    # List workflow run artifacts
    # GET /repos/:owner/:repo/actions/runs/:run_id/artifacts
    run_artifacts => { v => 2, url => '/repos/:owner/:repo/actions/runs/:run_id/artifacts', method => 'GET', paginate => 1 },

    # Get an artifact
    # GET /repos/:owner/:repo/actions/artifacts/:artifact_id
    artifact => {  v => 2, url => '/repos/:owner/:repo/actions/artifacts/:artifact_id', method => 'GET' },

    ### -------------------------------------------------------------------------------
    ### Workflows - https://developer.github.com/v3/actions/workflows/
    ### -------------------------------------------------------------------------------

    # List repository workflows
    # GET /repos/:owner/:repo/actions/workflows
    workflows => { v => 2, url => '/repos/:owner/:repo/actions/workflows', method => 'GET', paginate => 1 },

    # Get a workflow
    # GET /repos/:owner/:repo/actions/workflows/:workflow_id
    workflow => {  v => 2, url => '/repos/:owner/:repo/actions/workflows/:workflow_id', method => 'GET' },

    ### -------------------------------------------------------------------------------
    ### Workflow Jobs - https://developer.github.com/v3/actions/workflow-jobs/
    ### -------------------------------------------------------------------------------

    # List jobs for a workflow run
    # GET /repos/:owner/:repo/actions/runs/:run_id/jobs pagination
    jobs => {  v => 2, url => '/repos/:owner/:repo/actions/runs/:run_id/jobs', method => 'GET', paginate => 1 },

    # Get a workflow job
    # GET /repos/:owner/:repo/actions/jobs/:job_id
    job => {  v => 2, url => '/repos/:owner/:repo/actions/jobs/:job_id', method => 'GET' },

    ### -------------------------------------------------------------------------------
    ### Workflow Runs - https://developer.github.com/v3/actions/workflow-runs/
    ### -------------------------------------------------------------------------------

    runs => { v => 2, url => '/repos/:owner/:repo/actions/workflows/:workflow_id/runs', method => 'GET', paginate => 1 },

    # ...
);
__build_methods( __PACKAGE__, %__methods );

no Moo;

1;
__END__

=head1 NAME

Net::GitHub::V3::Actions - GitHub Actions API

=head1 SYNOPSIS

    use Net::GitHub::V3;

    my $gh = Net::GitHub::V3->new; # read L<Net::GitHub::V3> to set right authentication info
    my $actions = $gh->actions;

    # set :user/:repo for simple calls
    $actions->set_default_user_repo('fayland', 'perl-net-github');

    $actions->workflows();
    $actions->workflows( { owner => 'xxx', repo => 'repo' } );


=head1 DESCRIPTION

=head2 METHODS

=head3 GitHub Actions

L<https://developer.github.com/v3/actions/>

=head3 Artifacts

L<https://developer.github.com/v3/actions/artifacts/>

=over 4

=item artifacts

List artifacts for a repository

    $actions->artifacts( { owner => 'xxx', repo => 'repo' } );

=item run_artifacts

    $actions->run_artifacts( { owner => 'xxx', repo => 'repo', run_id => XXX } );

=item artifact

    $actions->artifacts( { owner => 'xxx', repo => 'repo', artifact_id => 'ID' } );

=back

=head3 Workflows

L<https://developer.github.com/v3/actions/workflows/>

=over 4

=item workflows

List repository workflows

    $actions->workflows( { owner => 'xxx', repo => 'repo' } );

=item workflow

Get a workflow

    $actions->workflow( { owner => 'xxx', repo => 'repo', workflow_id => 1234 } );

=back

=head3 Workflow Jobs

L<https://developer.github.com/v3/actions/workflow-jobs/>

=over 4

=item jobs

List jobs for a workflow run

=item job

Get a workflow job

=back

=head1 AUTHOR & COPYRIGHT & LICENSE

Refer L<Net::GitHub>