| 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::IP; | ||
| 10 | { | ||
| 11 | $Net::Gandi::Hosting::IP::VERSION = '1.122180'; | ||
| 12 | } | ||
| 13 | |||
| 14 | # ABSTRACT: Ip 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 | use Net::Gandi::Error qw(_validated_params); | ||
| 22 | |||
| 23 | use Carp; | ||
| 24 | |||
| 25 | |||
| 26 | has 'id' => ( is => 'rw', isa => 'Int' ); | ||
| 27 | |||
| 28 | has client => ( | ||
| 29 | is => 'rw', | ||
| 30 | isa => Client_T, | ||
| 31 | required => 1, | ||
| 32 | ); | ||
| 33 | |||
| 34 | |||
| 35 | sub list { | ||
| 36 | my ( $self, $params ) = validated_list( | ||
| 37 | \@_, | ||
| 38 | opts => { isa => 'HashRef', optional => 1 } | ||
| 39 | ); | ||
| 40 | |||
| 41 | $params ||= {}; | ||
| 42 | return $self->client->api_call( 'ip.list', $params ); | ||
| 43 | } | ||
| 44 | |||
| 45 | |||
| 46 | sub count { | ||
| 47 | my ( $self, $params ) = validated_list( | ||
| 48 | \@_, | ||
| 49 | opts => { isa => 'HashRef', optional => 1 } | ||
| 50 | ); | ||
| 51 | |||
| 52 | $params ||= {}; | ||
| 53 | return $self->client->api_call('ip.count', $params); | ||
| 54 | } | ||
| 55 | |||
| 56 | |||
| 57 | sub info { | ||
| 58 | my ( $self ) = @_; | ||
| 59 | |||
| 60 | carp 'Required parameter id is not defined' if ( ! $self->id ); | ||
| 61 | return $self->client->api_call( 'ip.info', $self->id ); | ||
| 62 | } | ||
| 63 | |||
| 64 | |||
| 65 | sub update { | ||
| 66 | my ( $self, $params ) = validated_list( | ||
| 67 | \@_, | ||
| 68 | ip_spec => { isa => 'HashRef' } | ||
| 69 | ); | ||
| 70 | |||
| 71 | carp 'Required parameter id is not defined' if ( ! $self->id ); | ||
| 72 | _validated_params('ip_update', $params); | ||
| 73 | |||
| 74 | $params ||= {}; | ||
| 75 | return $self->client->api_call('ip.update', $self->id, $params); | ||
| 76 | } | ||
| 77 | |||
| 78 | #sub attach { | ||
| 79 | # my ( $self, $iface_id ) = @_; | ||
| 80 | # | ||
| 81 | # return $self->client->api_call('iface.attach', $iface_id, $self->id); | ||
| 82 | #} | ||
| 83 | |||
| 84 | |||
| 85 | #sub detach { | ||
| 86 | # my ( $self, $iface_id ) = @_; | ||
| 87 | # | ||
| 88 | # return $self->client->api_call('iface.detach', $iface_id, $self->id); | ||
| 89 | #} | ||
| 90 | |||
| 91 | no Moose; | ||
| 92 | __PACKAGE__->meta->make_immutable; | ||
| 93 | |||
| 94 | 1; | ||
| 95 | |||
| 96 | __END__ |