zm-ruby-client 0.18.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +2 -2
- data/README.md +7 -0
- data/lib/zm/client/account/account.rb +31 -308
- data/lib/zm/client/account/account_aliases_collection.rb +52 -0
- data/lib/zm/client/account/account_dls_membership_collection.rb +4 -1
- data/lib/zm/client/account/account_dls_owner_collection.rb +8 -1
- data/lib/zm/client/account/account_jsns_builder.rb +77 -0
- data/lib/zm/client/account/account_jsns_initializer.rb +9 -24
- data/lib/zm/client/account/accounts_builder.rb +0 -1
- data/lib/zm/client/account/accounts_collection.rb +32 -8
- data/lib/zm/client/account.rb +1 -0
- data/lib/zm/client/ace/ace.rb +6 -22
- data/lib/zm/client/ace/ace_jsns_builder.rb +15 -16
- data/lib/zm/client/ace/ace_jsns_initializer.rb +0 -1
- data/lib/zm/client/ace/aces_builder.rb +0 -1
- data/lib/zm/client/ace/aces_collection.rb +2 -18
- data/lib/zm/client/appointment/appointment.rb +38 -30
- data/lib/zm/client/appointment/appointment_jsns_builder.rb +22 -34
- data/lib/zm/client/appointment/appointment_jsns_initializer.rb +6 -3
- data/lib/zm/client/appointment/appointments_builder.rb +6 -18
- data/lib/zm/client/appointment/appointments_collection.rb +25 -4
- data/lib/zm/client/backup/backup.rb +4 -32
- data/lib/zm/client/backup/backup_jsns_initializer.rb +26 -0
- data/lib/zm/client/backup/backups_builder.rb +8 -13
- data/lib/zm/client/backup/backups_collection.rb +2 -1
- data/lib/zm/client/backup.rb +1 -0
- data/lib/zm/client/base/account_search_objects_collection.rb +34 -13
- data/lib/zm/client/base/admin_objects_collection.rb +82 -17
- data/lib/zm/client/base/base_account_jsns_builder.rb +98 -0
- data/lib/zm/client/base/base_jsns_builder.rb +47 -0
- data/lib/zm/client/base/base_jsns_initializer.rb +43 -12
- data/lib/zm/client/base/ldap_filter.rb +20 -5
- data/lib/zm/client/base/mailbox_infos_collection.rb +68 -0
- data/lib/zm/client/base/mailbox_object.rb +299 -0
- data/lib/zm/client/base/mailbox_prefs_collection.rb +75 -0
- data/lib/zm/client/base/object.rb +28 -62
- data/lib/zm/client/base/objects_builder.rb +4 -10
- data/lib/zm/client/base/objects_collection.rb +13 -10
- data/lib/zm/client/base/zimbra_attribute.rb +10 -8
- data/lib/zm/client/base/zimbra_attributes_collection.rb +154 -10
- data/lib/zm/client/base.rb +5 -5
- data/lib/zm/client/cluster/cluster.rb +43 -39
- data/lib/zm/client/cluster/cluster_config.rb +5 -5
- data/lib/zm/client/common/recipients.rb +3 -3
- data/lib/zm/client/common/token_metadata.rb +4 -1
- data/lib/zm/client/common/utils.rb +57 -0
- data/lib/zm/client/common.rb +2 -1
- data/lib/zm/client/connector/rest_account.rb +15 -28
- data/lib/zm/client/connector/soap_account.rb +38 -441
- data/lib/zm/client/connector/soap_admin.rb +16 -552
- data/lib/zm/client/connector/soap_base.rb +30 -21
- data/lib/zm/client/connector/soap_error.rb +1 -3
- data/lib/zm/client/constant.rb +21 -11
- data/lib/zm/client/contact/contact.rb +42 -83
- data/lib/zm/client/contact/contact_jsns_builder.rb +60 -0
- data/lib/zm/client/contact/contact_jsns_initializer.rb +78 -0
- data/lib/zm/client/contact/contact_member.rb +29 -28
- data/lib/zm/client/contact/contact_members_collection.rb +44 -0
- data/lib/zm/client/contact/contacts_builder.rb +8 -1
- data/lib/zm/client/contact/contacts_collection.rb +17 -1
- data/lib/zm/client/contact/group_contact_jsns_builder.rb +51 -0
- data/lib/zm/client/contact/mod_group_contact.rb +4 -67
- data/lib/zm/client/contact.rb +5 -1
- data/lib/zm/client/cos/cos.rb +35 -40
- data/lib/zm/client/cos/cos_accounts_collection.rb +19 -0
- data/lib/zm/client/cos/cos_domains_collection.rb +20 -0
- data/lib/zm/client/cos/cos_jsns_builder.rb +72 -0
- data/lib/zm/client/cos/cos_jsns_initializer.rb +29 -0
- data/lib/zm/client/cos/cos_servers_collection.rb +60 -0
- data/lib/zm/client/cos/coses_builder.rb +8 -1
- data/lib/zm/client/cos/coses_collection.rb +8 -5
- data/lib/zm/client/cos.rb +5 -0
- data/lib/zm/client/datasource/datasource.rb +69 -0
- data/lib/zm/client/datasource/datasource_jsns_builder.rb +32 -0
- data/lib/zm/client/datasource/datasource_jsns_initializer.rb +27 -0
- data/lib/zm/client/datasource/datasources_builder.rb +29 -0
- data/lib/zm/client/datasource/datasources_collection.rb +21 -0
- data/lib/zm/client/datasource.rb +7 -0
- data/lib/zm/client/distributionlist/distributionlist.rb +52 -118
- data/lib/zm/client/distributionlist/distributionlist_aces_collection.rb +31 -0
- data/lib/zm/client/distributionlist/distributionlist_aliases_collection.rb +53 -0
- data/lib/zm/client/distributionlist/distributionlist_jsns_builder.rb +82 -0
- data/lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb +32 -0
- data/lib/zm/client/distributionlist/distributionlist_members_collection.rb +47 -0
- data/lib/zm/client/distributionlist/distributionlist_owners_collection.rb +52 -0
- data/lib/zm/client/distributionlist/distributionlists_builder.rb +8 -1
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +8 -9
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +4 -1
- data/lib/zm/client/distributionlist.rb +2 -0
- data/lib/zm/client/document/document.rb +27 -24
- data/lib/zm/client/document/document_jsns_builder.rb +18 -0
- data/lib/zm/client/document/document_jsns_initializer.rb +44 -0
- data/lib/zm/client/document/documents_builder.rb +6 -16
- data/lib/zm/client/document/documents_collection.rb +17 -67
- data/lib/zm/client/document.rb +2 -0
- data/lib/zm/client/domain/domain.rb +39 -55
- data/lib/zm/client/domain/domain_accounts_collection.rb +1 -1
- data/lib/zm/client/domain/domain_distributionlists_collection.rb +13 -0
- data/lib/zm/client/domain/domain_jsns_builder.rb +69 -0
- data/lib/zm/client/domain/domain_jsns_initializer.rb +25 -0
- data/lib/zm/client/domain/domain_resources_collection.rb +13 -0
- data/lib/zm/client/domain/domains_builder.rb +8 -1
- data/lib/zm/client/domain/domains_collection.rb +7 -7
- data/lib/zm/client/domain.rb +4 -0
- data/lib/zm/client/filter_rule.rb +7 -0
- data/lib/zm/client/filter_rules/filter_rule.rb +10 -0
- data/lib/zm/client/filter_rules/filter_rule_jsns_initializer.rb +24 -0
- data/lib/zm/client/filter_rules/filter_rules_builder.rb +21 -0
- data/lib/zm/client/filter_rules/filter_rules_collection.rb +21 -0
- data/lib/zm/client/filter_rules/outgoing_filter_rules_collection.rb +15 -0
- data/lib/zm/client/folder/folder.rb +77 -61
- data/lib/zm/client/folder/folder_grant.rb +34 -14
- data/lib/zm/client/folder/folder_grant_jsns_builder.rb +15 -4
- data/lib/zm/client/folder/folder_grants_collection.rb +36 -2
- data/lib/zm/client/folder/folder_jsns_builder.rb +22 -48
- data/lib/zm/client/folder/folder_jsns_initializer.rb +34 -17
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +2 -3
- data/lib/zm/client/folder/folder_retention_policy.rb +0 -1
- data/lib/zm/client/folder/folders_builder.rb +7 -10
- data/lib/zm/client/folder/folders_collection.rb +5 -2
- data/lib/zm/client/folder/folders_jsns_builder.rb +3 -1
- data/lib/zm/client/folder/mod_document_folder.rb +10 -6
- data/lib/zm/client/folder.rb +1 -1
- data/lib/zm/client/identity/identities_builder.rb +8 -1
- data/lib/zm/client/identity/identities_collection.rb +2 -1
- data/lib/zm/client/identity/identity.rb +34 -42
- data/lib/zm/client/identity/identity_jsns_builder.rb +57 -0
- data/lib/zm/client/identity/identity_jsns_initializer.rb +29 -0
- data/lib/zm/client/identity.rb +3 -1
- data/lib/zm/client/license/license.rb +9 -22
- data/lib/zm/client/license/license_jsns_initializer.rb +20 -0
- data/lib/zm/client/license/licenses_collection.rb +3 -13
- data/lib/zm/client/license.rb +2 -1
- data/lib/zm/client/message/attachments_collection.rb +55 -0
- data/lib/zm/client/message/message.rb +36 -264
- data/lib/zm/client/message/message_flags.rb +107 -0
- data/lib/zm/client/message/message_jsns_builder.rb +85 -0
- data/lib/zm/client/message/message_jsns_initializer.rb +71 -0
- data/lib/zm/client/message/message_recipients.rb +59 -0
- data/lib/zm/client/message/messages_builder.rb +7 -18
- data/lib/zm/client/message/messages_collection.rb +17 -2
- data/lib/zm/client/message.rb +5 -0
- data/lib/zm/client/mountpoint/mountpoint.rb +43 -20
- data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +8 -53
- data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +22 -13
- data/lib/zm/client/mountpoint/mountpoints_builder.rb +4 -5
- data/lib/zm/client/mountpoint/mountpoints_collection.rb +1 -2
- data/lib/zm/client/mta_queue/mta_queue.rb +13 -28
- data/lib/zm/client/mta_queue/mta_queue_jsns_builder.rb +41 -0
- data/lib/zm/client/mta_queue/mta_queue_jsns_initializer.rb +23 -0
- data/lib/zm/client/mta_queue/mta_queues_builder.rb +4 -8
- data/lib/zm/client/mta_queue/mta_queues_collection.rb +8 -27
- data/lib/zm/client/mta_queue.rb +2 -0
- data/lib/zm/client/mta_queue_item/mta_queue_item.rb +4 -31
- data/lib/zm/client/mta_queue_item/mta_queue_item_jsns_initializer.rb +33 -0
- data/lib/zm/client/mta_queue_item/mta_queue_items_builder.rb +4 -9
- data/lib/zm/client/mta_queue_item/mta_queue_items_collection.rb +7 -42
- data/lib/zm/client/mta_queue_item.rb +2 -1
- data/lib/zm/client/resource/resource.rb +24 -91
- data/lib/zm/client/resource/resource_jsns_builder.rb +79 -0
- data/lib/zm/client/resource/resource_jsns_initializer.rb +29 -0
- data/lib/zm/client/resource/resources_builder.rb +8 -1
- data/lib/zm/client/resource/resources_collection.rb +9 -7
- data/lib/zm/client/resource.rb +2 -0
- data/lib/zm/client/search_folder/search_folder.rb +38 -16
- data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +38 -19
- data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +17 -13
- data/lib/zm/client/search_folder/search_folders_builder.rb +0 -1
- data/lib/zm/client/search_folder/search_folders_collection.rb +2 -1
- data/lib/zm/client/server/server.rb +16 -488
- data/lib/zm/client/server/server_jsns_initializer.rb +16 -0
- data/lib/zm/client/server/servers_builder.rb +8 -1
- data/lib/zm/client/server/servers_collection.rb +13 -5
- data/lib/zm/client/server.rb +1 -0
- data/lib/zm/client/share/share.rb +5 -43
- data/lib/zm/client/share/share_jsns_initializer.rb +32 -0
- data/lib/zm/client/share/share_mountpoints_collection.rb +38 -0
- data/lib/zm/client/share/shares_builder.rb +8 -1
- data/lib/zm/client/share/shares_collection.rb +11 -16
- data/lib/zm/client/share.rb +2 -0
- data/lib/zm/client/signature/signature.rb +25 -29
- data/lib/zm/client/signature/signature_jsns_builder.rb +31 -13
- data/lib/zm/client/signature/signature_jsns_initializer.rb +16 -12
- data/lib/zm/client/signature/signatures_builder.rb +1 -2
- data/lib/zm/client/signature/signatures_collection.rb +2 -1
- data/lib/zm/client/signature.rb +1 -1
- data/lib/zm/client/soap_request/account_soap_constants.rb +76 -0
- data/lib/zm/client/soap_request/admin_soap_constants.rb +214 -0
- data/lib/zm/client/soap_request/mail_soap_constants.rb +162 -0
- data/lib/zm/client/soap_request/soap_constants.rb +55 -0
- data/lib/zm/client/soap_request/soap_context.rb +38 -0
- data/lib/zm/client/soap_request/soap_element.rb +90 -0
- data/lib/zm/client/soap_request.rb +8 -0
- data/lib/zm/client/tag/account_object_tags_collection.rb +65 -0
- data/lib/zm/client/tag/tag.rb +34 -22
- data/lib/zm/client/tag/tag_jsns_builder.rb +14 -35
- data/lib/zm/client/tag/tag_jsns_initializer.rb +4 -6
- data/lib/zm/client/tag/tags_builder.rb +0 -1
- data/lib/zm/client/tag/tags_collection.rb +2 -1
- data/lib/zm/client/tag.rb +1 -0
- data/lib/zm/client/task/task.rb +18 -49
- data/lib/zm/client/task/task_jsns_initializer.rb +45 -0
- data/lib/zm/client/task/tasks_builder.rb +6 -16
- data/lib/zm/client/task/tasks_collection.rb +29 -0
- data/lib/zm/client/task.rb +1 -0
- data/lib/zm/client/upload/upload.rb +26 -30
- data/lib/zm/client/version.rb +3 -3
- data/lib/zm/client.rb +4 -1
- data/lib/zm/modules/base.rb +10 -0
- data/lib/zm/modules/belongs_to_folder.rb +37 -0
- data/lib/zm/modules/belongs_to_tag.rb +11 -0
- data/lib/zm/modules/common/zimbra-attrs.json +1 -1
- data/lib/zm/modules/has_soap_admin_connector.rb +12 -0
- data/lib/zm/modules/inspector.rb +24 -0
- data/lib/zm/modules/missing_method_static_collection.rb +13 -0
- data/lib/zm/modules/zm_logger.rb +3 -1
- data/lib/zm/modules/zm_model.rb +4 -2
- data/lib/zm/utils/thread_pool.rb +4 -2
- data/lib/zm-ruby-client.rb +2 -0
- data/zm-ruby-client.gemspec +12 -9
- metadata +93 -34
- data/lib/zm/client/base/account_object.rb +0 -51
- data/lib/zm/client/base/admin_object.rb +0 -51
- data/lib/zm/client/base/folder_object.rb +0 -41
- data/lib/zm/client/config.rb +0 -12
- data/lib/zm/client/data_source.rb +0 -5
- data/lib/zm/modules/common/account_common.rb +0 -71
- data/lib/zm/modules/common/cos_common.rb +0 -463
- data/lib/zm/modules/common/dl_common.rb +0 -38
- data/lib/zm/modules/common/identity_common.rb +0 -19
- data/lib/zm/modules/common/resource_common.rb +0 -59
- data/lib/zm/modules/common/signature_common.rb +0 -16
- data/lib/zm/modules/common/zimbra-attrs.json.bak +0 -1
- data/test/accounts.rb +0 -89
- data/test/ace.rb +0 -50
- data/test/cluster.rb +0 -41
- data/test/cluster_config.rb +0 -30
- data/test/cluster_zimbra_attributes.rb +0 -38
- data/test/coses.rb +0 -26
- data/test/domains.rb +0 -70
- data/test/folder.rb +0 -125
- data/test/folder_grant.rb +0 -51
- data/test/mountpoint.rb +0 -49
- data/test/retention_policies.rb +0 -40
- data/test/search_folder.rb +0 -67
- data/test/signature.rb +0 -53
- data/test/tag.rb +0 -65
- data/test/zimbra_attributes.rb +0 -35
@@ -0,0 +1,299 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'zm/client/connector/rest_account'
|
4
|
+
require 'zm/client/signature'
|
5
|
+
require 'zm/client/folder'
|
6
|
+
require 'zm/client/mountpoint'
|
7
|
+
require 'zm/client/search_folder'
|
8
|
+
require 'zm/client/share'
|
9
|
+
require 'zm/client/tag'
|
10
|
+
require 'zm/client/ace'
|
11
|
+
require 'zm/client/contact'
|
12
|
+
require 'zm/client/appointment'
|
13
|
+
require 'zm/client/task'
|
14
|
+
require 'zm/client/document'
|
15
|
+
require 'zm/client/message'
|
16
|
+
require 'zm/client/identity'
|
17
|
+
require 'zm/client/upload'
|
18
|
+
require 'zm/client/filter_rule'
|
19
|
+
require 'zm/client/datasource'
|
20
|
+
|
21
|
+
module Zm
|
22
|
+
module Client
|
23
|
+
module Base
|
24
|
+
# Abstract Class for Account and Resource
|
25
|
+
class MailboxObject < Object
|
26
|
+
include HasSoapAdminConnector
|
27
|
+
|
28
|
+
attr_accessor :home_url, :public_url, :password, :carLicense
|
29
|
+
attr_writer :used, :domain_key
|
30
|
+
|
31
|
+
def soap_account_connector
|
32
|
+
@soap_account_connector ||= SoapAccountConnector.create(@parent.config)
|
33
|
+
end
|
34
|
+
alias sacc soap_account_connector
|
35
|
+
|
36
|
+
def rest_account_connector
|
37
|
+
@rest_account_connector ||= RestAccountConnector.new
|
38
|
+
end
|
39
|
+
|
40
|
+
alias rac rest_account_connector
|
41
|
+
|
42
|
+
def domain_name
|
43
|
+
@domain_name ||= @name.split('@').last
|
44
|
+
end
|
45
|
+
|
46
|
+
def infos
|
47
|
+
@infos ||= MailboxInfosCollection.new(self)
|
48
|
+
end
|
49
|
+
|
50
|
+
def prefs
|
51
|
+
@prefs ||= MailboxPrefsCollection.new(self)
|
52
|
+
end
|
53
|
+
|
54
|
+
def used
|
55
|
+
@used || used!
|
56
|
+
end
|
57
|
+
|
58
|
+
def used!
|
59
|
+
@used = mailbox_infos[:s]
|
60
|
+
end
|
61
|
+
|
62
|
+
def mbxid
|
63
|
+
@mbxid || mbxid!
|
64
|
+
end
|
65
|
+
|
66
|
+
def mbxid!
|
67
|
+
@mbxid = mailbox_infos[:mbxid]
|
68
|
+
end
|
69
|
+
|
70
|
+
def mailbox_infos
|
71
|
+
soap_request = SoapElement.admin(SoapAdminConstants::GET_MAILBOX_REQUEST)
|
72
|
+
node_mbox = SoapElement.create(SoapConstants::MBOX).add_attribute(SoapConstants::ID, @id)
|
73
|
+
soap_request.add_node(node_mbox)
|
74
|
+
sac.invoke(soap_request)[:GetMailboxResponse][:mbox].first
|
75
|
+
end
|
76
|
+
|
77
|
+
# #################################################################
|
78
|
+
# Authentication
|
79
|
+
# #################################################################
|
80
|
+
|
81
|
+
def logged?
|
82
|
+
!@token.nil?
|
83
|
+
end
|
84
|
+
|
85
|
+
def domain_key
|
86
|
+
return @domain_key if @domain_key
|
87
|
+
return @parent.domain_key(domain_name) if @parent.logged?
|
88
|
+
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
|
92
|
+
def login
|
93
|
+
if @parent.logged?
|
94
|
+
admin_login
|
95
|
+
else
|
96
|
+
account_login
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def account_login
|
101
|
+
sacc.token = nil
|
102
|
+
|
103
|
+
if password
|
104
|
+
account_login_password
|
105
|
+
else
|
106
|
+
account_login_preauth
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def account_login_preauth(expires = 0)
|
111
|
+
raise ZmError, 'domain key is required to login !' if domain_key.nil?
|
112
|
+
|
113
|
+
content, by = account_content_by
|
114
|
+
|
115
|
+
@token = sacc.auth_preauth(content, by, expires, domain_key)
|
116
|
+
sacc.context.token(@token)
|
117
|
+
end
|
118
|
+
|
119
|
+
def account_login_password
|
120
|
+
raise ZmError, 'password is required to login !' if password.nil?
|
121
|
+
|
122
|
+
content, by = account_content_by
|
123
|
+
|
124
|
+
@token = sacc.auth_password(content, by, @password)
|
125
|
+
sacc.context.token(@token)
|
126
|
+
end
|
127
|
+
|
128
|
+
def account_content_by
|
129
|
+
@id ? [@id, :id] : [@name, :name]
|
130
|
+
end
|
131
|
+
|
132
|
+
def admin_login
|
133
|
+
# @token = sac.delegate_auth(@name)
|
134
|
+
|
135
|
+
soap_request = SoapElement.admin(SoapAdminConstants::DELEGATE_AUTH_REQUEST)
|
136
|
+
node_account = SoapElement.create(SoapConstants::ACCOUNT)
|
137
|
+
|
138
|
+
if recorded?
|
139
|
+
node_account.add_attribute(SoapConstants::BY, SoapConstants::ID).add_content(@id)
|
140
|
+
else
|
141
|
+
node_account.add_attribute(SoapConstants::BY, SoapConstants::NAME).add_content(@name)
|
142
|
+
end
|
143
|
+
|
144
|
+
soap_request.add_node(node_account)
|
145
|
+
@token = sac.invoke(soap_request)[:DelegateAuthResponse][:authToken].first[:_content]
|
146
|
+
sacc.context.token(@token)
|
147
|
+
end
|
148
|
+
|
149
|
+
# #################################################################
|
150
|
+
# Associations
|
151
|
+
# #################################################################
|
152
|
+
|
153
|
+
def token_metadata
|
154
|
+
@token_metadata ||= TokenMetaData.new(@token)
|
155
|
+
end
|
156
|
+
|
157
|
+
def messages
|
158
|
+
@messages ||= MessagesCollection.new(self)
|
159
|
+
end
|
160
|
+
|
161
|
+
def folders
|
162
|
+
@folders ||= FoldersCollection.new(self)
|
163
|
+
end
|
164
|
+
|
165
|
+
def mountpoints
|
166
|
+
@mountpoints ||= MountPointsCollection.new(self)
|
167
|
+
end
|
168
|
+
|
169
|
+
def search_folders
|
170
|
+
@search_folders ||= SearchFoldersCollection.new(self)
|
171
|
+
end
|
172
|
+
|
173
|
+
def identities
|
174
|
+
@identities ||= IdentitiesCollection.new(self)
|
175
|
+
end
|
176
|
+
|
177
|
+
def shares
|
178
|
+
@shares ||= SharesCollection.new(self)
|
179
|
+
end
|
180
|
+
|
181
|
+
def contacts
|
182
|
+
@contacts ||= ContactsCollection.new(self)
|
183
|
+
end
|
184
|
+
|
185
|
+
def appointments
|
186
|
+
@appointments ||= AppointmentsCollection.new(self)
|
187
|
+
end
|
188
|
+
|
189
|
+
def tags
|
190
|
+
@tags ||= TagsCollection.new(self)
|
191
|
+
end
|
192
|
+
|
193
|
+
def tasks
|
194
|
+
@tasks ||= TasksCollection.new(self)
|
195
|
+
end
|
196
|
+
|
197
|
+
def aces
|
198
|
+
@aces ||= AcesCollection.new(self)
|
199
|
+
end
|
200
|
+
alias rights aces
|
201
|
+
|
202
|
+
def signatures
|
203
|
+
@signatures ||= SignaturesCollection.new(self)
|
204
|
+
end
|
205
|
+
|
206
|
+
def documents
|
207
|
+
@documents ||= DocumentsCollection.new(self)
|
208
|
+
end
|
209
|
+
|
210
|
+
def memberships
|
211
|
+
@memberships ||= AccountDlsMembershipCollection.new(self)
|
212
|
+
end
|
213
|
+
|
214
|
+
def dls_owner
|
215
|
+
@dls_owner ||= AccountDlsOwnerCollection.new(self)
|
216
|
+
end
|
217
|
+
|
218
|
+
def filter_rules
|
219
|
+
@filter_rules ||= FilterRulesCollection.new(self)
|
220
|
+
end
|
221
|
+
|
222
|
+
def outgoing_filter_rules
|
223
|
+
@outgoing_filter_rules ||= OutgoingFilterRulesCollection.new(self)
|
224
|
+
end
|
225
|
+
|
226
|
+
def data_sources
|
227
|
+
@data_sources ||= DataSourcesCollection.new(self)
|
228
|
+
end
|
229
|
+
|
230
|
+
# #################################################################
|
231
|
+
# SOAP Actions
|
232
|
+
# #################################################################
|
233
|
+
|
234
|
+
def password!(new_password = nil)
|
235
|
+
new_password ||= @password
|
236
|
+
return false if new_password.nil?
|
237
|
+
|
238
|
+
soap_request = SoapElement.admin(SoapAdminConstants::SET_PASSWORD_REQUEST)
|
239
|
+
soap_request.add_attributes({ id: @id, newPassword: new_password })
|
240
|
+
sac.invoke(soap_request)
|
241
|
+
|
242
|
+
@password = new_password
|
243
|
+
end
|
244
|
+
|
245
|
+
def rename!(email)
|
246
|
+
soap_request = SoapElement.admin(SoapAdminConstants::RENAME_ACCOUNT_REQUEST)
|
247
|
+
soap_request.add_attributes({ id: @id, newName: email })
|
248
|
+
sac.invoke(soap_request)
|
249
|
+
|
250
|
+
@name = email
|
251
|
+
end
|
252
|
+
|
253
|
+
def update!(hash)
|
254
|
+
return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?
|
255
|
+
|
256
|
+
do_update!(hash)
|
257
|
+
|
258
|
+
hash.each do |key, value|
|
259
|
+
update_attribute(key, value)
|
260
|
+
end
|
261
|
+
|
262
|
+
true
|
263
|
+
end
|
264
|
+
|
265
|
+
def local_transport
|
266
|
+
raise Zm::Client::ZmError, 'zimbraMailHost is null' if zimbraMailHost.nil?
|
267
|
+
|
268
|
+
"lmtp:#{zimbraMailHost}:7025"
|
269
|
+
end
|
270
|
+
|
271
|
+
def local_transport!
|
272
|
+
update!(zimbraMailTransport: local_transport)
|
273
|
+
end
|
274
|
+
|
275
|
+
def is_local_transport?
|
276
|
+
return nil unless zimbraMailTransport
|
277
|
+
|
278
|
+
zimbraMailTransport.start_with?(SoapConstants::LMTP)
|
279
|
+
end
|
280
|
+
|
281
|
+
def is_external_transport?
|
282
|
+
return nil unless zimbraMailTransport
|
283
|
+
|
284
|
+
zimbraMailTransport.start_with?(SoapConstants::SMTP)
|
285
|
+
end
|
286
|
+
|
287
|
+
def last_logon
|
288
|
+
@last_logon ||= Time.parse(zimbraLastLogonTimestamp) unless zimbraLastLogonTimestamp.nil?
|
289
|
+
end
|
290
|
+
|
291
|
+
# #################################################################
|
292
|
+
|
293
|
+
def uploader
|
294
|
+
@uploader ||= Upload.new(self)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zm
|
4
|
+
module Client
|
5
|
+
class MailboxPrefsCollection
|
6
|
+
def initialize(parent)
|
7
|
+
@parent = parent
|
8
|
+
@preferences = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def all
|
12
|
+
@all || all!
|
13
|
+
end
|
14
|
+
|
15
|
+
def all!
|
16
|
+
build_response
|
17
|
+
end
|
18
|
+
|
19
|
+
def clear
|
20
|
+
reset_query_params
|
21
|
+
@all.clear
|
22
|
+
end
|
23
|
+
|
24
|
+
def preferences(*entries)
|
25
|
+
@preferences += entries
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def update!(hash)
|
30
|
+
# The JSON version is different:
|
31
|
+
# {
|
32
|
+
# ModifyPrefsRequest: {
|
33
|
+
# "_attrs": {
|
34
|
+
# "prefName1": "prefValue1",
|
35
|
+
# "prefName2": "prefValue2"
|
36
|
+
# "+nameOfMulitValuedPref3": "addedPrefValue3",
|
37
|
+
# "-nameOfMulitValuedPref4": "removedPrefValue4",
|
38
|
+
# "nameOfMulitValuedPref5": ["prefValue5one","prefValue5two"],
|
39
|
+
# ...
|
40
|
+
# },
|
41
|
+
# _jsns: "urn:zimbraAccount"
|
42
|
+
# }
|
43
|
+
# }
|
44
|
+
|
45
|
+
req = {
|
46
|
+
_attrs: hash
|
47
|
+
}
|
48
|
+
|
49
|
+
soap_request = SoapElement.account(SoapAccountConstants::MODIFY_PREFS_REQUEST).add_attributes(req)
|
50
|
+
@parent.sacc.invoke(soap_request)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def build_response
|
56
|
+
@all = make_query.dig(:GetPrefsResponse, :_attrs)
|
57
|
+
end
|
58
|
+
|
59
|
+
def make_query
|
60
|
+
soap_request = SoapElement.account(SoapAccountConstants::GET_PREFS_REQUEST).add_attributes(jsns)
|
61
|
+
@parent.sacc.invoke(soap_request)
|
62
|
+
end
|
63
|
+
|
64
|
+
def jsns
|
65
|
+
return nil if @preferences.empty?
|
66
|
+
|
67
|
+
{ prefs: @preferences.map { |name| { name: name } } }
|
68
|
+
end
|
69
|
+
|
70
|
+
def reset_query_params
|
71
|
+
@preferences.clear
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -6,49 +6,12 @@ module Zm
|
|
6
6
|
# Abstract Class Provisionning Object
|
7
7
|
class Object
|
8
8
|
attr_accessor :parent, :token, :name, :id
|
9
|
-
attr_reader :grantee_type
|
10
9
|
|
11
10
|
def initialize(parent)
|
12
11
|
@parent = parent
|
13
|
-
@use_builder = true
|
14
12
|
yield(self) if block_given?
|
15
13
|
end
|
16
14
|
|
17
|
-
def disable_builder
|
18
|
-
@use_builder = false
|
19
|
-
self
|
20
|
-
end
|
21
|
-
|
22
|
-
def enable_builder
|
23
|
-
@use_builder = true
|
24
|
-
self
|
25
|
-
end
|
26
|
-
|
27
|
-
def use_builder?
|
28
|
-
@use_builder
|
29
|
-
end
|
30
|
-
|
31
|
-
def init_from_json(json)
|
32
|
-
@id = json[:id]
|
33
|
-
@name = json[:name]
|
34
|
-
end
|
35
|
-
|
36
|
-
def concat
|
37
|
-
instance_variables.map { |variable| instance_variable_get(variable) }
|
38
|
-
end
|
39
|
-
|
40
|
-
def to_s
|
41
|
-
concat.join(DOUBLEPOINT)
|
42
|
-
end
|
43
|
-
|
44
|
-
def convert_json_string_value(value)
|
45
|
-
return value unless value.is_a?(String)
|
46
|
-
return 0 if value == '0'
|
47
|
-
|
48
|
-
c = value.to_i
|
49
|
-
c.to_s == value ? c : value
|
50
|
-
end
|
51
|
-
|
52
15
|
def recorded?
|
53
16
|
!@id.nil?
|
54
17
|
end
|
@@ -57,41 +20,44 @@ module Zm
|
|
57
20
|
recorded? ? modify! : create!
|
58
21
|
end
|
59
22
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
value = instance_variable_get(name)
|
67
|
-
[n, value]
|
68
|
-
end
|
23
|
+
def clone
|
24
|
+
obj = super
|
25
|
+
obj.remove_instance_variable(:@id)
|
26
|
+
yield(obj) if block_given?
|
27
|
+
obj
|
28
|
+
end
|
69
29
|
|
70
|
-
|
71
|
-
|
72
|
-
multi_value.each { |a| arr += a.last.map { |v| [a.first, v] } }
|
73
|
-
arr
|
30
|
+
def logger
|
31
|
+
@parent.logger
|
74
32
|
end
|
75
33
|
|
76
|
-
def
|
77
|
-
|
34
|
+
def update_attribute(key, value)
|
35
|
+
arrow_attr_sym = Utils.arrow_name_sym(key)
|
36
|
+
|
37
|
+
if value.respond_to?(:empty?) && value.empty?
|
38
|
+
remove_instance_variable(arrow_attr_sym) if instance_variable_get(arrow_attr_sym)
|
39
|
+
else
|
40
|
+
instance_variable_set(arrow_attr_sym, value)
|
41
|
+
end
|
78
42
|
end
|
79
43
|
|
80
|
-
def
|
81
|
-
|
44
|
+
def to_s
|
45
|
+
inspect
|
46
|
+
end
|
82
47
|
|
83
|
-
|
48
|
+
def to_h
|
49
|
+
Hash[instance_variables_map]
|
84
50
|
end
|
85
51
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
yield(obj) if block_given?
|
90
|
-
obj
|
52
|
+
def inspect
|
53
|
+
keys_str = to_h.map { |k, v| "#{k}: #{v}" }.join(', ')
|
54
|
+
"#{self.class}:#{format('0x00%x', (object_id << 1))} #{keys_str}"
|
91
55
|
end
|
92
56
|
|
93
|
-
def
|
94
|
-
|
57
|
+
def instance_variables_map
|
58
|
+
keys = instance_variables.dup
|
59
|
+
keys.delete(:@parent)
|
60
|
+
keys.map { |key| [key, instance_variable_get(key)] }
|
95
61
|
end
|
96
62
|
end
|
97
63
|
end
|
@@ -10,24 +10,18 @@ module Zm
|
|
10
10
|
@json = json
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
json_items.map do |entry|
|
17
|
-
child = @child_class.new(@parent)
|
18
|
-
child.init_from_json(entry)
|
19
|
-
child
|
20
|
-
end
|
13
|
+
def ids
|
14
|
+
@json[:Body][json_key][:hit]&.map { |s| s[:id] } || []
|
21
15
|
end
|
22
16
|
|
23
17
|
private
|
24
18
|
|
25
19
|
def json_items
|
26
|
-
@json_items ||= @json[
|
20
|
+
@json_items ||= @json[json_key][@json_item_key]
|
27
21
|
end
|
28
22
|
|
29
23
|
def json_key
|
30
|
-
@json_key ||= @json
|
24
|
+
@json_key ||= @json.keys.first
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
@@ -6,6 +6,8 @@ module Zm
|
|
6
6
|
module Base
|
7
7
|
# Abstract Class Collection
|
8
8
|
class ObjectsCollection
|
9
|
+
include Zm::Inspector
|
10
|
+
|
9
11
|
METHODS_MISSING_LIST = %i[select each map length].to_set.freeze
|
10
12
|
attr_reader :parent
|
11
13
|
|
@@ -19,12 +21,6 @@ module Zm
|
|
19
21
|
find_by(id: id)
|
20
22
|
end
|
21
23
|
|
22
|
-
def build_from_entry(entry)
|
23
|
-
child = @child_class.new(@parent)
|
24
|
-
child.init_from_json(entry)
|
25
|
-
child
|
26
|
-
end
|
27
|
-
|
28
24
|
def first
|
29
25
|
@limit = 1
|
30
26
|
build_response.first
|
@@ -46,6 +42,8 @@ module Zm
|
|
46
42
|
self
|
47
43
|
end
|
48
44
|
|
45
|
+
alias limit per_page
|
46
|
+
|
49
47
|
def page(offset)
|
50
48
|
return self if @offset == offset
|
51
49
|
|
@@ -54,6 +52,8 @@ module Zm
|
|
54
52
|
self
|
55
53
|
end
|
56
54
|
|
55
|
+
alias offset page
|
56
|
+
|
57
57
|
def order(sort_by, sort_ascending = SoapUtils::ON)
|
58
58
|
return self if @sort_by == sort_by && @sort_ascending == sort_ascending
|
59
59
|
|
@@ -93,7 +93,10 @@ module Zm
|
|
93
93
|
def attrs_comma
|
94
94
|
return @attrs unless @attrs.is_a?(Array)
|
95
95
|
|
96
|
-
@attrs.uniq!
|
96
|
+
# @attrs.uniq!
|
97
|
+
# @attrs.compact!
|
98
|
+
return nil if @attrs.empty?
|
99
|
+
|
97
100
|
@attrs.join(COMMA)
|
98
101
|
end
|
99
102
|
|
@@ -104,9 +107,9 @@ module Zm
|
|
104
107
|
@sort_by = nil
|
105
108
|
@sort_ascending = SoapUtils::ON
|
106
109
|
@count_only = SoapUtils::OFF
|
107
|
-
@all_servers =
|
108
|
-
@refresh =
|
109
|
-
@apply_cos =
|
110
|
+
@all_servers = SoapUtils::OFF
|
111
|
+
@refresh = SoapUtils::OFF
|
112
|
+
@apply_cos = SoapUtils::ON
|
110
113
|
end
|
111
114
|
end
|
112
115
|
end
|
@@ -7,21 +7,23 @@ module Zm
|
|
7
7
|
module Client
|
8
8
|
module Base
|
9
9
|
class ZimbraAttribute < OpenStruct
|
10
|
-
|
11
|
-
# attr_accessor :flags, :id, :immutable, :max, :min, :name, :optionalIn, :order, :requiredIn, :since, :type, :value
|
12
|
-
|
13
10
|
def version_start
|
14
11
|
return @version_start unless @version_start.nil?
|
15
12
|
|
16
|
-
if since.nil?
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
@version_start = if since.nil?
|
14
|
+
'0.0.0'
|
15
|
+
else
|
16
|
+
VersionSorter.sort(since.split(',')).first
|
17
|
+
end
|
21
18
|
|
22
19
|
@version_start
|
23
20
|
end
|
24
21
|
|
22
|
+
def immutable?
|
23
|
+
# @immutable.to_s == '1'
|
24
|
+
immutable == '1'
|
25
|
+
end
|
26
|
+
|
25
27
|
def objects_scope
|
26
28
|
@objects_scope ||= (optionalIn.to_s.split(',') + requiredIn.to_s.split(',')).freeze
|
27
29
|
end
|