documentation improvements
[catagits/Catalyst-Controller-DBIC-API.git] / lib / Catalyst / Controller / DBIC / API / RPC.pm
CommitLineData
d2739840 1package Catalyst::Controller::DBIC::API::RPC;
8ea592cb 2
d2739840 3#ABSTRACT: Provides an RPC interface to DBIx::Class
4
5use Moose;
6BEGIN { extends 'Catalyst::Controller::DBIC::API'; }
7
8__PACKAGE__->config(
406086f3 9 'action' => { object_with_id => { PathPart => 'id' } },
d2739840 10 'default' => 'application/json',
11 'stash_key' => 'response',
12 'map' => {
13 'application/x-www-form-urlencoded' => 'JSON',
14 'application/json' => 'JSON',
15 },
16);
17
18=head1 DESCRIPTION
19
c0c8e1c6 20Provides an RPC API interface to the functionality described in
21L<Catalyst::Controller::DBIC::API>.
d2739840 22
23By default provides the following endpoints:
24
25 $base/create
26 $base/list
609916e5 27 $base/id/[identifier]
d2739840 28 $base/id/[identifier]/delete
29 $base/id/[identifier]/update
30
31Where $base is the URI described by L</setup>, the chain root of the controller.
32
33=method_protected setup
34
35Chained: override
36PathPart: override
37CaptureArgs: 0
38
c0c8e1c6 39As described in L<Catalyst::Controller::DBIC::API/setup>, this action is the
40chain root of the controller but has no pathpart or chain parent defined by
41default.
42
43These must be defined in order for the controller to function.
44
45The neatest way is normally to define these using the controller's config.
d2739840 46
47 __PACKAGE__->config
406086f3 48 ( action => { setup => { PathPart => 'track', Chained => '/api/rpc/rpc_base' } },
d2739840 49 ...
50 );
51
d2739840 52=cut
53
d2739840 54=method_protected create
55
533075c7 56Chained: L</objects_no_id>
d2739840 57PathPart: create
58CaptureArgs: 0
59
c0c8e1c6 60Provides an endpoint to the functionality described in
61L<Catalyst::Controller::DBIC::API/update_or_create>.
d2739840 62
63=cut
64
8ea592cb 65sub create : Chained('objects_no_id') : PathPart('create') : Args(0) {
66 my ( $self, $c ) = @_;
3d85db11 67 $self->update_or_create($c);
d2739840 68}
69
70=method_protected list
71
609916e5 72Chained: L</deserialize>
d2739840 73PathPart: list
74CaptureArgs: 0
75
c0c8e1c6 76Provides an endpoint to the functionality described in
77L<Catalyst::Controller::DBIC::API/list>.
d2739840 78
79=cut
80
8ea592cb 81sub list : Chained('deserialize') : PathPart('list') : Args(0) {
82 my ( $self, $c ) = @_;
533075c7 83 $self->next::method($c);
d2739840 84}
85
609916e5 86=method_protected item
87
88Chained: L</object_with_id>
89PathPart: ''
90Args: 0
91
c0c8e1c6 92Provides an endpoint to the functionality described in
93L<Catalyst::Controller::DBIC::API/item>.
609916e5 94
95=cut
96
8ea592cb 97sub item : Chained('object_with_id') : PathPart('') : Args(0) {
98 my ( $self, $c ) = @_;
533075c7 99 $self->next::method($c);
609916e5 100}
101
d2739840 102=method_protected update
103
609916e5 104Chained: L</object_with_id>
d2739840 105PathPart: update
609916e5 106Args: 0
d2739840 107
c0c8e1c6 108Provides an endpoint to the functionality described in
109L<Catalyst::Controller::DBIC::API/update_or_create>.
d2739840 110
111=cut
112
8ea592cb 113sub update : Chained('object_with_id') : PathPart('update') : Args(0) {
114 my ( $self, $c ) = @_;
3d85db11 115 $self->update_or_create($c);
d2739840 116}
117
118=method_protected delete
119
609916e5 120Chained: L</object_with_id>
d2739840 121PathPart: delete
609916e5 122Args: 0
d2739840 123
c0c8e1c6 124Provides an endpoint to the functionality described in
125L<Catalyst::Controller::DBIC::API/delete>.
d2739840 126
127=cut
128
8ea592cb 129sub delete : Chained('object_with_id') : PathPart('delete') : Args(0) {
130 my ( $self, $c ) = @_;
609916e5 131 $self->next::method($c);
132}
d2739840 133
609916e5 134=method_protected update_bulk
135
533075c7 136Chained: L</objects_no_id>
609916e5 137PathPart: update
138Args: 0
139
c0c8e1c6 140Provides an endpoint to the functionality described in
141L<Catalyst::Controller::DBIC::API/update_or_create> for multiple objects.
609916e5 142
143=cut
144
8ea592cb 145sub update_bulk : Chained('objects_no_id') : PathPart('update') : Args(0) {
146 my ( $self, $c ) = @_;
3d85db11 147 $self->update_or_create($c);
609916e5 148}
149
150=method_protected delete_bulk
151
533075c7 152Chained: L</objects_no_id>
609916e5 153PathPart: delete
154Args: 0
155
c0c8e1c6 156Provides an endpoint to the functionality described in
157L<Catalyst::Controller::DBIC::API/delete> for multiple objects.
609916e5 158
159=cut
160
8ea592cb 161sub delete_bulk : Chained('objects_no_id') : PathPart('delete') : Args(0) {
162 my ( $self, $c ) = @_;
a1f71064 163 $self->delete($c);
d2739840 164}
165
1661;