Class: Zm::Client::Account
Overview
objectClass: zimbraAccount
Instance Attribute Summary collapse
Attributes inherited from Base::Object
#grantee_type, #parent
Instance Method Summary
collapse
#soap_account_connector, #soap_admin_connector
#arrow_name, #clone, #concat, #convert_json_string_value, #instance_variables_array, #instance_variables_hash, #recorded?, #save!, #to_s
Constructor Details
#initialize(parent, attrs = {}) ⇒ Account
Returns a new instance of Account.
31
32
33
34
35
|
# File 'lib/zm/client/account/account.rb', line 31
def initialize(parent, attrs = {})
extend(AccountCommon)
super(parent)
@grantee_type = 'usr'.freeze
end
|
Instance Attribute Details
#carLicense ⇒ Object
Returns the value of attribute carLicense.
29
30
31
|
# File 'lib/zm/client/account/account.rb', line 29
def carLicense
@carLicense
end
|
#company ⇒ Object
Returns the value of attribute company.
29
30
31
|
# File 'lib/zm/client/account/account.rb', line 29
def company
@company
end
|
#domainkey ⇒ Object
Returns the value of attribute domainkey.
29
30
31
|
# File 'lib/zm/client/account/account.rb', line 29
def domainkey
@domainkey
end
|
#home_url ⇒ Object
130
131
132
133
|
# File 'lib/zm/client/account/account.rb', line 130
def home_url
infos if @infos.nil?
@home_url
end
|
#id ⇒ Object
Returns the value of attribute id.
27
28
29
|
# File 'lib/zm/client/account/account.rb', line 27
def id
@id
end
|
#name ⇒ Object
Returns the value of attribute name.
27
28
29
|
# File 'lib/zm/client/account/account.rb', line 27
def name
@name
end
|
#password ⇒ Object
Returns the value of attribute password.
29
30
31
|
# File 'lib/zm/client/account/account.rb', line 29
def password
@password
end
|
#token ⇒ Object
Returns the value of attribute token.
27
28
29
|
# File 'lib/zm/client/account/account.rb', line 27
def token
@token
end
|
#zimbraCOSId ⇒ Object
Returns the value of attribute zimbraCOSId.
29
30
31
|
# File 'lib/zm/client/account/account.rb', line 29
def zimbraCOSId
@zimbraCOSId
end
|
#zimbraMailHost ⇒ Object
Returns the value of attribute zimbraMailHost.
29
30
31
|
# File 'lib/zm/client/account/account.rb', line 29
def zimbraMailHost
@zimbraMailHost
end
|
#zimbraMailTransport ⇒ Object
Returns the value of attribute zimbraMailTransport.
29
30
31
|
# File 'lib/zm/client/account/account.rb', line 29
def zimbraMailTransport
@zimbraMailTransport
end
|
Instance Method Details
#account_login ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/zm/client/account/account.rb', line 71
def account_login
if password
account_login_password
else
account_login_preauth
end
end
|
#account_login_password ⇒ Object
86
87
88
89
90
|
# File 'lib/zm/client/account/account.rb', line 86
def account_login_password
raise ZmError, 'password is required to login !' if password.nil?
@token = sacc.auth_password(@name, @password)
end
|
#account_login_preauth ⇒ Object
79
80
81
82
83
84
|
# File 'lib/zm/client/account/account.rb', line 79
def account_login_preauth
domain_key
raise ZmError, 'domain key is required to login !' if @domainkey.nil?
@token = sacc.auth_preauth(@name, @domainkey)
end
|
#aces ⇒ Object
Also known as:
rights
175
176
177
|
# File 'lib/zm/client/account/account.rb', line 175
def aces
@aces ||= AcesCollection.new(self)
end
|
#add_alias!(email) ⇒ Object
256
257
258
259
|
# File 'lib/zm/client/account/account.rb', line 256
def add_alias!(email)
sac.add_account_alias(@id, email)
aliases.push(email)
end
|
#admin_login ⇒ Object
92
93
94
|
# File 'lib/zm/client/account/account.rb', line 92
def admin_login
@token = sac.delegate_auth(@name)
end
|
#aliases ⇒ Object
246
247
248
|
# File 'lib/zm/client/account/account.rb', line 246
def aliases
@aliases ||= set_aliases
end
|
#all_instance_variable_keys ⇒ Object
49
50
51
|
# File 'lib/zm/client/account/account.rb', line 49
def all_instance_variable_keys
AccountCommon::ZM_ACCOUNT_ATTRS
end
|
#appointments ⇒ Object
163
164
165
|
# File 'lib/zm/client/account/account.rb', line 163
def appointments
@appointments ||= AppointmentsCollection.new(self)
end
|
#calendar_folders ⇒ Object
200
201
202
|
# File 'lib/zm/client/account/account.rb', line 200
def calendar_folders
@calendar_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::APPOINTMENT.to_s }
end
|
196
197
198
|
# File 'lib/zm/client/account/account.rb', line 196
def contact_folders
@contact_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::CONTACT.to_s }
end
|
159
160
161
|
# File 'lib/zm/client/account/account.rb', line 159
def contacts
@contacts ||= ContactsCollection.new(self)
end
|
#cos ⇒ Object
117
118
119
|
# File 'lib/zm/client/account/account.rb', line 117
def cos
@cos ||= @parent.coses.find_by(id: zimbraCOSId)
end
|
#create! ⇒ Object
237
238
239
240
241
242
243
244
|
# File 'lib/zm/client/account/account.rb', line 237
def create!
rep = sac.create_account(
@name,
@password,
instance_variables_array(attrs_write)
)
@id = rep[:Body][:CreateAccountResponse][:account].first[:id]
end
|
#created_at ⇒ Object
301
302
303
|
# File 'lib/zm/client/account/account.rb', line 301
def created_at
@created_at ||= Time.parse zimbraCreateTimestamp unless zimbraCreateTimestamp.nil?
end
|
#data_sources ⇒ Object
184
185
186
|
# File 'lib/zm/client/account/account.rb', line 184
def data_sources
@data_sources ||= DataSourcesCollection.new sac, self
end
|
#delete! ⇒ Object
212
213
214
|
# File 'lib/zm/client/account/account.rb', line 212
def delete!
sac.delete_account(@id)
end
|
#dls_owner ⇒ Object
324
325
326
|
# File 'lib/zm/client/account/account.rb', line 324
def dls_owner
@dls_owner ||= AccountDlsOwnerCollection.new(self)
end
|
#document_folders ⇒ Object
208
209
210
|
# File 'lib/zm/client/account/account.rb', line 208
def document_folders
@document_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::DOCUMENT.to_s }
end
|
#documents ⇒ Object
188
189
190
|
# File 'lib/zm/client/account/account.rb', line 188
def documents
@documents ||= DocumentsCollection.new(self)
end
|
#domain_key ⇒ Object
100
101
102
|
# File 'lib/zm/client/account/account.rb', line 100
def domain_key
@domainkey ||= @parent.domain_key(domain_name)
end
|
#domain_name ⇒ Object
96
97
98
|
# File 'lib/zm/client/account/account.rb', line 96
def domain_name
@name.split('@').last
end
|
#flush_cache! ⇒ Object
305
306
307
|
# File 'lib/zm/client/account/account.rb', line 305
def flush_cache!
sac.flush_cache('account', 1, @id)
end
|
#folders ⇒ Object
139
140
141
|
# File 'lib/zm/client/account/account.rb', line 139
def folders
@folders ||= FoldersCollection.new(self)
end
|
#identities ⇒ Object
151
152
153
|
# File 'lib/zm/client/account/account.rb', line 151
def identities
@identities ||= IdentitiesCollection.new(self)
end
|
#infos ⇒ Object
104
105
106
|
# File 'lib/zm/client/account/account.rb', line 104
def infos
@infos ||= read_infos
end
|
#init_by_hash(attrs) ⇒ Object
37
38
39
40
41
|
# File 'lib/zm/client/account/account.rb', line 37
def init_by_hash(attrs)
attrs.each do |k, v|
self.instance_variable_set(arrow_name(k), v)
end
end
|
#init_from_json(json) ⇒ Object
328
329
330
331
332
|
# File 'lib/zm/client/account/account.rb', line 328
def init_from_json(json)
@used = json[:used] if json[:used]
@zimbraMailQuota = json[:limit] if json[:limit]
super(json)
end
|
#is_external_transport? ⇒ Boolean
287
288
289
290
291
|
# File 'lib/zm/client/account/account.rb', line 287
def is_external_transport?
return nil unless zimbraMailTransport
zimbraMailTransport.start_with?('smtp')
end
|
#is_local_transport? ⇒ Boolean
281
282
283
284
285
|
# File 'lib/zm/client/account/account.rb', line 281
def is_local_transport?
return nil unless zimbraMailTransport
zimbraMailTransport.start_with?('lmtp')
end
|
#is_on_to_move?(server) ⇒ Boolean
315
316
317
318
|
# File 'lib/zm/client/account/account.rb', line 315
def is_on_to_move?(server)
resp = sac.query_mailbox_move(@name, server.id)
resp[:Body][:QueryMailboxMoveResponse][:account].nil?
end
|
#last_logon ⇒ Object
297
298
299
|
# File 'lib/zm/client/account/account.rb', line 297
def last_logon
@last_logon ||= Time.parse zimbraLastLogonTimestamp unless zimbraLastLogonTimestamp.nil?
end
|
#local_transport ⇒ Object
271
272
273
274
275
|
# File 'lib/zm/client/account/account.rb', line 271
def local_transport
raise Zm::Client::SoapError, 'zimbraMailHost is null' if zimbraMailHost.nil?
"lmtp:#{zimbraMailHost}:7025"
end
|
#local_transport! ⇒ Object
277
278
279
|
# File 'lib/zm/client/account/account.rb', line 277
def local_transport!
update!(zimbraMailTransport: local_transport)
end
|
#logged? ⇒ Boolean
59
60
61
|
# File 'lib/zm/client/account/account.rb', line 59
def logged?
!@token.nil?
end
|
#login ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/zm/client/account/account.rb', line 63
def login
if @parent.logged?
admin_login
else
account_login
end
end
|
#memberships ⇒ Object
320
321
322
|
# File 'lib/zm/client/account/account.rb', line 320
def memberships
@memberships ||= AccountDlsMembershipCollection.new(self)
end
|
#message_folders ⇒ Object
192
193
194
|
# File 'lib/zm/client/account/account.rb', line 192
def message_folders
@message_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::MESSAGE.to_s }
end
|
#messages ⇒ Object
135
136
137
|
# File 'lib/zm/client/account/account.rb', line 135
def messages
@messages ||= MessagesCollection.new(self)
end
|
#modify! ⇒ Object
230
231
232
233
234
235
|
# File 'lib/zm/client/account/account.rb', line 230
def modify!
attrs_to_modify = instance_variables_array(attrs_write)
return if attrs_to_modify.empty?
sac.modify_account(@id, attrs_to_modify)
end
|
#mountpoints ⇒ Object
143
144
145
|
# File 'lib/zm/client/account/account.rb', line 143
def mountpoints
@mountpointss ||= MountPointsCollection.new(self)
end
|
#move_mailbox(server) ⇒ Object
309
310
311
312
313
|
# File 'lib/zm/client/account/account.rb', line 309
def move_mailbox(server)
raise Zm::Client::SoapError, 'zimbraMailHost is null' if zimbraMailHost.nil?
sac.move_mailbox(@name, zimbraMailHost, server.name, server.id)
end
|
#public_url ⇒ Object
125
126
127
128
|
# File 'lib/zm/client/account/account.rb', line 125
def public_url
infos if @infos.nil?
@public_url
end
|
#read_infos ⇒ Object
108
109
110
111
112
113
114
115
|
# File 'lib/zm/client/account/account.rb', line 108
def read_infos
@infos = sacc.get_info(@token)[:Body][:GetInfoResponse]
@id = @infos[:id]
@used = @infos[:used]
@public_url = @infos[:publicURL]
@zimbraCOSId = @infos[:cos][:id]
@home_url = @infos[:rest]
end
|
#remove_alias!(email) ⇒ Object
261
262
263
264
|
# File 'lib/zm/client/account/account.rb', line 261
def remove_alias!(email)
sac.remove_account_alias(@id, email)
aliases.delete(email)
end
|
#rename!(email) ⇒ Object
266
267
268
269
|
# File 'lib/zm/client/account/account.rb', line 266
def rename!(email)
sac.rename_account(@id, email)
@name = email
end
|
#rest_account_connector ⇒ Object
Also known as:
rac
53
54
55
|
# File 'lib/zm/client/account/account.rb', line 53
def rest_account_connector
@rest_account_connector ||= RestAccountConnector.new
end
|
#search_folders ⇒ Object
147
148
149
|
# File 'lib/zm/client/account/account.rb', line 147
def search_folders
@search_folders ||= SearchFoldersCollection.new(self)
end
|
#set_aliases ⇒ Object
250
251
252
253
254
|
# File 'lib/zm/client/account/account.rb', line 250
def set_aliases
return [] if zimbraMailAlias.nil?
return [zimbraMailAlias] if zimbraMailAlias.is_a?(String)
zimbraMailAlias
end
|
#shares ⇒ Object
155
156
157
|
# File 'lib/zm/client/account/account.rb', line 155
def shares
@shares ||= SharesCollection.new(self)
end
|
#signatures ⇒ Object
180
181
182
|
# File 'lib/zm/client/account/account.rb', line 180
def signatures
@signatures ||= SignaturesCollection.new(self)
end
|
167
168
169
|
# File 'lib/zm/client/account/account.rb', line 167
def tags
@tags ||= TagsCollection.new(self)
end
|
#task_folders ⇒ Object
204
205
206
|
# File 'lib/zm/client/account/account.rb', line 204
def task_folders
@task_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::TASK.to_s }
end
|
#tasks ⇒ Object
171
172
173
|
# File 'lib/zm/client/account/account.rb', line 171
def tasks
@tasks ||= TasksCollection.new(self)
end
|
#to_h ⇒ Object
43
44
45
46
47
|
# File 'lib/zm/client/account/account.rb', line 43
def to_h
hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
hashmap.delete_if { |_, v| v.nil? }
hashmap
end
|
#update!(hash) ⇒ Object
216
217
218
219
220
221
222
223
224
225
226
227
228
|
# File 'lib/zm/client/account/account.rb', line 216
def update!(hash)
sac.modify_account(@id, hash)
hash.each do |k, v|
arrow_attr_sym = "@#{k}".to_sym
if v.respond_to?(:empty?) && v.empty?
self.remove_instance_variable(arrow_attr_sym) if self.instance_variable_get(arrow_attr_sym)
else
self.instance_variable_set(arrow_attr_sym, v)
end
end
end
|
#uploader ⇒ Object
293
294
295
|
# File 'lib/zm/client/account/account.rb', line 293
def uploader
@uploader ||= Upload.new(self)
end
|
#used ⇒ Object
121
122
123
|
# File 'lib/zm/client/account/account.rb', line 121
def used
@used ||= sac.get_mailbox(id)[:Body][:GetMailboxResponse][:mbox].first[:s]
end
|