NAME
Marathon - An object-oriented Mapper for the Marathon REST API
VERSION
Version 0.9
SYNOPSIS
This module is a wrapper around the [Marathon REST API](http://mesosphere.github.io/marathon/docs/rest-api.html), so it can be used without having to write JSON by hand.
For the most common tasks, there is a helper method in the main module. Some additional metods are found in the Marathon::App etc. submodules.
To start, create a marathon object:
my $m = Marathon->new( url => 'http://my.marathon.here:8080' );
my $app = $m->get_app('hello-marathon');
$app->instances( 23 );
$app->update();
print STDERR Dumper( $app->deployments );
sleep 10;
$app->instances( 1 );
$app->update( {force => 'true'} ); # should work even if the scaling up is not done yet.
Please report [issues on github](https://github.com/geidies/perl-Marathon)
SUBROUTINES/METHODS
new
Creates a Marathon object. You can pass in the URL to the marathon REST interface:
use Marathon;
my $marathon = Marathon->new( url => 'http://169.254.47.11:8080', verbose => 0 );
The "verbose" parameter makes the module more chatty on STDERR.
get_app( $id )
Returns a Marathon::App as identified by the single argument "id". In case there is no such app, will return undef.
my $app = $marathon->get_app('such-1');
print $app->id . "\n";
new_app( $config )
Returns a new Marathon::App as described in the $config hash. Example:
my $app = $marathon->new_app({ id => 'very-1', mem => 4, cpus => 0.1, cmd => "while [ 1 ]; do echo 'wow.'; done" });
This will not (!) start the app in marathon. To do so, call create() on the returned object:
$app->create();
get_group( $id )
Works like get_app, just for groups.
new_group( $config )
Creates a new group. You can either specify the apps in-line:
my $group = $marathon->new_group( { id => 'very-1', apps: [{ id => "such-2", cmd => ... }, { id => "such-3", cmd => ... }] } );
Or add them to the created group later:
my $group = $marathon->new_group( { id => 'very-1' } );
$group->add( $marathon->new_app( { id => "such-2", cmd => ... } );
$group->add( $marathon->new_app( { id => "such-3", cmd => ... } );
In any case, new_group will just return a Marathon::Group object, it will not commit to marathon until you call create() on the returned object:
$group->create();
events()
Returns a Marathon::Events objects. You can register callbacks on it and start listening to the events stream.
get_tasks( $status )
Returns an array of currently running tasks. If $status is "running" or "staging", will filter and return only those tasks.
kill_tasks({ tasks => $@ids, scale => bool })
Kills the tasks with the given @ids. Scales if the scale param is true.
get_deployments
Returns a list of Marathon::Deployment objects with the currently running deployments.
kill_deployment( $id, { force => bool } )
Stop the deployment with given id.
metrics
returns the metrics returned by the /metrics endpoint, converted from json to perl.
help
returns the html returned by the /help endpoint.
logging
returns the html returned by the /logging endpoint.
ping
returns 1 if the master responds to a ping request.
AUTHOR
Sebastian Geidies, <seb at geidi.es>
BUGS
Please report [issues on github](https://github.com/geidies/perl-Marathon)
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Marathon
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
Copyright 2015 Sebastian Geidies.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.