line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=encoding utf-8 |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Webservice::OVH::Hosting::Web::Service |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Provieds basic functionality for webhosting Services |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 METHODS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use strict; |
19
|
36
|
|
|
36
|
|
235
|
use warnings; |
|
36
|
|
|
|
|
79
|
|
|
36
|
|
|
|
|
867
|
|
20
|
36
|
|
|
36
|
|
170
|
use Carp qw{ carp croak }; |
|
36
|
|
|
|
|
74
|
|
|
36
|
|
|
|
|
812
|
|
21
|
36
|
|
|
36
|
|
166
|
use DateTime; |
|
36
|
|
|
|
|
70
|
|
|
36
|
|
|
|
|
1551
|
|
22
|
36
|
|
|
36
|
|
240
|
use JSON; |
|
36
|
|
|
|
|
87
|
|
|
36
|
|
|
|
|
743
|
|
23
|
36
|
|
|
36
|
|
207
|
|
|
36
|
|
|
|
|
100
|
|
|
36
|
|
|
|
|
317
|
|
24
|
|
|
|
|
|
|
our $VERSION = 0.47; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 _new |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Internal Method to create the service object. |
29
|
|
|
|
|
|
|
This method is not ment to be called external. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Hosting::Web::service> |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH::Hosting::Web::service->_new($ovh_api_wrapper, $service_name, $module); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=back |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my ( $class, %params ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
|
|
die "Missing module" unless $params{module}; |
47
|
|
|
|
|
|
|
die "Missing wrapper" unless $params{wrapper}; |
48
|
0
|
0
|
|
|
|
|
die "Missing id" unless $params{id}; |
49
|
0
|
0
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
my $module = $params{module}; |
51
|
|
|
|
|
|
|
my $api_wrapper = $params{wrapper}; |
52
|
0
|
|
|
|
|
|
my $service_name = $params{id}; |
53
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $self = bless { _module => $module, _api_wrapper => $api_wrapper, _name => $service_name, _service_info => undef, _properties => undef }, $class; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 name |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Name is the unique identifier. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item * Return: VALUE |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item * Synopsis: my $name = $service->name; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=back |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my ($self) = @_; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
return $self->{_name}; |
77
|
0
|
|
|
0
|
1
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
=head2 service_infos |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Retrieves additional infos about the service. |
82
|
|
|
|
|
|
|
Infos that are not part of the properties |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * Return: HASH |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * Synopsis: my $info = $service->service_info; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my ($self) = @_; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
98
|
|
|
|
|
|
|
my $service_name = $self->name; |
99
|
0
|
|
|
0
|
1
|
|
my $response_service_info = $api->rawCall( method => 'get', path => "/hosting/web/$service_name/serviceInfos", noSignature => 0 ); |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
croak $response_service_info->error if $response_service_info->error; |
102
|
0
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$self->{_service_info} = $response_service_info->content; |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
return $self->{_service_info}; |
106
|
|
|
|
|
|
|
} |
107
|
0
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 change_service_infos |
109
|
0
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Change service_infos let you change the autorenewal method for this service |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * Parameter: %params - key => value renew(required) => { automatic(required), delete_at_expiration(required), forced(required), period(required) } |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * Synopsis: $service->change_service_infos(renew => { automatic => 'yes', delete_at_expiration => 'yes', forced => 'yes', period => 12 }); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my ( $self, %params ) = @_; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
croak "Missing parameter: renew" unless $params{renew}; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my @keys = qw{ automatic delete_at_expiration forced period }; |
128
|
0
|
|
|
0
|
1
|
|
if ( my @missing_parameters = grep { not exists $params{renew}{$_} } @keys ) { |
129
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
croak "Missing parameter: @missing_parameters"; |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
my $options = {}; |
|
0
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$options->{automatic} = $params{renew}{automatic} eq 'true' || $params{renew}{automatic} eq 'yes' || $params{renew}{automatic} eq '1' ? JSON::true : JSON::false; |
135
|
0
|
|
|
|
|
|
$options->{deleteAtExpiration} = $params{renew}{delete_at_expiration} eq 'true' || $params{renew}{delete_at_expiration} eq 'yes' || $params{renew}{delete_at_expiration} eq '1' ? JSON::true : JSON::false; |
136
|
|
|
|
|
|
|
$options->{forced} = $params{renew}{forced} eq 'true' || $params{renew}{forced} eq 'yes' || $params{renew}{forced} eq '1' ? JSON::true : JSON::false; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
139
|
0
|
0
|
0
|
|
|
|
my $service_name = $self->name; |
140
|
0
|
0
|
0
|
|
|
|
my $body = {}; |
141
|
0
|
0
|
0
|
|
|
|
$body->{renew}{period} = $params{renew}{period}; |
142
|
|
|
|
|
|
|
$body->{renew}{automatic} = $options->{automatic}; |
143
|
0
|
|
|
|
|
|
$body->{renew}{deleteAtExpiration} = $options->{deleteAtExpiration}; |
144
|
0
|
|
|
|
|
|
$body->{renew}{forced} = $options->{forced}; |
145
|
0
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
my $response = $api->rawCall( method => 'put', body => $body, path => "/hosting/web/$service_name/serviceInfos", noSignature => 0 ); |
147
|
0
|
|
|
|
|
|
croak $response->error if $response->error; |
148
|
0
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
1 |