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