zm-ruby-client 2.2.7 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +10 -6
- data/Gemfile +1 -6
- data/README.md +10 -15
- data/VERSION +1 -1
- data/lib/zm/client/account/account.rb +35 -22
- data/lib/zm/client/account/account_aliases_collection.rb +14 -6
- data/lib/zm/client/account/account_dls_membership_collection.rb +10 -4
- data/lib/zm/client/account/account_dls_owner_collection.rb +8 -5
- data/lib/zm/client/account/account_jsns_builder.rb +31 -19
- data/lib/zm/client/account/account_jsns_initializer.rb +4 -14
- data/lib/zm/client/account/accounts_builder.rb +1 -1
- data/lib/zm/client/account/accounts_collection.rb +15 -8
- data/lib/zm/client/ace/ace.rb +5 -5
- data/lib/zm/client/ace/ace_jsns_builder.rb +8 -8
- data/lib/zm/client/ace/ace_jsns_initializer.rb +7 -7
- data/lib/zm/client/ace/aces_builder.rb +1 -1
- data/lib/zm/client/ace/aces_collection.rb +2 -2
- data/lib/zm/client/appointment/appointment.rb +27 -24
- data/lib/zm/client/appointment/appointment_jsns_builder.rb +29 -20
- data/lib/zm/client/appointment/appointment_jsns_initializer.rb +14 -13
- data/lib/zm/client/appointment/appointments_builder.rb +1 -1
- data/lib/zm/client/appointment/appointments_collection.rb +8 -7
- data/lib/zm/client/backup/backup.rb +6 -2
- data/lib/zm/client/backup/backup_jsns_initializer.rb +14 -12
- data/lib/zm/client/backup/backups_builder.rb +1 -1
- data/lib/zm/client/backup/backups_collection.rb +2 -1
- data/lib/zm/client/base/account_search_objects_collection.rb +46 -20
- data/lib/zm/client/base/admin_objects_collection.rb +22 -27
- data/lib/zm/client/base/base_account_jsns_builder.rb +1 -4
- data/lib/zm/client/base/base_jsns_initializer.rb +8 -8
- data/lib/zm/client/base/mailbox_infos_collection.rb +23 -15
- data/lib/zm/client/base/mailbox_object.rb +174 -69
- data/lib/zm/client/base/mailbox_prefs_collection.rb +4 -8
- data/lib/zm/client/base/object.rb +2 -2
- data/lib/zm/client/base/objects_builder.rb +7 -3
- data/lib/zm/client/base/objects_collection.rb +4 -13
- data/lib/zm/client/base/zimbra_attribute.rb +4 -17
- data/lib/zm/client/base/zimbra_attributes_collection.rb +16 -9
- data/lib/zm/client/base.rb +0 -1
- data/lib/zm/client/cluster/batch_request.rb +50 -0
- data/lib/zm/client/cluster/cluster.rb +49 -27
- data/lib/zm/client/cluster/cluster_config.rb +129 -40
- data/lib/zm/client/common/recipients.rb +2 -2
- data/lib/zm/client/common/utils.rb +1 -13
- data/lib/zm/client/common.rb +0 -1
- data/lib/zm/client/connector/{rest_account.rb → rest_connector.rb} +40 -50
- data/lib/zm/client/connector/soap_account.rb +19 -15
- data/lib/zm/client/connector/soap_admin.rb +9 -9
- data/lib/zm/client/connector/soap_base.rb +24 -17
- data/lib/zm/client/connector/soap_error.rb +3 -23
- data/lib/zm/client/constant.rb +18 -16
- data/lib/zm/client/contact/contact.rb +21 -40
- data/lib/zm/client/contact/contact_jsns_builder.rb +1 -1
- data/lib/zm/client/contact/contact_jsns_initializer.rb +4 -26
- data/lib/zm/client/contact/contacts_builder.rb +1 -1
- data/lib/zm/client/contact/contacts_collection.rb +4 -24
- data/lib/zm/client/contact/group_contact_jsns_builder.rb +18 -13
- data/lib/zm/client/contact/mod_group_contact.rb +6 -2
- data/lib/zm/client/cos/cos.rb +35 -11
- data/lib/zm/client/cos/cos_domains_collection.rb +1 -1
- data/lib/zm/client/cos/cos_jsns_builder.rb +22 -9
- data/lib/zm/client/cos/cos_jsns_initializer.rb +2 -6
- data/lib/zm/client/cos/cos_servers_collection.rb +5 -6
- data/lib/zm/client/cos/coses_builder.rb +1 -1
- data/lib/zm/client/cos/coses_collection.rb +6 -4
- data/lib/zm/client/datasource/datasource.rb +27 -34
- data/lib/zm/client/datasource/datasource_jsns_builder.rb +1 -1
- data/lib/zm/client/datasource/datasource_jsns_initializer.rb +5 -6
- data/lib/zm/client/datasource/datasources_builder.rb +6 -9
- data/lib/zm/client/datasource/datasources_collection.rb +6 -5
- data/lib/zm/client/distributionlist/distributionlist.rb +22 -42
- data/lib/zm/client/distributionlist/distributionlist_aliases_collection.rb +14 -6
- data/lib/zm/client/distributionlist/distributionlist_jsns_builder.rb +20 -16
- data/lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb +2 -11
- data/lib/zm/client/distributionlist/distributionlist_members_collection.rb +20 -12
- data/lib/zm/client/distributionlist/distributionlist_owners_collection.rb +16 -5
- data/lib/zm/client/distributionlist/distributionlists_builder.rb +1 -1
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +12 -6
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +12 -6
- data/lib/zm/client/document/document.rb +16 -8
- data/lib/zm/client/document/document_jsns_builder.rb +1 -1
- data/lib/zm/client/document/document_jsns_initializer.rb +27 -26
- data/lib/zm/client/document/documents_builder.rb +1 -1
- data/lib/zm/client/document/documents_collection.rb +1 -1
- data/lib/zm/client/domain/domain.rb +18 -37
- data/lib/zm/client/domain/domain_accounts_collection.rb +1 -1
- data/lib/zm/client/domain/domain_distributionlists_collection.rb +1 -1
- data/lib/zm/client/domain/domain_jsns_builder.rb +18 -9
- data/lib/zm/client/domain/domain_jsns_initializer.rb +2 -6
- data/lib/zm/client/domain/domain_resources_collection.rb +1 -1
- data/lib/zm/client/domain/domains_builder.rb +1 -1
- data/lib/zm/client/domain/domains_collection.rb +12 -6
- data/lib/zm/client/filter_rules/filter_rule.rb +0 -9
- data/lib/zm/client/filter_rules/filter_rule_jsns_initializer.rb +7 -6
- data/lib/zm/client/filter_rules/filter_rules_builder.rb +1 -1
- data/lib/zm/client/filter_rules/filter_rules_collection.rb +5 -15
- data/lib/zm/client/filter_rules/outgoing_filter_rules_collection.rb +5 -2
- data/lib/zm/client/folder/folder.rb +73 -56
- data/lib/zm/client/folder/folder_grant.rb +7 -5
- data/lib/zm/client/folder/folder_grant_jsns_builder.rb +6 -3
- data/lib/zm/client/folder/folder_grants_collection.rb +2 -4
- data/lib/zm/client/folder/folder_jsns_builder.rb +14 -7
- data/lib/zm/client/folder/folder_jsns_initializer.rb +58 -40
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +4 -2
- data/lib/zm/client/folder/folders_builder.rb +1 -1
- data/lib/zm/client/folder/folders_collection.rb +21 -18
- data/lib/zm/client/folder/folders_jsns_builder.rb +4 -2
- data/lib/zm/client/folder/mod_document_folder.rb +5 -4
- data/lib/zm/client/identity/identities_builder.rb +1 -1
- data/lib/zm/client/identity/identities_collection.rb +6 -5
- data/lib/zm/client/identity/identity.rb +9 -29
- data/lib/zm/client/identity/identity_jsns_builder.rb +8 -4
- data/lib/zm/client/identity/identity_jsns_initializer.rb +5 -4
- data/lib/zm/client/license/license.rb +7 -1
- data/lib/zm/client/license/license_jsns_initializer.rb +8 -5
- data/lib/zm/client/license/licenses_collection.rb +1 -1
- data/lib/zm/client/mailbox/mailbox_item_concern.rb +33 -0
- data/lib/zm/client/mailbox/mailbox_item_id.rb +7 -0
- data/lib/zm/client/message/attachments_collection.rb +2 -2
- data/lib/zm/client/message/message.rb +56 -52
- data/lib/zm/client/message/message_flags.rb +21 -13
- data/lib/zm/client/message/message_jsns_builder.rb +11 -6
- data/lib/zm/client/message/message_jsns_initializer.rb +24 -23
- data/lib/zm/client/message/messages_builder.rb +1 -1
- data/lib/zm/client/message/messages_collection.rb +1 -15
- data/lib/zm/client/mountpoint/mountpoint.rb +17 -25
- data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +6 -3
- data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +25 -24
- data/lib/zm/client/mountpoint/mountpoints_builder.rb +1 -1
- data/lib/zm/client/mountpoint/mountpoints_collection.rb +13 -9
- data/lib/zm/client/mta_queue/mta_queue.rb +6 -2
- data/lib/zm/client/mta_queue/mta_queue_jsns_initializer.rb +3 -7
- data/lib/zm/client/mta_queue/mta_queues_builder.rb +3 -1
- data/lib/zm/client/mta_queue_item/mta_queue_item.rb +5 -3
- data/lib/zm/client/mta_queue_item/mta_queue_item_jsns_initializer.rb +1 -5
- data/lib/zm/client/mta_queue_item/mta_queue_items_builder.rb +3 -1
- data/lib/zm/client/mta_queue_item/mta_queue_items_collection.rb +3 -1
- data/lib/zm/client/resource/resource.rb +6 -18
- data/lib/zm/client/resource/resource_jsns_builder.rb +20 -13
- data/lib/zm/client/resource/resource_jsns_initializer.rb +4 -14
- data/lib/zm/client/resource/resources_builder.rb +1 -1
- data/lib/zm/client/resource/resources_collection.rb +12 -7
- data/lib/zm/client/search_folder/search_folder.rb +13 -29
- data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +6 -6
- data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +19 -18
- data/lib/zm/client/search_folder/search_folders_builder.rb +1 -1
- data/lib/zm/client/search_folder/search_folders_collection.rb +6 -5
- data/lib/zm/client/server/server.rb +9 -3
- data/lib/zm/client/server/server_accounts_collection.rb +4 -2
- data/lib/zm/client/server/server_jsns_initializer.rb +1 -5
- data/lib/zm/client/server/servers_builder.rb +1 -1
- data/lib/zm/client/server/servers_collection.rb +17 -9
- data/lib/zm/client/share/share.rb +5 -3
- data/lib/zm/client/share/share_jsns_initializer.rb +15 -14
- data/lib/zm/client/share/share_mountpoints_collection.rb +3 -6
- data/lib/zm/client/share/shares_builder.rb +1 -1
- data/lib/zm/client/share/shares_collection.rb +6 -3
- data/lib/zm/client/signature/signature.rb +6 -21
- data/lib/zm/client/signature/signature_jsns_builder.rb +12 -7
- data/lib/zm/client/signature/signature_jsns_initializer.rb +5 -4
- data/lib/zm/client/signature/signatures_builder.rb +1 -1
- data/lib/zm/client/signature/signatures_collection.rb +6 -5
- data/lib/zm/client/soap_request/request_methods_admin.rb +56 -0
- data/lib/zm/client/soap_request/request_methods_mailbox.rb +60 -0
- data/lib/zm/client/soap_request/soap_constants.rb +7 -0
- data/lib/zm/client/soap_request/soap_context.rb +11 -2
- data/lib/zm/client/soap_request.rb +3 -0
- data/lib/zm/client/tag/account_object_tags_collection.rb +11 -9
- data/lib/zm/client/tag/tag.rb +8 -44
- data/lib/zm/client/tag/tag_jsns_builder.rb +4 -2
- data/lib/zm/client/tag/tag_jsns_initializer.rb +7 -6
- data/lib/zm/client/tag/tags_builder.rb +1 -1
- data/lib/zm/client/tag/tags_collection.rb +6 -5
- data/lib/zm/client/task/task.rb +6 -5
- data/lib/zm/client/task/task_jsns_initializer.rb +28 -27
- data/lib/zm/client/task/tasks_builder.rb +1 -1
- data/lib/zm/client/task/tasks_collection.rb +2 -2
- data/lib/zm/client/token.rb +52 -0
- data/lib/zm/client/upload/upload.rb +101 -95
- data/lib/zm/client/zm_logger.rb +83 -0
- data/lib/zm/client.rb +6 -1
- data/lib/zm/modules/base.rb +0 -1
- data/lib/zm/modules/belongs_to_folder.rb +6 -7
- data/lib/zm/modules/belongs_to_tag.rb +3 -1
- data/lib/zm/modules/common/zimbra-attrs.csv +3 -4
- data/lib/zm/modules/inspector.rb +2 -2
- data/lib/zm/modules/missing_method_static_collection.rb +2 -2
- data/lib/zm/support/cache/entry.rb +63 -0
- data/lib/zm/support/cache/file_store.rb +141 -0
- data/lib/zm/support/cache/null_store.rb +43 -0
- data/lib/zm/support/cache/request_strategy.rb +10 -0
- data/lib/zm/support/cache/store.rb +197 -0
- data/lib/zm/support/cache/strategy.rb +13 -0
- data/lib/zm/support/cache.rb +26 -0
- data/lib/zm-ruby-client.rb +2 -2
- data/zm-ruby-client.gemspec +10 -15
- metadata +37 -36
- data/lib/zm/client/common/token_metadata.rb +0 -44
- data/lib/zm/modules/zm_logger.rb +0 -26
|
@@ -10,16 +10,12 @@ module Zm
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def all
|
|
13
|
-
@all || all!
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def all!
|
|
17
13
|
build_response
|
|
18
14
|
end
|
|
15
|
+
alias all! all
|
|
19
16
|
|
|
20
17
|
def clear
|
|
21
18
|
reset_query_params
|
|
22
|
-
@all.clear
|
|
23
19
|
end
|
|
24
20
|
|
|
25
21
|
def sections(*entries)
|
|
@@ -55,30 +51,42 @@ module Zm
|
|
|
55
51
|
|
|
56
52
|
soap_request = SoapElement.account(SoapAccountConstants::GET_ACCOUNT_INFO_REQUEST)
|
|
57
53
|
|
|
58
|
-
if @parent.id
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
node_entry = if @parent.id
|
|
55
|
+
SoapElement.create(SoapConstants::ACCOUNT)
|
|
56
|
+
.add_attribute(SoapConstants::BY, SoapConstants::ID)
|
|
57
|
+
.add_content(@parent.id)
|
|
58
|
+
else
|
|
59
|
+
SoapElement.create(SoapConstants::ACCOUNT)
|
|
60
|
+
.add_attribute(SoapConstants::BY, SoapConstants::NAME)
|
|
61
|
+
.add_content(@parent.name)
|
|
62
|
+
end
|
|
63
63
|
|
|
64
64
|
soap_request.add_node(node_entry)
|
|
65
65
|
|
|
66
|
-
@zimbraMailHost = @parent.
|
|
66
|
+
@zimbraMailHost = @parent.soap_connector
|
|
67
|
+
.invoke(soap_request)
|
|
68
|
+
.dig(:GetAccountInfoResponse, :_attrs, :zimbraMailHost)
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
private
|
|
70
72
|
|
|
71
73
|
def build_response
|
|
72
|
-
|
|
74
|
+
make_query[:GetInfoResponse]
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
def make_query
|
|
76
|
-
soap_request = SoapElement.account(SoapAccountConstants::GET_INFO_REQUEST)
|
|
77
|
-
|
|
78
|
+
soap_request = SoapElement.account(SoapAccountConstants::GET_INFO_REQUEST)
|
|
79
|
+
.add_attributes(jsns)
|
|
80
|
+
@parent.soap_connector.invoke(soap_request)
|
|
78
81
|
end
|
|
79
82
|
|
|
80
83
|
def jsns
|
|
81
|
-
|
|
84
|
+
h = {
|
|
85
|
+
rights: @rights.join(','),
|
|
86
|
+
sections: @sections.join(',')
|
|
87
|
+
}
|
|
88
|
+
h.compact!
|
|
89
|
+
h
|
|
82
90
|
end
|
|
83
91
|
|
|
84
92
|
def reset_query_params
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'zm/client/
|
|
3
|
+
require 'zm/client/mailbox/mailbox_item_concern'
|
|
4
|
+
require 'zm/client/connector/rest_connector'
|
|
4
5
|
require 'zm/client/signature'
|
|
5
6
|
require 'zm/client/folder'
|
|
6
7
|
require 'zm/client/mountpoint'
|
|
@@ -29,26 +30,47 @@ module Zm
|
|
|
29
30
|
attr_writer :used, :domain_key
|
|
30
31
|
|
|
31
32
|
def soap_account_connector
|
|
32
|
-
@soap_account_connector
|
|
33
|
-
end
|
|
34
|
-
alias sacc soap_account_connector
|
|
33
|
+
return @soap_account_connector if defined? @soap_account_connector
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
@rest_account_connector ||= RestAccountConnector.new
|
|
35
|
+
@soap_account_connector = SoapAccountConnector.create(soap_config)
|
|
38
36
|
end
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
def soap_connector
|
|
39
|
+
return @soap_connector if defined? @soap_connector
|
|
40
|
+
|
|
41
|
+
if logged?
|
|
42
|
+
@soap_connector = soap_account_connector
|
|
43
|
+
elsif (@id || @name) && @parent&.logged?
|
|
44
|
+
@soap_connector = @parent.soap_admin_connector.clone
|
|
45
|
+
|
|
46
|
+
if @id
|
|
47
|
+
@soap_connector.context.account(:id, @id)
|
|
48
|
+
else
|
|
49
|
+
@soap_connector.context.account(:name, @name)
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
raise ZmError, 'SoapConnector not defined'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
@soap_connector
|
|
56
|
+
end
|
|
41
57
|
|
|
42
58
|
def domain_name
|
|
43
|
-
@domain_name
|
|
59
|
+
return @domain_name if defined? @domain_name
|
|
60
|
+
|
|
61
|
+
@domain_name = @name.split('@').last
|
|
44
62
|
end
|
|
45
63
|
|
|
46
64
|
def infos
|
|
47
|
-
@infos
|
|
65
|
+
return @infos if defined? @infos
|
|
66
|
+
|
|
67
|
+
@infos = MailboxInfosCollection.new(self)
|
|
48
68
|
end
|
|
49
69
|
|
|
50
70
|
def prefs
|
|
51
|
-
@prefs
|
|
71
|
+
return @prefs if defined? @prefs
|
|
72
|
+
|
|
73
|
+
@prefs = MailboxPrefsCollection.new(self)
|
|
52
74
|
end
|
|
53
75
|
|
|
54
76
|
def used
|
|
@@ -78,8 +100,32 @@ module Zm
|
|
|
78
100
|
# Authentication
|
|
79
101
|
# #################################################################
|
|
80
102
|
|
|
103
|
+
def token
|
|
104
|
+
return @token if defined? @token
|
|
105
|
+
|
|
106
|
+
@token = (Token.new(soap_account_connector.token) if soap_account_connector.token)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def token=(value)
|
|
110
|
+
@token = Token.new(soap_account_connector.token = value)
|
|
111
|
+
@soap_connector = soap_account_connector
|
|
112
|
+
end
|
|
113
|
+
|
|
81
114
|
def logged?
|
|
82
|
-
|
|
115
|
+
!token.nil? && !token.expired?
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def alive?
|
|
119
|
+
soap_request = SoapElement.mail(SoapMailConstants::NO_OP_REQUEST)
|
|
120
|
+
soap_connector.invoke(soap_request)
|
|
121
|
+
true
|
|
122
|
+
rescue Zm::Client::SoapError => e
|
|
123
|
+
logger.warn "Mailbox session token alive ? #{e.message}"
|
|
124
|
+
false
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def logged_and_alive?
|
|
128
|
+
logged? && alive?
|
|
83
129
|
end
|
|
84
130
|
|
|
85
131
|
def domain_key
|
|
@@ -97,7 +143,7 @@ module Zm
|
|
|
97
143
|
end
|
|
98
144
|
|
|
99
145
|
def account_login
|
|
100
|
-
|
|
146
|
+
soap_account_connector.token = nil
|
|
101
147
|
|
|
102
148
|
if password
|
|
103
149
|
account_login_password
|
|
@@ -107,21 +153,21 @@ module Zm
|
|
|
107
153
|
end
|
|
108
154
|
|
|
109
155
|
def account_login_preauth(expires = 0)
|
|
156
|
+
logger.info 'Get Account session token by preauth access'
|
|
110
157
|
raise ZmError, 'domain key is required to login !' if domain_key.nil?
|
|
111
158
|
|
|
112
159
|
content, by = account_content_by
|
|
113
160
|
|
|
114
|
-
|
|
115
|
-
sacc.context.token(@token)
|
|
161
|
+
self.token = soap_account_connector.auth_preauth(content, by, expires, domain_key)
|
|
116
162
|
end
|
|
117
163
|
|
|
118
164
|
def account_login_password
|
|
165
|
+
logger.info 'Get Account session token by password access'
|
|
119
166
|
raise ZmError, 'password is required to login !' if password.nil?
|
|
120
167
|
|
|
121
168
|
content, by = account_content_by
|
|
122
169
|
|
|
123
|
-
|
|
124
|
-
sacc.context.token(@token)
|
|
170
|
+
self.token = soap_account_connector.auth_password(content, by, @password)
|
|
125
171
|
end
|
|
126
172
|
|
|
127
173
|
def account_content_by
|
|
@@ -129,7 +175,7 @@ module Zm
|
|
|
129
175
|
end
|
|
130
176
|
|
|
131
177
|
def admin_login
|
|
132
|
-
|
|
178
|
+
logger.info 'Get Account session token by Delegate access'
|
|
133
179
|
|
|
134
180
|
soap_request = SoapElement.admin(SoapAdminConstants::DELEGATE_AUTH_REQUEST)
|
|
135
181
|
node_account = SoapElement.create(SoapConstants::ACCOUNT)
|
|
@@ -141,89 +187,120 @@ module Zm
|
|
|
141
187
|
end
|
|
142
188
|
|
|
143
189
|
soap_request.add_node(node_account)
|
|
144
|
-
|
|
145
|
-
sacc.context.token(@token)
|
|
190
|
+
self.token = sac.invoke(soap_request)[:DelegateAuthResponse][:authToken].first[:_content]
|
|
146
191
|
end
|
|
147
192
|
|
|
148
193
|
# #################################################################
|
|
149
194
|
# Associations
|
|
150
195
|
# #################################################################
|
|
151
196
|
|
|
152
|
-
def token_metadata
|
|
153
|
-
@token_metadata ||= TokenMetaData.new(@token)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
197
|
def messages
|
|
157
|
-
@messages
|
|
198
|
+
return @messages if defined? @messages
|
|
199
|
+
|
|
200
|
+
@messages = MessagesCollection.new(self)
|
|
158
201
|
end
|
|
159
202
|
|
|
160
203
|
def folders
|
|
161
|
-
@folders
|
|
204
|
+
return @folders if defined? @folders
|
|
205
|
+
|
|
206
|
+
@folders = FoldersCollection.new(self)
|
|
162
207
|
end
|
|
163
208
|
|
|
164
209
|
def mountpoints
|
|
165
|
-
@mountpoints
|
|
210
|
+
return @mountpoints if defined? @mountpoints
|
|
211
|
+
|
|
212
|
+
@mountpoints = MountPointsCollection.new(self)
|
|
166
213
|
end
|
|
167
214
|
|
|
168
215
|
def search_folders
|
|
169
|
-
@search_folders
|
|
216
|
+
return @search_folders if defined? @search_folders
|
|
217
|
+
|
|
218
|
+
@search_folders = SearchFoldersCollection.new(self)
|
|
170
219
|
end
|
|
171
220
|
|
|
172
221
|
def identities
|
|
173
|
-
@identities
|
|
222
|
+
return @identities if defined? @identities
|
|
223
|
+
|
|
224
|
+
@identities = IdentitiesCollection.new(self)
|
|
174
225
|
end
|
|
175
226
|
|
|
176
227
|
def shares
|
|
177
|
-
@shares
|
|
228
|
+
return @shares if defined? @shares
|
|
229
|
+
|
|
230
|
+
@shares = SharesCollection.new(self)
|
|
178
231
|
end
|
|
179
232
|
|
|
180
233
|
def contacts
|
|
181
|
-
@contacts
|
|
234
|
+
return @contacts if defined? @contacts
|
|
235
|
+
|
|
236
|
+
@contacts = ContactsCollection.new(self)
|
|
182
237
|
end
|
|
183
238
|
|
|
184
239
|
def appointments
|
|
185
|
-
@appointments
|
|
240
|
+
return @appointments if defined? @appointments
|
|
241
|
+
|
|
242
|
+
@appointments = AppointmentsCollection.new(self)
|
|
186
243
|
end
|
|
187
244
|
|
|
188
245
|
def tags
|
|
189
|
-
@tags
|
|
246
|
+
return @tags if defined? @tags
|
|
247
|
+
|
|
248
|
+
@tags = TagsCollection.new(self)
|
|
190
249
|
end
|
|
191
250
|
|
|
192
251
|
def tasks
|
|
193
|
-
@tasks
|
|
252
|
+
return @tasks if defined? @tasks
|
|
253
|
+
|
|
254
|
+
@tasks = TasksCollection.new(self)
|
|
194
255
|
end
|
|
195
256
|
|
|
196
257
|
def aces
|
|
197
|
-
@aces
|
|
258
|
+
return @aces if defined? @aces
|
|
259
|
+
|
|
260
|
+
@aces = AcesCollection.new(self)
|
|
198
261
|
end
|
|
199
262
|
alias rights aces
|
|
200
263
|
|
|
201
264
|
def signatures
|
|
202
|
-
@signatures
|
|
265
|
+
return @signatures if defined? @signatures
|
|
266
|
+
|
|
267
|
+
@signatures = SignaturesCollection.new(self)
|
|
203
268
|
end
|
|
204
269
|
|
|
205
270
|
def documents
|
|
206
|
-
@documents
|
|
271
|
+
return @documents if defined? @documents
|
|
272
|
+
|
|
273
|
+
@documents = DocumentsCollection.new(self)
|
|
207
274
|
end
|
|
208
275
|
|
|
209
276
|
def memberships
|
|
210
|
-
@memberships
|
|
277
|
+
return @memberships if defined? @memberships
|
|
278
|
+
|
|
279
|
+
@memberships = AccountDlsMembershipCollection.new(self)
|
|
211
280
|
end
|
|
212
281
|
|
|
213
282
|
def dls_owner
|
|
214
|
-
@dls_owner
|
|
283
|
+
return @dls_owner if defined? @dls_owner
|
|
284
|
+
|
|
285
|
+
@dls_owner = AccountDlsOwnerCollection.new(self)
|
|
215
286
|
end
|
|
216
287
|
|
|
217
288
|
def filter_rules
|
|
218
|
-
@filter_rules
|
|
289
|
+
return @filter_rules if defined? @filter_rules
|
|
290
|
+
|
|
291
|
+
@filter_rules = FilterRulesCollection.new(self)
|
|
219
292
|
end
|
|
220
293
|
|
|
221
294
|
def outgoing_filter_rules
|
|
222
|
-
@outgoing_filter_rules
|
|
295
|
+
return @outgoing_filter_rules if defined? @outgoing_filter_rules
|
|
296
|
+
|
|
297
|
+
@outgoing_filter_rules = OutgoingFilterRulesCollection.new(self)
|
|
223
298
|
end
|
|
224
299
|
|
|
225
300
|
def data_sources
|
|
226
|
-
@data_sources
|
|
301
|
+
return @data_sources if defined? @data_sources
|
|
302
|
+
|
|
303
|
+
@data_sources = DataSourcesCollection.new(self)
|
|
227
304
|
end
|
|
228
305
|
|
|
229
306
|
# #################################################################
|
|
@@ -241,26 +318,6 @@ module Zm
|
|
|
241
318
|
@password = new_password
|
|
242
319
|
end
|
|
243
320
|
|
|
244
|
-
def rename!(email)
|
|
245
|
-
soap_request = SoapElement.admin(SoapAdminConstants::RENAME_ACCOUNT_REQUEST)
|
|
246
|
-
soap_request.add_attributes({ id: @id, newName: email })
|
|
247
|
-
sac.invoke(soap_request)
|
|
248
|
-
|
|
249
|
-
@name = email
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
def update!(hash)
|
|
253
|
-
return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?
|
|
254
|
-
|
|
255
|
-
do_update!(hash)
|
|
256
|
-
|
|
257
|
-
hash.each do |key, value|
|
|
258
|
-
update_attribute(key, value)
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
true
|
|
262
|
-
end
|
|
263
|
-
|
|
264
321
|
def local_transport
|
|
265
322
|
raise Zm::Client::ZmError, 'zimbraMailHost is null' if zimbraMailHost.nil?
|
|
266
323
|
|
|
@@ -272,34 +329,82 @@ module Zm
|
|
|
272
329
|
end
|
|
273
330
|
|
|
274
331
|
def is_local_transport?
|
|
275
|
-
return
|
|
332
|
+
return false unless zimbraMailTransport
|
|
276
333
|
|
|
277
334
|
zimbraMailTransport.start_with?(SoapConstants::LMTP)
|
|
278
335
|
end
|
|
279
336
|
|
|
280
337
|
def is_external_transport?
|
|
281
|
-
return
|
|
338
|
+
return false unless zimbraMailTransport
|
|
282
339
|
|
|
283
340
|
zimbraMailTransport.start_with?(SoapConstants::SMTP)
|
|
284
341
|
end
|
|
285
342
|
|
|
286
343
|
def last_logon
|
|
287
|
-
@last_logon
|
|
344
|
+
return @last_logon if defined? @last_logon
|
|
345
|
+
|
|
346
|
+
@last_logon = Time.parse(zimbraLastLogonTimestamp) unless zimbraLastLogonTimestamp.nil?
|
|
288
347
|
end
|
|
289
348
|
|
|
290
349
|
# #################################################################
|
|
291
350
|
|
|
292
|
-
def
|
|
293
|
-
|
|
351
|
+
def build_uploader
|
|
352
|
+
tmp_token = soap_connector&.token
|
|
353
|
+
raise ZmError, 'token have to be set to instance Upload class' unless tmp_token
|
|
354
|
+
|
|
355
|
+
Upload.new(rest_url, tmp_token, is_token_admin: soap_connector.is_a?(SoapAdminConnector), **rest_options)
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
def rest_options
|
|
359
|
+
if soap_config
|
|
360
|
+
{
|
|
361
|
+
timeout: soap_config.timeout,
|
|
362
|
+
verbose: soap_config.logger.debug?
|
|
363
|
+
}
|
|
364
|
+
else
|
|
365
|
+
{}
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
def rest_url
|
|
370
|
+
raise ZmError, 'name attribute is requuired for REST Url' unless @name
|
|
371
|
+
|
|
372
|
+
if logged?
|
|
373
|
+
rest_account_url
|
|
374
|
+
elsif parent_logged?
|
|
375
|
+
rest_admin_url
|
|
376
|
+
else
|
|
377
|
+
raise ZmError, 'impossible to set rest_url'
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def rest_admin_url
|
|
382
|
+
raise ZmError, 'impossible to set rest_admin_url' unless soap_config.zimbra_admin_url
|
|
383
|
+
|
|
384
|
+
File.join(soap_config.zimbra_admin_url, 'home', @name)
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
def rest_account_url
|
|
388
|
+
if soap_config.zimbra_public_url
|
|
389
|
+
File.join(soap_config.zimbra_public_url, 'home', @name)
|
|
390
|
+
elsif home_url
|
|
391
|
+
home_url
|
|
392
|
+
else
|
|
393
|
+
raise ZmError, 'impossible to set rest_account_url'
|
|
394
|
+
end
|
|
294
395
|
end
|
|
295
396
|
|
|
296
397
|
private
|
|
297
398
|
|
|
298
399
|
def soap_config
|
|
299
|
-
return @
|
|
300
|
-
return
|
|
400
|
+
return @soap_config if defined? @soap_config
|
|
401
|
+
return unless @parent
|
|
301
402
|
|
|
302
|
-
|
|
403
|
+
if @parent.respond_to?(:config)
|
|
404
|
+
@soap_config = @parent.config
|
|
405
|
+
elsif @parent.respond_to?(:parent) && @parent.parent.respond_to?(:config)
|
|
406
|
+
@soap_config = @parent.parent.config
|
|
407
|
+
end
|
|
303
408
|
end
|
|
304
409
|
|
|
305
410
|
def parent_logged?
|
|
@@ -9,16 +9,12 @@ module Zm
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def all
|
|
12
|
-
@all || all!
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def all!
|
|
16
12
|
build_response
|
|
17
13
|
end
|
|
14
|
+
alias all! all
|
|
18
15
|
|
|
19
16
|
def clear
|
|
20
17
|
reset_query_params
|
|
21
|
-
@all.clear
|
|
22
18
|
end
|
|
23
19
|
|
|
24
20
|
def preferences(*entries)
|
|
@@ -48,18 +44,18 @@ module Zm
|
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
soap_request = SoapElement.account(SoapAccountConstants::MODIFY_PREFS_REQUEST).add_attributes(req)
|
|
51
|
-
@parent.
|
|
47
|
+
@parent.soap_connector.invoke(soap_request)
|
|
52
48
|
end
|
|
53
49
|
|
|
54
50
|
private
|
|
55
51
|
|
|
56
52
|
def build_response
|
|
57
|
-
|
|
53
|
+
make_query.dig(:GetPrefsResponse, :_attrs)
|
|
58
54
|
end
|
|
59
55
|
|
|
60
56
|
def make_query
|
|
61
57
|
soap_request = SoapElement.account(SoapAccountConstants::GET_PREFS_REQUEST).add_attributes(jsns)
|
|
62
|
-
@parent.
|
|
58
|
+
@parent.soap_connector.invoke(soap_request)
|
|
63
59
|
end
|
|
64
60
|
|
|
65
61
|
def jsns
|
|
@@ -46,12 +46,12 @@ module Zm
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def to_h
|
|
49
|
-
|
|
49
|
+
instance_variables_map.to_h
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def inspect
|
|
53
53
|
keys_str = to_h.map { |k, v| "#{k}: #{v}" }.join(', ')
|
|
54
|
-
"#{self.class}:#{format('0x00%x',
|
|
54
|
+
"#{self.class}:#{format('0x00%x', object_id << 1)} #{keys_str}"
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def instance_variables_map
|
|
@@ -11,17 +11,21 @@ module Zm
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def ids
|
|
14
|
-
@json
|
|
14
|
+
@json.dig(:Body, json_key, :hit)&.map { |s| s[:id] } || []
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
private
|
|
18
18
|
|
|
19
19
|
def json_items
|
|
20
|
-
@json_items
|
|
20
|
+
return @json_items if defined? @json_items
|
|
21
|
+
|
|
22
|
+
@json_items = @json[json_key][@json_item_key]
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def json_key
|
|
24
|
-
@json_key
|
|
26
|
+
return @json_key if defined? @json_key
|
|
27
|
+
|
|
28
|
+
@json_key = @json.keys.first
|
|
25
29
|
end
|
|
26
30
|
end
|
|
27
31
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'set'
|
|
4
3
|
module Zm
|
|
5
4
|
module Client
|
|
6
5
|
module Base
|
|
@@ -27,45 +26,37 @@ module Zm
|
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
def all
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def all!
|
|
34
|
-
@all = build_response
|
|
29
|
+
build_response
|
|
35
30
|
end
|
|
31
|
+
alias all! all
|
|
36
32
|
|
|
37
33
|
def per_page(limit)
|
|
38
34
|
return self if @limit == limit
|
|
39
35
|
|
|
40
|
-
@all = nil
|
|
41
36
|
@limit = limit
|
|
42
37
|
self
|
|
43
38
|
end
|
|
44
|
-
|
|
45
39
|
alias limit per_page
|
|
46
40
|
|
|
47
41
|
def page(offset)
|
|
48
42
|
return self if @offset == offset
|
|
49
43
|
|
|
50
|
-
@all = nil
|
|
51
44
|
@offset = offset
|
|
52
45
|
self
|
|
53
46
|
end
|
|
54
|
-
|
|
55
47
|
alias offset page
|
|
56
48
|
|
|
57
49
|
def order(sort_by, sort_ascending = SoapUtils::ON)
|
|
58
50
|
return self if @sort_by == sort_by && @sort_ascending == sort_ascending
|
|
59
51
|
|
|
60
|
-
@all = nil
|
|
61
52
|
@sort_by = sort_by
|
|
62
53
|
@sort_ascending = sort_ascending
|
|
63
54
|
self
|
|
64
55
|
end
|
|
65
56
|
|
|
66
|
-
def method_missing(method,
|
|
57
|
+
def method_missing(method, *, &)
|
|
67
58
|
if METHODS_MISSING_LIST.include?(method)
|
|
68
|
-
build_response.send(method,
|
|
59
|
+
build_response.send(method, *, &)
|
|
69
60
|
else
|
|
70
61
|
super
|
|
71
62
|
end
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'ostruct'
|
|
4
|
-
require 'version_sorter'
|
|
5
|
-
|
|
6
3
|
module Zm
|
|
7
4
|
module Client
|
|
8
5
|
module Base
|
|
9
6
|
class ZimbraAttribute
|
|
10
|
-
attr_reader :name, :optionalIn, :flags, :requiredIn, :cardinality, :callback, :immutable, :type, :value, :max,
|
|
7
|
+
attr_reader :name, :optionalIn, :flags, :requiredIn, :cardinality, :callback, :immutable, :type, :value, :max,
|
|
8
|
+
:min, :since
|
|
11
9
|
|
|
12
|
-
def initialize(name: nil, optionalIn: nil, flags: nil, requiredIn: nil, cardinality: nil, callback: nil,
|
|
10
|
+
def initialize(name: nil, optionalIn: nil, flags: nil, requiredIn: nil, cardinality: nil, callback: nil,
|
|
11
|
+
immutable: nil, type: nil, value: nil, max: nil, min: nil, since: nil)
|
|
13
12
|
@name = name
|
|
14
13
|
@optionalIn = optionalIn.to_s.split(',')
|
|
15
14
|
@flags = flags
|
|
@@ -24,18 +23,6 @@ module Zm
|
|
|
24
23
|
@since = since
|
|
25
24
|
end
|
|
26
25
|
|
|
27
|
-
def version_start
|
|
28
|
-
return @version_start unless @version_start.nil?
|
|
29
|
-
|
|
30
|
-
@version_start = if since.nil?
|
|
31
|
-
'0.0.0'
|
|
32
|
-
else
|
|
33
|
-
VersionSorter.sort(since.split(',')).first
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
@version_start
|
|
37
|
-
end
|
|
38
|
-
|
|
39
26
|
def immutable?
|
|
40
27
|
immutable == '1'
|
|
41
28
|
end
|