Class: Zm::Client::Base::MailboxObject
Overview
Abstract Class for Account and Resource
Instance Attribute Summary collapse
Attributes inherited from Object
#id, #name, #parent
Instance Method Summary
collapse
#soap_admin_connector
Methods inherited from Object
#clone, #initialize, #inspect, #instance_variables_map, #logger, #recorded?, #save!, #to_h, #to_s, #update_attribute
Instance Attribute Details
#carLicense ⇒ Object
Returns the value of attribute carLicense.
29
30
31
|
# File 'lib/zm/client/base/mailbox_object.rb', line 29
def carLicense
@carLicense
end
|
#domain_key ⇒ Object
131
132
133
134
135
|
# File 'lib/zm/client/base/mailbox_object.rb', line 131
def domain_key
return @domain_key if defined?(@domain_key)
@parent.domain_key(domain_name)
end
|
Returns the value of attribute home_url.
29
30
31
|
# File 'lib/zm/client/base/mailbox_object.rb', line 29
def home_url
@home_url
end
|
Returns the value of attribute password.
29
30
31
|
# File 'lib/zm/client/base/mailbox_object.rb', line 29
def password
@password
end
|
#public_url ⇒ Object
Returns the value of attribute public_url.
29
30
31
|
# File 'lib/zm/client/base/mailbox_object.rb', line 29
def public_url
@public_url
end
|
76
77
78
|
# File 'lib/zm/client/base/mailbox_object.rb', line 76
def used
@used || used!
end
|
Instance Method Details
#account_content_by ⇒ Object
173
174
175
|
# File 'lib/zm/client/base/mailbox_object.rb', line 173
def account_content_by
@id ? [@id, :id] : [@name, :name]
end
|
#account_login ⇒ Object
145
146
147
148
149
150
151
152
153
|
# File 'lib/zm/client/base/mailbox_object.rb', line 145
def account_login
soap_account_connector.token = nil
if password
account_login_password
else
account_login_preauth
end
end
|
#account_login_password ⇒ Object
164
165
166
167
168
169
170
171
|
# File 'lib/zm/client/base/mailbox_object.rb', line 164
def account_login_password
logger.info 'Get Account session token by password access'
raise ZmError, 'password is required to login !' if password.nil?
content, by = account_content_by
self.token = soap_account_connector.auth_password(content, by, @password)
end
|
#account_login_preauth(expires = 0) ⇒ Object
155
156
157
158
159
160
161
162
|
# File 'lib/zm/client/base/mailbox_object.rb', line 155
def account_login_preauth(expires = 0)
logger.info 'Get Account session token by preauth access'
raise ZmError, 'domain key is required to login !' if domain_key.nil?
content, by = account_content_by
self.token = soap_account_connector.auth_preauth(content, by, expires, domain_key)
end
|
#aces ⇒ Object
Also known as:
rights
257
258
259
260
261
|
# File 'lib/zm/client/base/mailbox_object.rb', line 257
def aces
return @aces if defined? @aces
@aces = AcesCollection.new(self)
end
|
#admin_login ⇒ Object
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/zm/client/base/mailbox_object.rb', line 177
def admin_login
logger.info 'Get Account session token by Delegate access'
soap_request = SoapElement.admin(SoapAdminConstants::DELEGATE_AUTH_REQUEST)
node_account = SoapElement.create(SoapConstants::ACCOUNT)
if recorded?
node_account.add_attribute(SoapConstants::BY, SoapConstants::ID).add_content(@id)
else
node_account.add_attribute(SoapConstants::BY, SoapConstants::NAME).add_content(@name)
end
soap_request.add_node(node_account)
self.token = sac.invoke(soap_request)[:DelegateAuthResponse][:authToken].first[:_content]
end
|
#alive? ⇒ Boolean
118
119
120
121
122
123
124
125
|
# File 'lib/zm/client/base/mailbox_object.rb', line 118
def alive?
soap_request = SoapElement.mail(SoapMailConstants::NO_OP_REQUEST)
soap_connector.invoke(soap_request)
true
rescue Zm::Client::SoapError => e
logger.warn "Mailbox session token alive ? #{e.message}"
false
end
|
#appointments ⇒ Object
239
240
241
242
243
|
# File 'lib/zm/client/base/mailbox_object.rb', line 239
def appointments
return @appointments if defined? @appointments
@appointments = AppointmentsCollection.new(self)
end
|
#build_uploader ⇒ Object
#################################################################
351
352
353
354
355
356
|
# File 'lib/zm/client/base/mailbox_object.rb', line 351
def build_uploader
tmp_token = soap_connector&.token
raise ZmError, 'token have to be set to instance Upload class' unless tmp_token
Upload.new(rest_url, tmp_token, is_token_admin: soap_connector.is_a?(SoapAdminConnector), **rest_options)
end
|
233
234
235
236
237
|
# File 'lib/zm/client/base/mailbox_object.rb', line 233
def contacts
return @contacts if defined? @contacts
@contacts = ContactsCollection.new(self)
end
|
#data_sources ⇒ Object
300
301
302
303
304
|
# File 'lib/zm/client/base/mailbox_object.rb', line 300
def data_sources
return @data_sources if defined? @data_sources
@data_sources = DataSourcesCollection.new(self)
end
|
#dls_owner ⇒ Object
282
283
284
285
286
|
# File 'lib/zm/client/base/mailbox_object.rb', line 282
def dls_owner
return @dls_owner if defined? @dls_owner
@dls_owner = AccountDlsOwnerCollection.new(self)
end
|
#documents ⇒ Object
270
271
272
273
274
|
# File 'lib/zm/client/base/mailbox_object.rb', line 270
def documents
return @documents if defined? @documents
@documents = DocumentsCollection.new(self)
end
|
#domain_name ⇒ Object
58
59
60
61
62
|
# File 'lib/zm/client/base/mailbox_object.rb', line 58
def domain_name
return @domain_name if defined? @domain_name
@domain_name = @name.split('@').last
end
|
#filter_rules ⇒ Object
288
289
290
291
292
|
# File 'lib/zm/client/base/mailbox_object.rb', line 288
def filter_rules
return @filter_rules if defined? @filter_rules
@filter_rules = FilterRulesCollection.new(self)
end
|
203
204
205
206
207
|
# File 'lib/zm/client/base/mailbox_object.rb', line 203
def folders
return @folders if defined? @folders
@folders = FoldersCollection.new(self)
end
|
#identities ⇒ Object
221
222
223
224
225
|
# File 'lib/zm/client/base/mailbox_object.rb', line 221
def identities
return @identities if defined? @identities
@identities = IdentitiesCollection.new(self)
end
|
64
65
66
67
68
|
# File 'lib/zm/client/base/mailbox_object.rb', line 64
def infos
return @infos if defined? @infos
@infos = MailboxInfosCollection.new(self)
end
|
#is_external_transport? ⇒ Boolean
337
338
339
340
341
|
# File 'lib/zm/client/base/mailbox_object.rb', line 337
def is_external_transport?
return false unless zimbraMailTransport
zimbraMailTransport.start_with?(SoapConstants::SMTP)
end
|
#is_local_transport? ⇒ Boolean
331
332
333
334
335
|
# File 'lib/zm/client/base/mailbox_object.rb', line 331
def is_local_transport?
return false unless zimbraMailTransport
zimbraMailTransport.start_with?(SoapConstants::LMTP)
end
|
#last_logon ⇒ Object
343
344
345
346
347
|
# File 'lib/zm/client/base/mailbox_object.rb', line 343
def last_logon
return @last_logon if defined? @last_logon
@last_logon = Time.parse(zimbraLastLogonTimestamp) unless zimbraLastLogonTimestamp.nil?
end
|
#local_transport ⇒ Object
321
322
323
324
325
|
# File 'lib/zm/client/base/mailbox_object.rb', line 321
def local_transport
raise Zm::Client::ZmError, 'zimbraMailHost is null' if zimbraMailHost.nil?
"lmtp:#{zimbraMailHost}:7025"
end
|
#local_transport! ⇒ Object
327
328
329
|
# File 'lib/zm/client/base/mailbox_object.rb', line 327
def local_transport!
update!(zimbraMailTransport: local_transport)
end
|
#logged? ⇒ Boolean
114
115
116
|
# File 'lib/zm/client/base/mailbox_object.rb', line 114
def logged?
!token.nil? && !token.expired?
end
|
#logged_and_alive? ⇒ Boolean
127
128
129
|
# File 'lib/zm/client/base/mailbox_object.rb', line 127
def logged_and_alive?
logged? && alive?
end
|
137
138
139
140
141
142
143
|
# File 'lib/zm/client/base/mailbox_object.rb', line 137
def login
if parent_logged?
admin_login
else
account_login
end
end
|
#mailbox_infos ⇒ Object
92
93
94
95
96
97
|
# File 'lib/zm/client/base/mailbox_object.rb', line 92
def mailbox_infos
soap_request = SoapElement.admin(SoapAdminConstants::GET_MAILBOX_REQUEST)
node_mbox = SoapElement.create(SoapConstants::MBOX).add_attribute(SoapConstants::ID, @id)
soap_request.add_node(node_mbox)
sac.invoke(soap_request)[:GetMailboxResponse][:mbox].first
end
|
84
85
86
|
# File 'lib/zm/client/base/mailbox_object.rb', line 84
def mbxid
@mbxid || mbxid!
end
|
88
89
90
|
# File 'lib/zm/client/base/mailbox_object.rb', line 88
def mbxid!
@mbxid = mailbox_infos[:mbxid]
end
|
#memberships ⇒ Object
276
277
278
279
280
|
# File 'lib/zm/client/base/mailbox_object.rb', line 276
def memberships
return @memberships if defined? @memberships
@memberships = AccountDlsMembershipCollection.new(self)
end
|
################################################################# Associations #################################################################
197
198
199
200
201
|
# File 'lib/zm/client/base/mailbox_object.rb', line 197
def messages
return @messages if defined? @messages
@messages = MessagesCollection.new(self)
end
|
#mountpoints ⇒ Object
209
210
211
212
213
|
# File 'lib/zm/client/base/mailbox_object.rb', line 209
def mountpoints
return @mountpoints if defined? @mountpoints
@mountpoints = MountPointsCollection.new(self)
end
|
#outgoing_filter_rules ⇒ Object
294
295
296
297
298
|
# File 'lib/zm/client/base/mailbox_object.rb', line 294
def outgoing_filter_rules
return @outgoing_filter_rules if defined? @outgoing_filter_rules
@outgoing_filter_rules = OutgoingFilterRulesCollection.new(self)
end
|
#password!(new_password = nil) ⇒ Object
################################################################# SOAP Actions #################################################################
310
311
312
313
314
315
316
317
318
319
|
# File 'lib/zm/client/base/mailbox_object.rb', line 310
def password!(new_password = nil)
new_password ||= @password
return false if new_password.nil?
soap_request = SoapElement.admin(SoapAdminConstants::SET_PASSWORD_REQUEST)
soap_request.add_attributes({ id: @id, newPassword: new_password })
sac.invoke(soap_request)
@password = new_password
end
|
70
71
72
73
74
|
# File 'lib/zm/client/base/mailbox_object.rb', line 70
def prefs
return @prefs if defined? @prefs
@prefs = MailboxPrefsCollection.new(self)
end
|
#rest_account_url ⇒ Object
387
388
389
390
391
392
393
394
395
|
# File 'lib/zm/client/base/mailbox_object.rb', line 387
def rest_account_url
if soap_config.zimbra_public_url
File.join(soap_config.zimbra_public_url, 'home', @name)
elsif home_url
home_url
else
raise ZmError, 'impossible to set rest_account_url'
end
end
|
#rest_admin_url ⇒ Object
381
382
383
384
385
|
# File 'lib/zm/client/base/mailbox_object.rb', line 381
def rest_admin_url
raise ZmError, 'impossible to set rest_admin_url' unless soap_config.zimbra_admin_url
File.join(soap_config.zimbra_admin_url, 'home', @name)
end
|
#rest_options ⇒ Object
358
359
360
361
362
363
364
365
366
367
|
# File 'lib/zm/client/base/mailbox_object.rb', line 358
def rest_options
if soap_config
{
timeout: soap_config.timeout,
verbose: soap_config.logger.debug?
}
else
{}
end
end
|
369
370
371
372
373
374
375
376
377
378
379
|
# File 'lib/zm/client/base/mailbox_object.rb', line 369
def rest_url
raise ZmError, 'name attribute is requuired for REST Url' unless @name
if logged?
rest_account_url
elsif parent_logged?
rest_admin_url
else
raise ZmError, 'impossible to set rest_url'
end
end
|
#search_folders ⇒ Object
215
216
217
218
219
|
# File 'lib/zm/client/base/mailbox_object.rb', line 215
def search_folders
return @search_folders if defined? @search_folders
@search_folders = SearchFoldersCollection.new(self)
end
|
227
228
229
230
231
|
# File 'lib/zm/client/base/mailbox_object.rb', line 227
def shares
return @shares if defined? @shares
@shares = SharesCollection.new(self)
end
|
#signatures ⇒ Object
264
265
266
267
268
|
# File 'lib/zm/client/base/mailbox_object.rb', line 264
def signatures
return @signatures if defined? @signatures
@signatures = SignaturesCollection.new(self)
end
|
#soap_account_connector ⇒ Object
32
33
34
35
36
|
# File 'lib/zm/client/base/mailbox_object.rb', line 32
def soap_account_connector
return @soap_account_connector if defined? @soap_account_connector
@soap_account_connector = SoapAccountConnector.create(soap_config)
end
|
#soap_connector ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/zm/client/base/mailbox_object.rb', line 38
def soap_connector
return @soap_connector if defined? @soap_connector
if logged?
@soap_connector = soap_account_connector
elsif (@id || @name) && @parent&.logged?
@soap_connector = @parent.soap_admin_connector.clone
if @id
@soap_connector.context.account(:id, @id)
else
@soap_connector.context.account(:name, @name)
end
else
raise ZmError, 'SoapConnector not defined'
end
@soap_connector
end
|
245
246
247
248
249
|
# File 'lib/zm/client/base/mailbox_object.rb', line 245
def tags
return @tags if defined? @tags
@tags = TagsCollection.new(self)
end
|
251
252
253
254
255
|
# File 'lib/zm/client/base/mailbox_object.rb', line 251
def tasks
return @tasks if defined? @tasks
@tasks = TasksCollection.new(self)
end
|
################################################################# Authentication #################################################################
103
104
105
106
107
|
# File 'lib/zm/client/base/mailbox_object.rb', line 103
def token
return @token if defined? @token
@token = (Token.new(soap_account_connector.token) if soap_account_connector.token)
end
|
#token=(value) ⇒ Object
109
110
111
112
|
# File 'lib/zm/client/base/mailbox_object.rb', line 109
def token=(value)
@token = Token.new(soap_account_connector.token = value)
@soap_connector = soap_account_connector
end
|
80
81
82
|
# File 'lib/zm/client/base/mailbox_object.rb', line 80
def used!
@used = mailbox_infos[:s]
end
|