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