include templating on domain addition and make web hosting optional
[Net-Plesk.git] / lib / Net / Plesk / Method / domain_add.pm
1 package Net::Plesk::Method::domain_add;
2
3 use strict;
4
5 use vars qw( $VERSION @ISA $AUTOLOAD $DEBUG );
6
7 @ISA = qw( Net::Plesk::Method );
8 $VERSION = '0.02';
9
10 $DEBUG = 0;
11
12 =head1 NAME
13
14 Net::Plesk::Method::domain_add - Perl extension for Plesk XML Remote API domain addition
15
16 =head1 SYNOPSIS
17
18   use Net::Plesk::Method::domain_add
19
20   my $p = new Net::Plesk::Method::domain_add ( $clientID, 'domain.com' );
21
22   $request = $p->endcode;
23
24 =head1 DESCRIPTION
25
26 This module implements an interface to construct a request for a domain
27 addition using SWSOFT's Plesk.
28
29 =head1 METHODS
30
31 =over 4
32
33 =item init args ...
34
35 Initializes a Plesk domain_add object.  The I<domain>, I<client>, and
36 $<ip_address> options are required.
37
38 =cut
39
40 sub init {
41   my ($self, $domain, $client, $ip, $template, $user, $pass) = @_;
42   my $xml = join ( "\n", (
43                     '<domain>',
44                     '<add>',
45                     '<gen_setup>',
46                     '<name>',
47                     $self->encode($domain),
48                     '</name>',
49                     '<client_id>',
50                     $self->encode($client),
51                     '</client_id>',
52                  ));
53   $xml .= '<htype>vrt_hst</htype>' if defined($user);
54   $xml .= join ( "\n", ( '<ip_address>',
55                   $self->encode($ip),
56                   '</ip_address>',
57                   '</gen_setup>',
58                ));
59   if (defined($user)) {
60     $xml .= "<hosting><vrt_hst><ftp_login>" . $self->encode($user);
61     $xml .= "</ftp_login><ftp_password>" . $self->encode($pass);
62     $xml .= "</ftp_password><ip_address>" . $self->encode($ip);
63     $xml .= "</ip_address></vrt_hst></hosting>";
64   }
65   if ($template) {
66     $xml .= "<template-name>" . $self->encode($template) . "</template-name>";
67   }
68   $xml .= '</add></domain>';
69
70   $$self = $xml;
71 }
72
73 =back
74
75 =head1 BUGS
76
77   Creepy crawlies.
78
79 =head1 SEE ALSO
80
81 SWSOFT Plesk Remote API documentation (1.4.0.0 or later)
82
83 =head1 AUTHOR
84
85 Jeff Finucane E<lt>jeff@cmh.netE<gt>
86
87 =head1 COPYRIGHT AND LICENSE
88
89 Copyright (C) 2006 Jeff Finucane
90
91 This library is free software; you can redistribute it and/or modify
92 it under the same terms as Perl itself.
93
94 =cut
95
96 1;
97