API-Docker

 view release on metacpan or  search on metacpan

t/timeout_forwarding.t  view on Meta::CPAN

    'images' => sub { $_[0]->commit(container => 'c1') } ],
  [ 'images->build_prune', 'POST /build/prune',
    'images' => sub { $_[0]->build_prune } ],

  # -- networks ------------------------------------------------------------
  [ 'networks->list', 'GET /networks',
    'networks' => sub { $_[0]->list } ],
  [ 'networks->inspect', 'GET /networks/n1',
    'networks' => sub { $_[0]->inspect('n1') } ],
  [ 'networks->remove', 'DELETE /networks/n1',
    'networks' => sub { $_[0]->remove('n1') } ],
  [ 'networks->prune', 'POST /networks/prune',
    'networks' => sub { $_[0]->prune } ],

  # -- volumes -------------------------------------------------------------
  [ 'volumes->list', 'GET /volumes',
    'volumes' => sub { $_[0]->list } ],
  [ 'volumes->inspect', 'GET /volumes/v1',
    'volumes' => sub { $_[0]->inspect('v1') } ],
  [ 'volumes->remove', 'DELETE /volumes/v1',
    'volumes' => sub { $_[0]->remove('v1') } ],
  [ 'volumes->prune', 'POST /volumes/prune',
    'volumes' => sub { $_[0]->prune } ],

  # -- secrets -------------------------------------------------------------
  [ 'secrets->list', 'GET /secrets',
    'secrets' => sub { $_[0]->list } ],
  [ 'secrets->inspect', 'GET /secrets/s1',
    'secrets' => sub { $_[0]->inspect('s1') } ],
  [ 'secrets->remove', 'DELETE /secrets/s1',
    'secrets' => sub { $_[0]->remove('s1') } ],

  # -- configs -------------------------------------------------------------
  [ 'configs->list', 'GET /configs',
    'configs' => sub { $_[0]->list } ],
  [ 'configs->inspect', 'GET /configs/cf1',
    'configs' => sub { $_[0]->inspect('cf1') } ],
  [ 'configs->remove', 'DELETE /configs/cf1',
    'configs' => sub { $_[0]->remove('cf1') } ],

  # -- exec ----------------------------------------------------------------
  [ 'exec->start', 'POST /exec/e1/start',
    'exec' => sub { $_[0]->start('e1') } ],
  [ 'exec->resize', 'POST /exec/e1/resize',
    'exec' => sub { $_[0]->resize('e1', h => 40, w => 120) } ],
  [ 'exec->inspect', 'GET /exec/e1/json',
    'exec' => sub { $_[0]->inspect('e1') } ],

  # -- system --------------------------------------------------------------
  [ 'system->info', 'GET /info',
    'system' => sub { $_[0]->info } ],
  [ 'system->version', 'GET /version',
    'system' => sub { $_[0]->version } ],
  [ 'system->ping', 'GET /_ping',
    'system' => sub { $_[0]->ping } ],
  [ 'system->events', 'GET /events',
    'system' => sub { $_[0]->events } ],
  [ 'system->df', 'GET /system/df',
    'system' => sub { $_[0]->df } ],
  [ 'system->auth', 'POST /auth',
    'system' => sub { $_[0]->auth(username => 'u', password => 'p') } ],

  # -- plugins -------------------------------------------------------------
  [ 'plugins->list', 'GET /plugins',
    'plugins' => sub { $_[0]->list } ],
  [ 'plugins->privileges', 'GET /plugins/privileges',
    'plugins' => sub { $_[0]->privileges('p') } ],
  [ 'plugins->install', 'POST /plugins/pull',
    'plugins' => sub { $_[0]->install('p', privileges => []) } ],
  [ 'plugins->install privileges pre-flight', 'GET /plugins/privileges',
    'plugins' => sub { $_[0]->install('p', accept_privileges => 1) } ],
  [ 'plugins->inspect', 'GET /plugins/p/json',
    'plugins' => sub { $_[0]->inspect('p') } ],
  [ 'plugins->remove', 'DELETE /plugins/p',
    'plugins' => sub { $_[0]->remove('p') } ],
  [ 'plugins->enable', 'POST /plugins/p/enable',
    'plugins' => sub { $_[0]->enable('p') } ],
  [ 'plugins->disable', 'POST /plugins/p/disable',
    'plugins' => sub { $_[0]->disable('p') } ],
  [ 'plugins->upgrade', 'POST /plugins/p/upgrade',
    'plugins' => sub { $_[0]->upgrade('p', privileges => []) } ],
  [ 'plugins->upgrade privileges pre-flight', 'GET /plugins/privileges',
    'plugins' => sub { $_[0]->upgrade('p', accept_privileges => 1) } ],
  [ 'plugins->push', 'POST /plugins/p/push',
    'plugins' => sub { $_[0]->push('p') } ],
  [ 'plugins->configure', 'POST /plugins/p/set',
    'plugins' => sub { $_[0]->configure('p', ['A=1']) } ],

  # -- distribution --------------------------------------------------------
  [ 'distribution->inspect', 'GET /distribution/alpine/json',
    'distribution' => sub { $_[0]->inspect('alpine') } ],
  [ 'distribution->exists', 'GET /distribution/alpine/json',
    'distribution' => sub { $_[0]->exists('alpine') } ],
);

# The option list the named endpoint was requested with, or a string saying
# why there is none -- which is_deeply then reports instead of an empty hash.
# @using is what the resource class is cloned with; empty means it is used as
# it comes off the client.
sub opts_for {
  my ($case, @using) = @_;
  my (undef, $want, $accessor, $code) = @$case;

  my $probe = Test::TimeoutForward::Probe->new(
    host => 'unix:///nonexistent-api-docker-74.sock', api_version => '1.41');

  my $resource = $probe->$accessor;
  $resource = $resource->using(@using) if @using;

  eval { $code->($resource); 1 }
    or return 'the call died before requesting anything: ' . $@;

  my @seen;
  for my $call (@{ $probe->calls }) {
    my $endpoint = $call->{method} . ' ' . $call->{path};
    push @seen, $endpoint;
    return $call->{opts} if $endpoint eq $want;
  }
  return "never requested $want (requested: " . join(', ', @seen) . ')';
}



( run in 2.606 seconds using v1.01-cache-2.11-cpan-f5f21f1076c )