Class: Zm::Client::Cluster

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/cluster/cluster.rb

Overview

class admin connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Cluster

Returns a new instance of Cluster.



22
23
24
25
26
27
28
29
# File 'lib/zm/client/cluster/cluster.rb', line 22

def initialize(config)
  @config = config
  @soap_admin_connector = SoapAdminConnector.new(
    @config.zimbra_admin_scheme,
    @config.zimbra_admin_host,
    @config.zimbra_admin_port
  )
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



20
21
22
# File 'lib/zm/client/cluster/cluster.rb', line 20

def config
  @config
end

#soap_admin_connectorObject (readonly)

Returns the value of attribute soap_admin_connector.



20
21
22
# File 'lib/zm/client/cluster/cluster.rb', line 20

def soap_admin_connector
  @soap_admin_connector
end

Instance Method Details

#accountsObject



68
69
70
# File 'lib/zm/client/cluster/cluster.rb', line 68

def accounts
  @accounts ||= AccountsCollection.new self
end

#alive?Boolean

Returns:



42
43
44
45
46
47
# File 'lib/zm/client/cluster/cluster.rb', line 42

def alive?
  @soap_admin_connector.noop
  true
rescue Zm::Client::SoapError => _
  false
end

#cosesObject



80
81
82
# File 'lib/zm/client/cluster/cluster.rb', line 80

def coses
  @coses ||= CosesCollection.new self
end

#count_object(type) ⇒ Object

Raises:



96
97
98
99
100
101
# File 'lib/zm/client/cluster/cluster.rb', line 96

def count_object(type)
  raise ZmError, 'Unknown object type' unless Zm::Client::CountTypes::ALL.include?(type)

  resp = soap_admin_connector.count_object(type)
  resp[:Body][:CountObjectsResponse][:num]
end

#distributionlistsObject Also known as: distribution_lists



84
85
86
# File 'lib/zm/client/cluster/cluster.rb', line 84

def distributionlists
  @distributionlists ||= DistributionListsCollection.new self
end

#domain_key(domain_name) ⇒ Object



90
91
92
93
94
# File 'lib/zm/client/cluster/cluster.rb', line 90

def domain_key(domain_name)
  key = @config.domain_key(domain_name)
  key ||= find_domain_key(domain_name)
  key
end

#domainsObject



64
65
66
# File 'lib/zm/client/cluster/cluster.rb', line 64

def domains
  @domains ||= DomainsCollection.new self
end

#email_exist?(email) ⇒ Boolean

Returns:



103
104
105
106
107
108
# File 'lib/zm/client/cluster/cluster.rb', line 103

def email_exist?(email)
  filter = "(mail=#{email})"
  resp = soap_admin_connector.search_directory(filter, nil, nil, nil, nil, nil, nil, nil, 'accounts,distributionlists,aliases,resources',nil, 1)
  num = resp[:Body][:SearchDirectoryResponse][:num]
  !num.zero?
end

#licenseObject



57
58
59
60
61
62
# File 'lib/zm/client/cluster/cluster.rb', line 57

def license
  @license ||= LicensesCollection.new(self).find
rescue Zm::Client::SoapError => e
  puts e.message
  nil
end

#logged?Boolean

Returns:



38
39
40
# File 'lib/zm/client/cluster/cluster.rb', line 38

def logged?
  !@soap_admin_connector.token.nil?
end

#loginObject



31
32
33
34
35
36
# File 'lib/zm/client/cluster/cluster.rb', line 31

def 
  @soap_admin_connector.auth(
    @config.,
    @config.zimbra_admin_password
  )
end

#resourcesObject



72
73
74
# File 'lib/zm/client/cluster/cluster.rb', line 72

def resources
  @resources ||= ResourcesCollection.new self
end

#serversObject



76
77
78
# File 'lib/zm/client/cluster/cluster.rb', line 76

def servers
  @servers ||= ServersCollection.new self
end

#soap_account_connectorObject



49
50
51
52
53
54
55
# File 'lib/zm/client/cluster/cluster.rb', line 49

def 
   ||= SoapAccountConnector.new(
    @config.zimbra_public_scheme,
    @config.zimbra_public_host,
    @config.zimbra_public_port
  )
end