Class: Zm::Client::ClusterConfig
- Inherits:
-
Object
- Object
- Zm::Client::ClusterConfig
- Defined in:
- lib/zm/client/cluster/cluster_config.rb
Overview
class config for cluster connection
Instance Attribute Summary collapse
-
#domains ⇒ Object
Returns the value of attribute domains.
-
#to_h ⇒ Object
readonly
Returns the value of attribute to_h.
-
#zimbra_admin_host ⇒ Object
Returns the value of attribute zimbra_admin_host.
-
#zimbra_admin_login ⇒ Object
Returns the value of attribute zimbra_admin_login.
-
#zimbra_admin_password ⇒ Object
Returns the value of attribute zimbra_admin_password.
-
#zimbra_admin_port ⇒ Object
Returns the value of attribute zimbra_admin_port.
-
#zimbra_admin_scheme ⇒ Object
Returns the value of attribute zimbra_admin_scheme.
-
#zimbra_public_host ⇒ Object
Returns the value of attribute zimbra_public_host.
-
#zimbra_public_port ⇒ Object
Returns the value of attribute zimbra_public_port.
-
#zimbra_public_scheme ⇒ Object
Returns the value of attribute zimbra_public_scheme.
Instance Method Summary collapse
- #domain_key(domain_name) ⇒ Object
- #find_domain(domain_name) ⇒ Object
- #init_from_file(file_config_path) ⇒ Object
- #init_from_h ⇒ Object
- #init_from_json(file_config_path) ⇒ Object
- #init_from_yml(file_config_path) ⇒ Object
-
#initialize(parameters = nil) {|_self| ... } ⇒ ClusterConfig
constructor
A new instance of ClusterConfig.
- #make_config_domain ⇒ Object
Constructor Details
#initialize(parameters = nil) {|_self| ... } ⇒ ClusterConfig
Returns a new instance of ClusterConfig.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 16 def initialize(parameters = nil) @zimbra_admin_scheme = 'https' @zimbra_admin_port = 7071 @zimbra_public_scheme = 'https' @zimbra_public_port = 443 @domains = [] if parameters.is_a?(String) init_from_file(parameters) elsif parameters.is_a?(Hash) @to_h = parameters end unless @to_h.nil? init_from_h make_config_domain end yield(self) if block_given? end |
Instance Attribute Details
#domains ⇒ Object
Returns the value of attribute domains.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def domains @domains end |
#to_h ⇒ Object (readonly)
Returns the value of attribute to_h.
9 10 11 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 9 def to_h @to_h end |
#zimbra_admin_host ⇒ Object
Returns the value of attribute zimbra_admin_host.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def zimbra_admin_host @zimbra_admin_host end |
#zimbra_admin_login ⇒ Object
Returns the value of attribute zimbra_admin_login.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def zimbra_admin_login @zimbra_admin_login end |
#zimbra_admin_password ⇒ Object
Returns the value of attribute zimbra_admin_password.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def zimbra_admin_password @zimbra_admin_password end |
#zimbra_admin_port ⇒ Object
Returns the value of attribute zimbra_admin_port.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def zimbra_admin_port @zimbra_admin_port end |
#zimbra_admin_scheme ⇒ Object
Returns the value of attribute zimbra_admin_scheme.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def zimbra_admin_scheme @zimbra_admin_scheme end |
#zimbra_public_host ⇒ Object
Returns the value of attribute zimbra_public_host.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def zimbra_public_host @zimbra_public_host end |
#zimbra_public_port ⇒ Object
Returns the value of attribute zimbra_public_port.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def zimbra_public_port @zimbra_public_port end |
#zimbra_public_scheme ⇒ Object
Returns the value of attribute zimbra_public_scheme.
10 11 12 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 10 def zimbra_public_scheme @zimbra_public_scheme end |
Instance Method Details
#domain_key(domain_name) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 78 def domain_key(domain_name) domain = find_domain(domain_name) return nil if domain.nil? domain.key end |
#find_domain(domain_name) ⇒ Object
74 75 76 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 74 def find_domain(domain_name) @domains.find { |d| d.name == domain_name } end |
#init_from_file(file_config_path) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 37 def init_from_file(file_config_path) if file_config_path.end_with?('.json') init_from_json(file_config_path) elsif file_config_path.end_with?('.yml', '.yaml') init_from_yml(file_config_path) else raise ClusterConfigError, 'no valid config file extension' end end |
#init_from_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 47 def init_from_h @zimbra_admin_host = @to_h[:zimbra_admin_host] unless @to_h[:zimbra_admin_host].nil? @zimbra_admin_scheme = @to_h[:zimbra_admin_scheme] unless @to_h[:zimbra_admin_scheme].nil? @zimbra_admin_port = @to_h[:zimbra_admin_port] unless @to_h[:zimbra_admin_port].nil? @zimbra_admin_login = @to_h[:zimbra_admin_login] unless @to_h[:zimbra_admin_login].nil? @zimbra_admin_password = @to_h[:zimbra_admin_password] unless @to_h[:zimbra_admin_password].nil? @zimbra_public_host = @to_h[:zimbra_public_host] unless @to_h[:zimbra_public_host].nil? @zimbra_public_scheme = @to_h[:zimbra_public_scheme] unless @to_h[:zimbra_public_scheme].nil? @zimbra_public_port = @to_h[:zimbra_public_port] unless @to_h[:zimbra_public_port].nil? end |
#init_from_json(file_config_path) ⇒ Object
62 63 64 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 62 def init_from_json(file_config_path) @to_h = JSON.parse(File.read(file_config_path), symbolize_names: true) end |
#init_from_yml(file_config_path) ⇒ Object
58 59 60 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 58 def init_from_yml(file_config_path) @to_h = YAML.safe_load(File.read(file_config_path), symbolize_names: true) end |
#make_config_domain ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/zm/client/cluster/cluster_config.rb', line 66 def make_config_domain return if @to_h[:domains].nil? @domains = @to_h[:domains].map do |h| ClusterConfigDomain.new(h[:name], h[:key]) end end |