Class: Plesk::Packet

Inherits:
Object
  • Object
show all
Defined in:
lib/plesk/packet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version = "1.4.1.2") ⇒ Packet

Returns a new instance of Packet.



5
6
7
8
9
# File 'lib/plesk/packet.rb', line 5

def initialize version="1.4.1.2"
  @content = Nokogiri::XML::Builder.new do |xml|
    xml.packet(version: version)
  end.doc
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/plesk/packet.rb', line 4

def content
  @content
end

Instance Method Details

#domain_infoObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/plesk/packet.rb', line 10

def domain_info
  doc = @content
  Nokogiri::XML::Builder.with(doc.at('packet')) do |xml|
    xml.domain {
      xml.get {
      xml.filter
      xml.dataset {
        xml.limits
        xml.prefs
      }
    }
    }
  end
end

#domain_info_for_domain(domain) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/plesk/packet.rb', line 24

def domain_info_for_domain domain
  doc = @content
  @content=Nokogiri::XML::Builder.with(doc.at('packet')) do |xml|
    xml.domain {
      xml.get {
      xml.filter {
      xml.domain_name domain
    }
    xml.dataset {
      xml.limits
      xml.prefs
    }
    }
    }
  end
end

#mailgroup_info(name, id) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/plesk/packet.rb', line 40

def mailgroup_info name,id
  doc = @content
  @content =Nokogiri::XML::Builder.with(doc.at('packet')) do |xml|
    xml.mail {
      xml.get_info {
      xml.filter {
      xml.name name
      xml.domain_id id
    }
    xml.group
    }
    }
  end
end

#mailgroup_set(name, id, mails) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/plesk/packet.rb', line 54

def mailgroup_set name,id,mails
  doc = @content
  @content =Nokogiri::XML::Builder.with(doc.at('packet')) do |xml|
    xml.mail {
      xml.update {
      xml.set {
      xml.filter {
      xml.domain_id id
      xml.mailname {
        xml.name name
        xml.mailgroup {
          xml.enabled :true
          mails.each do |mail|
            xml.address mail
          end
        }
      }
    }
    }
    }
    }
  end
end

#secret_key_for_ip(ip) ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'lib/plesk/packet.rb', line 77

def secret_key_for_ip ip
  doc = @content
  Nokogiri::XML::Builder.with(doc.at('packet')) do |xml|
    xml.secret_key {
      xml.create {
      xml.ip_address ip
    }
    }
  end
end

#to_xmlObject



87
88
89
# File 'lib/plesk/packet.rb', line 87

def to_xml
  @content.to_xml
end