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
-
#buildDate ⇒ Object
readonly
Returns the value of attribute buildDate.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#majorversion ⇒ Object
readonly
Returns the value of attribute majorversion.
-
#microversion ⇒ Object
readonly
Returns the value of attribute microversion.
-
#minorversion ⇒ Object
readonly
Returns the value of attribute minorversion.
-
#release ⇒ Object
readonly
Returns the value of attribute release.
-
#soap_admin_connector ⇒ Object
readonly
Returns the value of attribute soap_admin_connector.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#zimbra_attributes ⇒ Object
readonly
Returns the value of attribute zimbra_attributes.
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
- #has_admin_credentials? ⇒ Boolean
- #infos! ⇒ Object
-
#initialize(config) ⇒ Cluster
constructor
A new instance of Cluster.
- #license ⇒ Object
- #logged? ⇒ Boolean
- #login ⇒ Object
- #resources ⇒ Object
- #servers ⇒ Object
- #token ⇒ Object
- #token=(value) ⇒ Object
- #token_metadata ⇒ Object
Constructor Details
#initialize(config) ⇒ Cluster
Returns a new instance of Cluster.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/zm/client/cluster/cluster.rb', line 21 def initialize(config) # extend(ZmLogger) @config = config @version = config.zimbra_version @zimbra_attributes = Base::ZimbraAttributesCollection.new(self) @zimbra_attributes.set_methods @soap_admin_connector = SoapAdminConnector.create(@config) end |
Instance Attribute Details
#buildDate ⇒ Object (readonly)
Returns the value of attribute buildDate.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def buildDate @buildDate end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def config @config end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def host @host end |
#majorversion ⇒ Object (readonly)
Returns the value of attribute majorversion.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def majorversion @majorversion end |
#microversion ⇒ Object (readonly)
Returns the value of attribute microversion.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def microversion @microversion end |
#minorversion ⇒ Object (readonly)
Returns the value of attribute minorversion.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def minorversion @minorversion end |
#release ⇒ Object (readonly)
Returns the value of attribute release.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def release @release end |
#soap_admin_connector ⇒ Object (readonly)
Returns the value of attribute soap_admin_connector.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def soap_admin_connector @soap_admin_connector end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def version @version end |
#zimbra_attributes ⇒ Object (readonly)
Returns the value of attribute zimbra_attributes.
18 19 20 |
# File 'lib/zm/client/cluster/cluster.rb', line 18 def zimbra_attributes @zimbra_attributes end |
Instance Method Details
#accounts ⇒ Object
86 87 88 |
# File 'lib/zm/client/cluster/cluster.rb', line 86 def accounts @accounts ||= AccountsCollection.new self end |
#alive? ⇒ Boolean
62 63 64 65 66 67 68 69 |
# File 'lib/zm/client/cluster/cluster.rb', line 62 def alive? soap_request = SoapElement.admin(SoapAdminConstants::NO_OP_REQUEST) @soap_admin_connector.invoke(soap_request) true rescue Zm::Client::SoapError => e logger.error "Admin session token alive ? #{e.}" false end |
#coses ⇒ Object
98 99 100 |
# File 'lib/zm/client/cluster/cluster.rb', line 98 def coses @coses ||= CosesCollection.new self end |
#count_object(type) ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/zm/client/cluster/cluster.rb', line 114 def count_object(type) raise ZmError, 'Unknown object type' unless Zm::Client::CountTypes::ALL.include?(type) soap_request = SoapElement.admin(SoapAdminConstants::COUNT_OBJECTS_REQUEST) soap_request.add_attribute('type', type) soap_resp = @soap_admin_connector.invoke(soap_request) soap_resp[:CountObjectsResponse][:num] end |
#distributionlists ⇒ Object Also known as: distribution_lists
102 103 104 |
# File 'lib/zm/client/cluster/cluster.rb', line 102 def distributionlists @distributionlists ||= DistributionListsCollection.new self end |
#domain_key(domain_name) ⇒ Object
108 109 110 111 112 |
# File 'lib/zm/client/cluster/cluster.rb', line 108 def domain_key(domain_name) key = @config.domain_key(domain_name) key ||= find_domain_key(domain_name) key end |
#domains ⇒ Object
82 83 84 |
# File 'lib/zm/client/cluster/cluster.rb', line 82 def domains @domains ||= DomainsCollection.new self end |
#email_exist?(email) ⇒ Boolean
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/zm/client/cluster/cluster.rb', line 123 def email_exist?(email) jsns = { query: "(mail=#{email})", types: 'accounts,distributionlists,aliases,resources', countOnly: SoapUtils::ON } soap_request = SoapElement.admin(SoapAdminConstants::SEARCH_DIRECTORY_REQUEST) soap_request.add_attributes(jsns) soap_resp = @soap_admin_connector.invoke(soap_request) !soap_resp[:SearchDirectoryResponse][:num].zero? end |
#has_admin_credentials? ⇒ Boolean
33 34 35 |
# File 'lib/zm/client/cluster/cluster.rb', line 33 def has_admin_credentials? @config.has_admin_credentials? end |
#infos! ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/zm/client/cluster/cluster.rb', line 136 def infos! soap_request = SoapElement.admin(SoapAdminConstants::GET_VERSION_INFO_REQUEST) soap_response = @soap_admin_connector.invoke(soap_request) json = soap_response[:GetVersionInfoResponse][:info].first instance_variable_set(:@type, json[:type]) instance_variable_set(:@version, json[:version]) instance_variable_set(:@release, json[:release]) instance_variable_set(:@buildDate, json[:buildDate]) instance_variable_set(:@host, json[:host]) instance_variable_set(:@majorversion, json[:majorversion]) instance_variable_set(:@minorversion, json[:minorversion]) instance_variable_set(:@microversion, json[:microversion]) end |
#license ⇒ Object
75 76 77 78 79 80 |
# File 'lib/zm/client/cluster/cluster.rb', line 75 def license @license ||= LicensesCollection.new(self).find rescue Zm::Client::SoapError => e logger.error "Get License info #{e.}" nil end |
#logged? ⇒ Boolean
58 59 60 |
# File 'lib/zm/client/cluster/cluster.rb', line 58 def logged? !@soap_admin_connector.token.nil? end |
#login ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/zm/client/cluster/cluster.rb', line 45 def login raise ClusterConfigError, 'admin credentials are missing' unless @config.has_admin_credentials? logger.info 'Get Admin session token' @soap_admin_connector.token = nil if logged? soap_request = SoapElement.admin(SoapAdminConstants::AUTH_REQUEST) soap_request.add_attributes(name: @config.zimbra_admin_login, password: @config.zimbra_admin_password) soap_resp = @soap_admin_connector.invoke(soap_request, Zm::Client::AuthError) @soap_admin_connector.context.token(soap_resp[:AuthResponse][:authToken].first[:_content]) end |
#resources ⇒ Object
90 91 92 |
# File 'lib/zm/client/cluster/cluster.rb', line 90 def resources @resources ||= ResourcesCollection.new self end |
#servers ⇒ Object
94 95 96 |
# File 'lib/zm/client/cluster/cluster.rb', line 94 def servers @servers ||= ServersCollection.new self end |
#token ⇒ Object
37 38 39 |
# File 'lib/zm/client/cluster/cluster.rb', line 37 def token @soap_admin_connector.token end |
#token=(value) ⇒ Object
41 42 43 |
# File 'lib/zm/client/cluster/cluster.rb', line 41 def token=(value) @soap_admin_connector.token= value end |
#token_metadata ⇒ Object
71 72 73 |
# File 'lib/zm/client/cluster/cluster.rb', line 71 def @token_metadata ||= TokenMetaData.new(@soap_admin_connector.token) end |