Class: Zm::Client::Cluster
- Inherits:
-
Object
- Object
- Zm::Client::Cluster
- Defined in:
- lib/zm/client/cluster/cluster.rb
Overview
class admin connection
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#soap_admin_connector ⇒ Object
readonly
Returns the value of attribute soap_admin_connector.
Instance Method Summary collapse
- #accounts ⇒ Object
- #alive? ⇒ Boolean
- #coses ⇒ Object
- #count_object(type) ⇒ Object
- #distributionlists ⇒ Object (also: #distribution_lists)
- #domain_key(domain_name) ⇒ Object
- #domains ⇒ Object
- #email_exist?(email) ⇒ Boolean
-
#initialize(config) ⇒ Cluster
constructor
A new instance of Cluster.
- #license ⇒ Object
- #logged? ⇒ Boolean
- #login ⇒ Object
- #resources ⇒ Object
- #servers ⇒ Object
- #soap_account_connector ⇒ Object
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
#config ⇒ Object (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_connector ⇒ Object (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
#accounts ⇒ Object
68 69 70 |
# File 'lib/zm/client/cluster/cluster.rb', line 68 def accounts @accounts ||= AccountsCollection.new self end |
#alive? ⇒ Boolean
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 |
#coses ⇒ Object
80 81 82 |
# File 'lib/zm/client/cluster/cluster.rb', line 80 def coses @coses ||= CosesCollection.new self end |
#count_object(type) ⇒ Object
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 |
#distributionlists ⇒ Object 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 |
#domains ⇒ Object
64 65 66 |
# File 'lib/zm/client/cluster/cluster.rb', line 64 def domains @domains ||= DomainsCollection.new self end |
#email_exist?(email) ⇒ Boolean
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 |
#license ⇒ Object
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. nil end |
#logged? ⇒ Boolean
38 39 40 |
# File 'lib/zm/client/cluster/cluster.rb', line 38 def logged? !@soap_admin_connector.token.nil? end |
#login ⇒ Object
31 32 33 34 35 36 |
# File 'lib/zm/client/cluster/cluster.rb', line 31 def login @soap_admin_connector.auth( @config.zimbra_admin_login, @config.zimbra_admin_password ) end |
#resources ⇒ Object
72 73 74 |
# File 'lib/zm/client/cluster/cluster.rb', line 72 def resources @resources ||= ResourcesCollection.new self end |
#servers ⇒ Object
76 77 78 |
# File 'lib/zm/client/cluster/cluster.rb', line 76 def servers @servers ||= ServersCollection.new self end |
#soap_account_connector ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/zm/client/cluster/cluster.rb', line 49 def soap_account_connector @soap_account_connector ||= SoapAccountConnector.new( @config.zimbra_public_scheme, @config.zimbra_public_host, @config.zimbra_public_port ) end |