| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Controller::DBIC::API::REST; |
|
2
|
|
|
|
|
|
|
$Catalyst::Controller::DBIC::API::REST::VERSION = '2.008001'; |
|
3
|
|
|
|
|
|
|
#ABSTRACT: Provides a REST interface to DBIx::Class |
|
4
|
16
|
|
|
16
|
|
2728243
|
use Moose; |
|
|
16
|
|
|
|
|
48
|
|
|
|
16
|
|
|
|
|
124
|
|
|
5
|
16
|
|
|
16
|
|
104878
|
BEGIN { extends 'Catalyst::Controller::DBIC::API'; } |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->config( |
|
8
|
|
|
|
|
|
|
'default' => 'application/json', |
|
9
|
|
|
|
|
|
|
'stash_key' => 'response', |
|
10
|
|
|
|
|
|
|
'map' => { |
|
11
|
|
|
|
|
|
|
'application/x-www-form-urlencoded' => 'JSON', |
|
12
|
|
|
|
|
|
|
'application/json' => 'JSON', |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub update_or_create_objects : POST PUT Chained('objects_no_id') PathPart('') |
|
18
|
|
|
|
|
|
|
Args(0) { |
|
19
|
7
|
|
|
7
|
1
|
3087
|
my ( $self, $c ) = @_; |
|
20
|
7
|
|
|
|
|
52
|
$self->update_or_create($c); |
|
21
|
16
|
|
|
16
|
|
103773
|
} |
|
|
16
|
|
|
|
|
45
|
|
|
|
16
|
|
|
|
|
181
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub delete_many_objects : DELETE Chained('objects_no_id') PathPart('') |
|
25
|
|
|
|
|
|
|
Args(0) { |
|
26
|
1
|
|
|
1
|
1
|
485
|
my ( $self, $c ) = @_; |
|
27
|
1
|
|
|
|
|
7
|
$self->delete($c); |
|
28
|
16
|
|
|
16
|
|
20319
|
} |
|
|
16
|
|
|
|
|
50
|
|
|
|
16
|
|
|
|
|
80
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub list_objects : GET Chained('objects_no_id') PathPart('') Args(0) { |
|
32
|
24
|
|
|
24
|
1
|
10124
|
my ( $self, $c ) = @_; |
|
33
|
24
|
|
|
|
|
191
|
$self->list($c); |
|
34
|
16
|
|
|
16
|
|
16436
|
} |
|
|
16
|
|
|
|
|
43
|
|
|
|
16
|
|
|
|
|
90
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub update_or_create_one_object : POST PUT Chained('object_with_id') |
|
38
|
|
|
|
|
|
|
PathPart('') Args(0) { |
|
39
|
3
|
|
|
3
|
1
|
1384
|
my ( $self, $c ) = @_; |
|
40
|
3
|
|
|
|
|
30
|
$self->update_or_create($c); |
|
41
|
16
|
|
|
16
|
|
16409
|
} |
|
|
16
|
|
|
|
|
50
|
|
|
|
16
|
|
|
|
|
98
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub delete_one_object : DELETE Chained('object_with_id') PathPart('') Args(0) |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
1
|
|
|
1
|
1
|
618
|
my ( $self, $c ) = @_; |
|
47
|
1
|
|
|
|
|
56
|
$self->delete($c); |
|
48
|
16
|
|
|
16
|
|
16522
|
} |
|
|
16
|
|
|
|
|
44
|
|
|
|
16
|
|
|
|
|
89
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub list_one_object : GET Chained('object_with_id') PathPart('') Args(0) { |
|
52
|
2
|
|
|
2
|
1
|
1114
|
my ( $self, $c ) = @_; |
|
53
|
2
|
|
|
|
|
22
|
$self->item($c); |
|
54
|
16
|
|
|
16
|
|
16351
|
} |
|
|
16
|
|
|
|
|
62
|
|
|
|
16
|
|
|
|
|
87
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=pod |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Catalyst::Controller::DBIC::API::REST - Provides a REST interface to DBIx::Class |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 2.008001 |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Provides a REST style API interface to the functionality described in |
|
73
|
|
|
|
|
|
|
L<Catalyst::Controller::DBIC::API>. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
By default provides the following endpoints: |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$base (operates on lists of objects and accepts GET, PUT, POST and DELETE) |
|
78
|
|
|
|
|
|
|
$base/[identifier] (operates on a single object and accepts GET, PUT, POST and DELETE) |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Where $base is the URI described by L</setup>, the chain root of the controller |
|
81
|
|
|
|
|
|
|
and the request type will determine the L<Catalyst::Controller::DBIC::API> |
|
82
|
|
|
|
|
|
|
method to forward. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 PROTECTED_METHODS |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 setup |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Chained: override |
|
89
|
|
|
|
|
|
|
PathPart: override |
|
90
|
|
|
|
|
|
|
CaptureArgs: 0 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
As described in L<Catalyst::Controller::DBIC::API/setup>, this action is the |
|
93
|
|
|
|
|
|
|
chain root of the controller but has no pathpart or chain parent defined by |
|
94
|
|
|
|
|
|
|
default. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
These must be defined in order for the controller to function. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The neatest way is normally to define these using the controller's config. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__PACKAGE__->config |
|
101
|
|
|
|
|
|
|
( action => { setup => { PathPart => 'track', Chained => '/api/rest/rest_base' } }, |
|
102
|
|
|
|
|
|
|
... |
|
103
|
|
|
|
|
|
|
); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 update_or_create_objects |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Chained: L</objects_no_id> |
|
108
|
|
|
|
|
|
|
PathPart: none |
|
109
|
|
|
|
|
|
|
Args: 0 |
|
110
|
|
|
|
|
|
|
Method: POST/PUT |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Calls L<Catalyst::Controller::DBIC::API/update_or_create>. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 delete_many_objects |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Chained: L</objects_no_id> |
|
117
|
|
|
|
|
|
|
PathPart: none |
|
118
|
|
|
|
|
|
|
Args: 0 |
|
119
|
|
|
|
|
|
|
Method: DELETE |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Calls L<Catalyst::Controller::DBIC::API/delete>. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 list_objects |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Chained: L</objects_no_id> |
|
126
|
|
|
|
|
|
|
PathPart: none |
|
127
|
|
|
|
|
|
|
Args: 0 |
|
128
|
|
|
|
|
|
|
Method: GET |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Calls L<Catalyst::Controller::DBIC::API/list>. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 update_or_create_one_object |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Chained: L</object_with_id> |
|
135
|
|
|
|
|
|
|
PathPart: none |
|
136
|
|
|
|
|
|
|
Args: 0 |
|
137
|
|
|
|
|
|
|
Method: POST/PUT |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Calls L<Catalyst::Controller::DBIC::API/update_or_create>. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 delete_one_object |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Chained: L</object_with_id> |
|
144
|
|
|
|
|
|
|
PathPart: none |
|
145
|
|
|
|
|
|
|
Args: 0 |
|
146
|
|
|
|
|
|
|
Method: DELETE |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Calls L<Catalyst::Controller::DBIC::API/delete>. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 list_one_object |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Chained: L</object_with_id> |
|
153
|
|
|
|
|
|
|
PathPart: none |
|
154
|
|
|
|
|
|
|
Args: 0 |
|
155
|
|
|
|
|
|
|
Method: GET |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Calls L<Catalyst::Controller::DBIC::API/item>. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHORS |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=over 4 |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Nicholas Perez <nperez@cpan.org> |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Luke Saunders <luke.saunders@gmail.com> |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Alexander Hartmaier <abraxxa@cpan.org> |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Oleg Kostyuk <cub.uanic@gmail.com> |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Samuel Kaufman <sam@socialflow.com> |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=back |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This software is copyright (c) 2019 by Luke Saunders, Nicholas Perez, Alexander Hartmaier, et al. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
194
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |