Class: Zm::Client::Account
Overview
objectClass: zimbraAccount
Instance Attribute Summary collapse
-
#carLicense ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense.
-
#domainkey ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense.
-
#home_url ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense.
-
#id ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense.
-
#name ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense.
-
#password ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense.
-
#token ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense.
Attributes inherited from Base::Object
#grantee_type, #parent
Instance Method Summary
collapse
#soap_account_connector, #soap_admin_connector, #to_h
#arrow_name, #clone, #concat, #convert_json_string_value, #disable_builder, #enable_builder, #instance_variables_array, #instance_variables_hash, #logger, #recorded?, #save!, #to_s, #use_builder?
Constructor Details
#initialize(parent) ⇒ Account
Returns a new instance of Account.
33
34
35
36
37
|
# File 'lib/zm/client/account/account.rb', line 33
def initialize(parent)
extend(AccountCommon)
super(parent)
@grantee_type = 'usr'.freeze
end
|
Instance Attribute Details
#carLicense ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
31
32
33
|
# File 'lib/zm/client/account/account.rb', line 31
def carLicense
@carLicense
end
|
#domainkey ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
31
32
33
|
# File 'lib/zm/client/account/account.rb', line 31
def domainkey
@domainkey
end
|
#home_url ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
31
32
33
|
# File 'lib/zm/client/account/account.rb', line 31
def home_url
@home_url
end
|
#id ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
31
32
33
|
# File 'lib/zm/client/account/account.rb', line 31
def id
@id
end
|
#name ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
31
32
33
|
# File 'lib/zm/client/account/account.rb', line 31
def name
@name
end
|
#password ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
31
32
33
|
# File 'lib/zm/client/account/account.rb', line 31
def password
@password
end
|
#token ⇒ Object
attr_reader :name, :id, :token attr_writer :home_url attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
31
32
33
|
# File 'lib/zm/client/account/account.rb', line 31
def token
@token
end
|
Instance Method Details
#account_login ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/zm/client/account/account.rb', line 73
def account_login
if password
account_login_password
else
account_login_preauth
end
end
|
#account_login_password ⇒ Object
88
89
90
91
92
|
# File 'lib/zm/client/account/account.rb', line 88
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
81
82
83
84
85
86
|
# File 'lib/zm/client/account/account.rb', line 81
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
182
183
184
|
# File 'lib/zm/client/account/account.rb', line 182
def aces
@aces ||= AcesCollection.new(self)
end
|
#add_alias!(email) ⇒ Object
274
275
276
277
|
# File 'lib/zm/client/account/account.rb', line 274
def add_alias!(email)
sac.add_account_alias(@id, email)
aliases.push(email)
end
|
#admin_login ⇒ Object
94
95
96
|
# File 'lib/zm/client/account/account.rb', line 94
def admin_login
@token = sac.delegate_auth(@name)
end
|
#aliases ⇒ Object
264
265
266
|
# File 'lib/zm/client/account/account.rb', line 264
def aliases
@aliases ||= set_aliases
end
|
#all_instance_variable_keys ⇒ Object
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
51
52
53
|
# File 'lib/zm/client/account/account.rb', line 51
def all_instance_variable_keys
AccountCommon::ZM_ACCOUNT_ATTRS
end
|
#appointments ⇒ Object
170
171
172
|
# File 'lib/zm/client/account/account.rb', line 170
def appointments
@appointments ||= AppointmentsCollection.new(self)
end
|
#calendar_folders ⇒ Object
207
208
209
|
# File 'lib/zm/client/account/account.rb', line 207
def calendar_folders
@calendar_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::APPOINTMENT.to_s }
end
|
203
204
205
|
# File 'lib/zm/client/account/account.rb', line 203
def contact_folders
@contact_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::CONTACT.to_s }
end
|
166
167
168
|
# File 'lib/zm/client/account/account.rb', line 166
def contacts
@contacts ||= ContactsCollection.new(self)
end
|
#cos ⇒ Object
124
125
126
|
# File 'lib/zm/client/account/account.rb', line 124
def cos
@cos ||= @parent.coses.find_by(id: zimbraCOSId)
end
|
#create! ⇒ Object
249
250
251
252
253
254
255
256
|
# File 'lib/zm/client/account/account.rb', line 249
def create!
rep = sac.create_account(
@name,
@password,
instance_variables_array(attrs_write)
)
@id = rep[:Body][:CreateAccountResponse][:account].first[:id]
end
|
#created_at ⇒ Object
319
320
321
|
# File 'lib/zm/client/account/account.rb', line 319
def created_at
@created_at ||= Time.parse zimbraCreateTimestamp unless zimbraCreateTimestamp.nil?
end
|
#data_sources ⇒ Object
191
192
193
|
# File 'lib/zm/client/account/account.rb', line 191
def data_sources
@data_sources ||= DataSourcesCollection.new sac, self
end
|
#delete! ⇒ Object
219
220
221
|
# File 'lib/zm/client/account/account.rb', line 219
def delete!
sac.delete_account(@id)
end
|
#dls_owner ⇒ Object
342
343
344
|
# File 'lib/zm/client/account/account.rb', line 342
def dls_owner
@dls_owner ||= AccountDlsOwnerCollection.new(self)
end
|
#document_folders ⇒ Object
215
216
217
|
# File 'lib/zm/client/account/account.rb', line 215
def document_folders
@document_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::DOCUMENT.to_s }
end
|
#documents ⇒ Object
195
196
197
|
# File 'lib/zm/client/account/account.rb', line 195
def documents
@documents ||= DocumentsCollection.new(self)
end
|
#domain_key ⇒ Object
106
107
108
|
# File 'lib/zm/client/account/account.rb', line 106
def domain_key
@domainkey ||= @parent.domain_key(domain_name)
end
|
#domain_name ⇒ Object
102
103
104
|
# File 'lib/zm/client/account/account.rb', line 102
def domain_name
@domain_name ||= @name.split('@').last
end
|
#flush_cache! ⇒ Object
323
324
325
|
# File 'lib/zm/client/account/account.rb', line 323
def flush_cache!
sac.flush_cache('account', 1, @id)
end
|
#folders ⇒ Object
146
147
148
|
# File 'lib/zm/client/account/account.rb', line 146
def folders
@folders ||= FoldersCollection.new(self)
end
|
#identities ⇒ Object
158
159
160
|
# File 'lib/zm/client/account/account.rb', line 158
def identities
@identities ||= IdentitiesCollection.new(self)
end
|
#infos ⇒ Object
110
111
112
|
# File 'lib/zm/client/account/account.rb', line 110
def infos
@infos || read_infos
end
|
#init_from_json(json) ⇒ Object
350
351
352
353
354
|
# File 'lib/zm/client/account/account.rb', line 350
def init_from_json(json)
@used = json[:used] if json[:used]
@zimbraMailQuota = json[:limit] if json[:limit]
super(json)
end
|
#is_external_transport? ⇒ Boolean
305
306
307
308
309
|
# File 'lib/zm/client/account/account.rb', line 305
def is_external_transport?
return nil unless zimbraMailTransport
zimbraMailTransport.start_with?('smtp')
end
|
#is_local_transport? ⇒ Boolean
299
300
301
302
303
|
# File 'lib/zm/client/account/account.rb', line 299
def is_local_transport?
return nil unless zimbraMailTransport
zimbraMailTransport.start_with?('lmtp')
end
|
#is_on_to_move?(server) ⇒ Boolean
333
334
335
336
|
# File 'lib/zm/client/account/account.rb', line 333
def is_on_to_move?(server)
resp = sac.query_mailbox_move(@name, server.id)
resp[:Body][:QueryMailboxMoveResponse][:account].nil?
end
|
#last_logon ⇒ Object
315
316
317
|
# File 'lib/zm/client/account/account.rb', line 315
def last_logon
@last_logon ||= Time.parse zimbraLastLogonTimestamp unless zimbraLastLogonTimestamp.nil?
end
|
#local_transport ⇒ Object
289
290
291
292
293
|
# File 'lib/zm/client/account/account.rb', line 289
def local_transport
raise Zm::Client::SoapError, 'zimbraMailHost is null' if zimbraMailHost.nil?
"lmtp:#{zimbraMailHost}:7025"
end
|
#local_transport! ⇒ Object
295
296
297
|
# File 'lib/zm/client/account/account.rb', line 295
def local_transport!
update!(zimbraMailTransport: local_transport)
end
|
#logged? ⇒ Boolean
61
62
63
|
# File 'lib/zm/client/account/account.rb', line 61
def logged?
!@token.nil?
end
|
#login ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/zm/client/account/account.rb', line 65
def login
if @parent.logged?
admin_login
else
account_login
end
end
|
#memberships ⇒ Object
338
339
340
|
# File 'lib/zm/client/account/account.rb', line 338
def memberships
@memberships ||= AccountDlsMembershipCollection.new(self)
end
|
#message_folders ⇒ Object
199
200
201
|
# File 'lib/zm/client/account/account.rb', line 199
def message_folders
@message_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::MESSAGE.to_s }
end
|
#messages ⇒ Object
142
143
144
|
# File 'lib/zm/client/account/account.rb', line 142
def messages
@messages ||= MessagesCollection.new(self)
end
|
#modify! ⇒ Object
242
243
244
245
246
247
|
# File 'lib/zm/client/account/account.rb', line 242
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
150
151
152
|
# File 'lib/zm/client/account/account.rb', line 150
def mountpoints
@mountpointss ||= MountPointsCollection.new(self)
end
|
#move_mailbox(server) ⇒ Object
327
328
329
330
331
|
# File 'lib/zm/client/account/account.rb', line 327
def move_mailbox(server)
raise Zm::Client::SoapError, 'zimbraMailHost is null' if zimbraMailHost.nil?
sac.move_mailbox(@name, zimbraMailHost, server.name, server.id)
end
|
#password!(new_password) ⇒ Object
223
224
225
226
|
# File 'lib/zm/client/account/account.rb', line 223
def password!(new_password)
sac.set_password(@id, new_password)
@password = new_password
end
|
#public_url ⇒ Object
132
133
134
135
|
# File 'lib/zm/client/account/account.rb', line 132
def public_url
infos if @infos.nil?
@public_url
end
|
#ranking(op, email = nil) ⇒ Object
346
347
348
|
# File 'lib/zm/client/account/account.rb', line 346
def ranking(op, email = nil)
sacc.ranking_action(@token, op, email)
end
|
#read_infos ⇒ Object
114
115
116
117
118
119
120
121
122
|
# File 'lib/zm/client/account/account.rb', line 114
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]
@infos
end
|
#remove_alias!(email) ⇒ Object
279
280
281
282
|
# File 'lib/zm/client/account/account.rb', line 279
def remove_alias!(email)
sac.remove_account_alias(@id, email)
aliases.delete(email)
end
|
#rename!(email) ⇒ Object
284
285
286
287
|
# File 'lib/zm/client/account/account.rb', line 284
def rename!(email)
sac.rename_account(@id, email)
@name = email
end
|
#rest_account_connector ⇒ Object
Also known as:
rac
55
56
57
|
# File 'lib/zm/client/account/account.rb', line 55
def rest_account_connector
@rest_account_connector ||= RestAccountConnector.new
end
|
#search_folders ⇒ Object
154
155
156
|
# File 'lib/zm/client/account/account.rb', line 154
def search_folders
@search_folders ||= SearchFoldersCollection.new(self)
end
|
#set_aliases ⇒ Object
268
269
270
271
272
|
# File 'lib/zm/client/account/account.rb', line 268
def set_aliases
return [] if zimbraMailAlias.nil?
return [zimbraMailAlias] if zimbraMailAlias.is_a?(String)
zimbraMailAlias
end
|
#set_password(new_password = nil) ⇒ Object
258
259
260
261
262
|
# File 'lib/zm/client/account/account.rb', line 258
def set_password(new_password = nil)
new_password ||= @password
sac.set_password(@id, new_password)
@password = new_password
end
|
#shares ⇒ Object
162
163
164
|
# File 'lib/zm/client/account/account.rb', line 162
def shares
@shares ||= SharesCollection.new(self)
end
|
#signatures ⇒ Object
187
188
189
|
# File 'lib/zm/client/account/account.rb', line 187
def signatures
@signatures ||= SignaturesCollection.new(self)
end
|
174
175
176
|
# File 'lib/zm/client/account/account.rb', line 174
def tags
@tags ||= TagsCollection.new(self)
end
|
#task_folders ⇒ Object
211
212
213
|
# File 'lib/zm/client/account/account.rb', line 211
def task_folders
@task_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::TASK.to_s }
end
|
#tasks ⇒ Object
178
179
180
|
# File 'lib/zm/client/account/account.rb', line 178
def tasks
@tasks ||= TasksCollection.new(self)
end
|
98
99
100
|
# File 'lib/zm/client/account/account.rb', line 98
def token_metadata
@token_metadata ||= TokenMetaData.new(@token)
end
|
#update!(hash) ⇒ Object
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# File 'lib/zm/client/account/account.rb', line 228
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
311
312
313
|
# File 'lib/zm/client/account/account.rb', line 311
def uploader
@uploader ||= Upload.new(self)
end
|
#used ⇒ Object
128
129
130
|
# File 'lib/zm/client/account/account.rb', line 128
def used
@used ||= sac.get_mailbox(id)[:Body][:GetMailboxResponse][:mbox].first[:s]
end
|