| 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::Iface; | ||
| 10 | { | ||
| 11 | $Net::Gandi::Hosting::Iface::VERSION = '1.122180'; | ||
| 12 | } | ||
| 13 | |||
| 14 | # ABSTRACT: Iface 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( "iface.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('iface.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( 'iface.info', $self->id ); | ||
| 62 | } | ||
| 63 | |||
| 64 | |||
| 65 | sub create { | ||
| 66 | my ( $self, $params ) = validated_list( | ||
| 67 | \@_, | ||
| 68 | iface_spec => { isa => 'HashRef' } | ||
| 69 | ); | ||
| 70 | |||
| 71 | _validated_params('iface_create', $params); | ||
| 72 | |||
| 73 | return $self->client->api_call( "iface.create", $params ); | ||
| 74 | } | ||
| 75 | |||
| 76 | |||
| 77 | sub update { | ||
| 78 | my ( $self, $params ) = validated_list( | ||
| 79 | \@_, | ||
| 80 | iface_spec => { isa => 'HashRef' } | ||
| 81 | ); | ||
| 82 | |||
| 83 | carp 'Required parameter id is not defined' if ( ! $self->id ); | ||
| 84 | _validated_params('iface_update', $params); | ||
| 85 | |||
| 86 | return $self->client->api_call( "iface.update", $self->id, $params ); | ||
| 87 | } | ||
| 88 | |||
| 89 | |||
| 90 | sub delete { | ||
| 91 | my ( $self ) = @_; | ||
| 92 | |||
| 93 | carp 'Required parameter id is not defined' if ( ! $self->id ); | ||
| 94 | return $self->client->api_call('iface.delete', $self->id); | ||
| 95 | } | ||
| 96 | |||
| 97 | no Moose; | ||
| 98 | __PACKAGE__->meta->make_immutable; | ||
| 99 | |||
| 100 | 1; | ||
| 101 | |||
| 102 | __END__ |