Class: Zm::Client::Domain

Inherits:
Base::Object show all
Includes:
HasSoapAdminConnector
Defined in:
lib/zm/client/domain/domain.rb

Overview

objectClass: zimbraDomain

Instance Attribute Summary

Attributes inherited from Base::Object

#id, #name, #parent, #token

Instance Method Summary collapse

Methods included from HasSoapAdminConnector

#soap_admin_connector

Methods inherited from Base::Object

#clone, #initialize, #inspect, #instance_variables_map, #logger, #recorded?, #save!, #to_h, #to_s, #update_attribute

Constructor Details

This class inherits a constructor from Zm::Client::Base::Object

Instance Method Details

#accountsObject



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

def accounts
  @accounts ||= DomainAccountsCollection.new(self)
end

#attrs_writeObject



57
58
59
# File 'lib/zm/client/domain/domain.rb', line 57

def attrs_write
  @parent.zimbra_attributes.all_domain_attrs_writable_names
end

#cosObject



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

def cos
  return nil if self.zimbraDomainDefaultCOSId.nil?

  @cos ||= @parent.coses.find_by id: self.zimbraDomainDefaultCOSId
end

#create!Object



9
10
11
12
# File 'lib/zm/client/domain/domain.rb', line 9

def create!
  resp = sac.invoke(jsns_builder.to_create)
  @id = resp[:CreateDomainResponse][:domain].first[:id]
end

#delete!Object



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

def delete!
  soap_request = SoapElement.admin(SoapAdminConstants::DELETE_DOMAIN_REQUEST).add_attribute(SoapConstants::ID,
                                                                                            @id)
  sac.invoke(soap_request)
  @id = nil
end

#distributionlistsObject Also known as: distribution_lists



42
43
44
# File 'lib/zm/client/domain/domain.rb', line 42

def distributionlists
  @distributionlists ||= DomainDistributionListsCollection.new(self)
end

#DKIMPublicTxtObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/zm/client/domain/domain.rb', line 61

def DKIMPublicTxt
  return if self.DKIMPublicKey.nil?
  return @DKIMPublicTxt if @DKIMPublicTxt

  txt = self.DKIMPublicKey.each_line.map do |line|
    line.chomp!
    line.gsub!('"', '')
    line.strip!
  end.join

  matches = txt.scan(/\((.*)\)/)
  return if matches.first.nil?

  @DKIMPublicTxt = matches.first.first.strip
end

#modify!Object



14
15
16
17
# File 'lib/zm/client/domain/domain.rb', line 14

def modify!
  sac.invoke(jsns_builder.to_update)
  true
end

#resourcesObject



47
48
49
# File 'lib/zm/client/domain/domain.rb', line 47

def resources
  @resources ||= DomainResourcesCollection.new(self)
end

#update!(hash) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/zm/client/domain/domain.rb', line 19

def update!(hash)
  return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?

  do_update!(hash)

  hash.each do |key, value|
    update_attribute(key, value)
  end

  true
end