| 1 | # | ||
| 2 | # This file is part of Net-Gandi | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2012 by Natal Ngétal. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | package Net::Gandi::Hosting::Image; | ||
| 10 | { | ||
| 11 | $Net::Gandi::Hosting::Image::VERSION = '1.122180'; | ||
| 12 | } | ||
| 13 | |||
| 14 | # ABSTRACT: Disk image interface | ||
| 15 | |||
| 16 | use Moose; | ||
| 17 | use MooseX::Params::Validate; | ||
| 18 | use namespace::autoclean; | ||
| 19 | |||
| 20 | use Net::Gandi::Types Client => { -as => 'Client_T' }; | ||
| 21 | |||
| 22 | use Carp; | ||
| 23 | |||
| 24 | |||
| 25 | has 'id' => ( is => 'rw', isa => 'Int' ); | ||
| 26 | |||
| 27 | has client => ( | ||
| 28 | is => 'rw', | ||
| 29 | isa => Client_T, | ||
| 30 | required => 1, | ||
| 31 | ); | ||
| 32 | |||
| 33 | |||
| 34 | sub list { | ||
| 35 | my ( $self, $params ) = validated_list( | ||
| 36 | \@_, | ||
| 37 | opts => { isa => 'HashRef', optional => 1 } | ||
| 38 | ); | ||
| 39 | |||
| 40 | $params ||= {}; | ||
| 41 | return $self->client->api_call( 'image.list', $params ); | ||
| 42 | } | ||
| 43 | |||
| 44 | |||
| 45 | sub info { | ||
| 46 | my ( $self ) = @_; | ||
| 47 | |||
| 48 | carp 'Required parameter id is not defined' if ( ! $self->id ); | ||
| 49 | return $self->client->api_call( 'image.info', $self->id ); | ||
| 50 | } | ||
| 51 | |||
| 52 | no Moose; | ||
| 53 | __PACKAGE__->meta->make_immutable; | ||
| 54 | |||
| 55 | 1; | ||
| 56 | |||
| 57 | __END__ |