API-Docker

 view release on metacpan or  search on metacpan

lib/API/Docker/Role/Entity/Network.pm  view on Meta::CPAN

Unlike containers and images, a network has B<one> shape. The swagger answers
both C<GET /networks> -- an array of them -- and C<GET /networks/{id}> with
the same C<Network> definition, so L<API::Docker::API::Networks/list> and
L<API::Docker::API::Networks/inspect> hand back the same class and nothing
here has to tell two apart. What can still differ between the two calls is
which fields the engine fills in, not which fields exist -- no network in
F<t/fixtures/networks_list.json> carries C<Containers> at all, and a field
the engine omits reads as C<undef> rather than as a shape of its own.

Every method here forwards to L<API::Docker::API::Networks> with the
network's own C<id> and returns whatever that method returns; the options are
that method's options, undocumented here on purpose so there is one place to
correct when the engine's are found to be something else.

Why the methods are a role applied to a generated class rather than a class
of their own: L<API::Docker::Role::Entity/DESCRIPTION>.

=head2 inspect

    my $fresh = $network->inspect;

Get fresh network information. Returns another
L<API::Docker::Type::Network> -- the same class, since the daemon describes a
network one way.

=head2 remove

    $network->remove;

Remove the network.

=head2 connect

    $network->connect(Container => $container_id);

Connect a container to this network.

=head2 disconnect

    $network->disconnect(Container => $container_id, Force => 1);

Disconnect a container from this network.

=head1 SEE ALSO

=over

=item * L<API::Docker::API::Networks> - the operations these forward to

=item * L<API::Docker::Type::Network> - the fields C<list> and C<inspect>
return

=item * L<API::Docker::Role::Entity> - why the methods live in a role

=back

=head1 SUPPORT

=head2 Issues

Please report bugs and feature requests on GitHub at
L<https://github.com/Getty/p5-api-docker/issues>.

=head1 CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

=head1 AUTHOR

Torsten Raudssus <getty@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 1.192 second using v1.01-cache-2.11-cpan-364913b4093 )