File Coverage

blib/lib/API/Docker/API/Exec.pm
Criterion Covered Total %
statement 9 26 34.6
branch 0 18 0.0
condition n/a
subroutine 3 7 42.8
pod 4 4 100.0
total 16 55 29.0


line stmt bran cond sub pod time code
1             package API::Docker::API::Exec;
2             # ABSTRACT: Docker Engine Exec API
3             our $VERSION = '0.001';
4 7     7   40 use Moo;
  7         9  
  7         38  
5 7     7   2229 use Carp qw( croak );
  7         13  
  7         389  
6 7     7   40 use namespace::clean;
  7         9  
  7         34  
7              
8              
9             has client => (
10             is => 'ro',
11             required => 1,
12             weak_ref => 1,
13             );
14              
15              
16             sub create {
17 0     0 1   my ($self, $container_id, %config) = @_;
18 0 0         croak "Container ID required" unless $container_id;
19 0 0         croak "Cmd required" unless $config{Cmd};
20 0           return $self->client->post("/containers/$container_id/exec", \%config);
21             }
22              
23              
24             sub start {
25 0     0 1   my ($self, $exec_id, %opts) = @_;
26 0 0         croak "Exec ID required" unless $exec_id;
27             my $body = {
28             Detach => $opts{Detach} ? \1 : \0,
29 0 0         Tty => $opts{Tty} ? \1 : \0,
    0          
30             };
31 0           return $self->client->post("/exec/$exec_id/start", $body);
32             }
33              
34              
35             sub resize {
36 0     0 1   my ($self, $exec_id, %opts) = @_;
37 0 0         croak "Exec ID required" unless $exec_id;
38 0           my %params;
39 0 0         $params{h} = $opts{h} if defined $opts{h};
40 0 0         $params{w} = $opts{w} if defined $opts{w};
41 0           return $self->client->post("/exec/$exec_id/resize", undef, params => \%params);
42             }
43              
44              
45             sub inspect {
46 0     0 1   my ($self, $exec_id) = @_;
47 0 0         croak "Exec ID required" unless $exec_id;
48 0           return $self->client->get("/exec/$exec_id/json");
49             }
50              
51              
52              
53             1;
54              
55             __END__