* Start of a JSON API to get information about a specific build.
E.g. http://server/build/1341335/api/get-info returns a JSON record containing information about the build.
This commit is contained in:
parent
d72538e641
commit
d8a7ca67f4
1
deps.nix
1
deps.nix
|
@ -11,6 +11,7 @@ with pkgs;
|
|||
perlPackages.CatalystViewTT
|
||||
perlPackages.CatalystEngineHTTPPrefork
|
||||
perlPackages.CatalystViewDownload
|
||||
perlPackages.CatalystViewJSON
|
||||
perlPackages.XMLSimple
|
||||
perlPackages.IPCRun
|
||||
perlPackages.IOCompressBzip2
|
||||
|
|
|
@ -43,7 +43,13 @@ __PACKAGE__->config(
|
|||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
'View::JSON' => {
|
||||
expose_stash => qr/^json/,
|
||||
},
|
||||
'Plugin::Session' => {
|
||||
expires => 3600 * 24 * 2,
|
||||
},
|
||||
);
|
||||
|
||||
__PACKAGE__->setup();
|
||||
|
|
|
@ -11,6 +11,8 @@ use JSON::Any;
|
|||
use DateTime;
|
||||
use Digest::SHA qw(sha256_hex);
|
||||
|
||||
# !!! Rewrite this to use View::JSON.
|
||||
|
||||
sub api : Chained('/') PathPart('api') CaptureArgs(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->response->content_type('application/json');
|
||||
|
@ -163,16 +165,6 @@ sub nrrunning : Chained('api') PathPart('nrrunning') Args(0) {
|
|||
$c->forward('Hydra::View::Plain');
|
||||
}
|
||||
|
||||
sub ts {
|
||||
my ($nr, $period) = @_;
|
||||
my @arr ;
|
||||
|
||||
|
||||
|
||||
|
||||
return @arr;
|
||||
}
|
||||
|
||||
sub nrbuilds : Chained('api') PathPart('nrbuilds') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
my $nr = $c->request->params->{nr} ;
|
||||
|
|
|
@ -10,6 +10,7 @@ use File::stat;
|
|||
use Data::Dump qw(dump);
|
||||
use Nix;
|
||||
|
||||
|
||||
sub build : Chained('/') PathPart CaptureArgs(1) {
|
||||
my ($self, $c, $id) = @_;
|
||||
|
||||
|
@ -29,6 +30,7 @@ sub build : Chained('/') PathPart CaptureArgs(1) {
|
|||
$c->stash->{project} = $c->stash->{build}->project;
|
||||
}
|
||||
|
||||
|
||||
sub view_build : Chained('build') PathPart('') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
|
@ -215,6 +217,7 @@ sub download_by_type : Chained('build') PathPart('download-by-type') {
|
|||
$c->res->redirect(defaultUriForProduct($self, $c, $product, @path));
|
||||
}
|
||||
|
||||
|
||||
sub contents : Chained('build') PathPart Args(1) {
|
||||
my ($self, $c, $productnr) = @_;
|
||||
|
||||
|
@ -308,6 +311,7 @@ sub buildtimedeps : Chained('build') PathPart('buildtime-deps') {
|
|||
$c->res->content_type('image/png'); # !!!
|
||||
}
|
||||
|
||||
|
||||
sub deps : Chained('build') PathPart('deps') {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
|
@ -539,4 +543,15 @@ sub clone_submit : Chained('build') PathPart('clone/submit') Args(0) {
|
|||
}
|
||||
|
||||
|
||||
sub get_info : Chained('build') PathPart('api/get-info') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
my $build = $c->stash->{build};
|
||||
# !!! strip the json prefix
|
||||
$c->stash->{jsonBuildId} = $build->id;
|
||||
$c->stash->{jsonDrvPath} = $build->drvpath;
|
||||
$c->stash->{jsonOutPath} = $build->outpath;
|
||||
$c->forward('View::JSON');
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
3
src/lib/Hydra/View/JSON.pm
Normal file
3
src/lib/Hydra/View/JSON.pm
Normal file
|
@ -0,0 +1,3 @@
|
|||
package Hydra::View::JSON;
|
||||
use base qw(Catalyst::View::JSON);
|
||||
1;
|
Loading…
Reference in a new issue