zm-ruby-client 3.0.1 → 3.1.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/CHANGELOG.md +96 -0
- data/README.md +128 -27
- data/VERSION +1 -1
- data/lib/zm/client/account/account.rb +12 -19
- data/lib/zm/client/account/account_aliases_collection.rb +6 -4
- data/lib/zm/client/account/account_dls_membership_collection.rb +4 -3
- data/lib/zm/client/account/account_dls_owner_collection.rb +3 -2
- data/lib/zm/client/account/account_jsns_builder.rb +10 -10
- data/lib/zm/client/account/accounts_collection.rb +27 -16
- data/lib/zm/client/ace/ace.rb +3 -6
- data/lib/zm/client/ace/ace_jsns_builder.rb +6 -6
- data/lib/zm/client/appointment/appointment.rb +32 -14
- data/lib/zm/client/appointment/appointment_jsns_builder.rb +5 -5
- data/lib/zm/client/appointment/appointment_jsns_initializer.rb +6 -1
- data/lib/zm/client/appointment/appointments_collection.rb +12 -9
- data/lib/zm/client/backup/backup.rb +5 -2
- data/lib/zm/client/backup/backups_collection.rb +3 -2
- data/lib/zm/client/base/account_objects_collection.rb +1 -0
- data/lib/zm/client/base/account_search_objects_collection.rb +6 -6
- data/lib/zm/client/base/admin_objects_collection.rb +60 -7
- data/lib/zm/client/base/base_account_jsns_builder.rb +89 -87
- data/lib/zm/client/base/base_jsns_builder.rb +3 -3
- data/lib/zm/client/base/base_jsns_initializer.rb +20 -15
- data/lib/zm/client/base/mailbox_infos_collection.rb +92 -90
- data/lib/zm/client/base/mailbox_object.rb +49 -160
- data/lib/zm/client/base/mailbox_prefs_collection.rb +54 -52
- data/lib/zm/client/base/object.rb +19 -2
- data/lib/zm/client/base/objects_collection.rb +10 -10
- data/lib/zm/client/base/zimbra_attribute.rb +28 -42
- data/lib/zm/client/base/zimbra_attributes_collection.rb +38 -24
- data/lib/zm/client/{cluster/batch_request.rb → batch_request.rb} +1 -1
- data/lib/zm/client/cluster/cluster.rb +24 -61
- data/lib/zm/client/cluster/cluster_config.rb +35 -15
- data/lib/zm/client/contact/contact.rb +15 -13
- data/lib/zm/client/contact/contact_jsns_builder.rb +9 -6
- data/lib/zm/client/contact/contact_jsns_initializer.rb +2 -2
- data/lib/zm/client/contact/contact_member.rb +3 -3
- data/lib/zm/client/contact/contact_members_collection.rb +3 -3
- data/lib/zm/client/contact/contacts_builder.rb +1 -1
- data/lib/zm/client/contact/contacts_collection.rb +2 -2
- data/lib/zm/client/contact/group_contact_jsns_builder.rb +18 -14
- data/lib/zm/client/contact/mod_group_contact.rb +12 -8
- data/lib/zm/client/cos/cos.rb +15 -31
- data/lib/zm/client/cos/cos_jsns_builder.rb +21 -21
- data/lib/zm/client/cos/coses_collection.rb +11 -6
- data/lib/zm/client/datasource/datasource.rb +3 -9
- data/lib/zm/client/datasource/datasource_jsns_builder.rb +4 -4
- data/lib/zm/client/datasource/datasources_builder.rb +1 -1
- data/lib/zm/client/datasource/datasources_collection.rb +2 -2
- data/lib/zm/client/deprecated_constants.rb +36 -0
- data/lib/zm/client/distributionlist/distributionlist.rb +15 -47
- data/lib/zm/client/distributionlist/distributionlist_aces_collection.rb +4 -4
- data/lib/zm/client/distributionlist/distributionlist_aliases_collection.rb +7 -5
- data/lib/zm/client/distributionlist/distributionlist_jsns_builder.rb +29 -41
- data/lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb +14 -3
- data/lib/zm/client/distributionlist/distributionlist_members_collection.rb +14 -10
- data/lib/zm/client/distributionlist/distributionlist_owners_collection.rb +13 -13
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +15 -7
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +8 -6
- data/lib/zm/client/document/document.rb +5 -11
- data/lib/zm/client/document/document_jsns_builder.rb +2 -2
- data/lib/zm/client/document/documents_collection.rb +4 -4
- data/lib/zm/client/domain/domain.rb +8 -25
- data/lib/zm/client/domain/domain_jsns_builder.rb +13 -13
- data/lib/zm/client/domain/domains_collection.rb +13 -6
- data/lib/zm/client/filter_rules/filter_rules_collection.rb +1 -1
- data/lib/zm/client/filter_rules/outgoing_filter_rules_collection.rb +1 -1
- data/lib/zm/client/folder/folder.rb +34 -21
- data/lib/zm/client/folder/folder_default.rb +39 -0
- data/lib/zm/client/folder/folder_grant_jsns_builder.rb +3 -3
- data/lib/zm/client/folder/folder_grants_collection.rb +1 -1
- data/lib/zm/client/folder/folder_jsns_builder.rb +12 -12
- data/lib/zm/client/folder/folder_jsns_initializer.rb +1 -1
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +6 -2
- data/lib/zm/client/folder/folder_view.rb +15 -0
- data/lib/zm/client/folder/folders_jsns_builder.rb +1 -1
- data/lib/zm/client/folder/mod_document_folder.rb +16 -12
- data/lib/zm/client/identity/identities_collection.rb +1 -1
- data/lib/zm/client/identity/identity.rb +3 -9
- data/lib/zm/client/identity/identity_jsns_builder.rb +8 -8
- data/lib/zm/client/{base/ldap_filter.rb → ldap_filter.rb} +1 -1
- data/lib/zm/client/license/licenses_collection.rb +1 -1
- data/lib/zm/client/mailbox/mailbox_item_concern.rb +0 -2
- data/lib/zm/client/message/message.rb +14 -19
- data/lib/zm/client/message/message_attachments_collection.rb +39 -0
- data/lib/zm/client/message/message_flags_collection.rb +130 -0
- data/lib/zm/client/message/message_jsns_builder.rb +4 -8
- data/lib/zm/client/message/message_jsns_initializer.rb +4 -4
- data/lib/zm/client/message/message_recipients.rb +19 -43
- data/lib/zm/client/message/messages_collection.rb +20 -4
- data/lib/zm/client/mountpoint/{mountpoint.rb → mount_point.rb} +4 -10
- data/lib/zm/client/mountpoint/{mountpoint_jsns_builder.rb → mount_point_jsns_builder.rb} +3 -3
- data/lib/zm/client/mountpoint/{mountpoint_jsns_initializer.rb → mount_point_jsns_initializer.rb} +1 -1
- data/lib/zm/client/mountpoint/{mountpoints_builder.rb → mount_points_builder.rb} +1 -1
- data/lib/zm/client/mta_queue/mta_queue.rb +4 -16
- data/lib/zm/client/mta_queue/mta_queue_action.rb +12 -0
- data/lib/zm/client/mta_queue/mta_queue_jsns_builder.rb +7 -7
- data/lib/zm/client/mta_queue/mta_queue_name.rb +14 -0
- data/lib/zm/client/mta_queue/mta_queues_collection.rb +4 -3
- data/lib/zm/client/mta_queue_item/mta_queue_items_collection.rb +1 -0
- data/lib/zm/client/recipient.rb +21 -0
- data/lib/zm/client/{common/recipients.rb → recipients.rb} +0 -16
- data/lib/zm/client/resource/resource.rb +3 -7
- data/lib/zm/client/resource/resource_jsns_builder.rb +13 -13
- data/lib/zm/client/resource/resources_collection.rb +20 -7
- data/lib/zm/client/search_folder/search_folder.rb +4 -11
- data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +6 -6
- data/lib/zm/client/search_folder/search_folders_collection.rb +1 -1
- data/lib/zm/client/server/server.rb +16 -22
- data/lib/zm/client/server/server_services.rb +26 -0
- data/lib/zm/client/server/servers_collection.rb +6 -6
- data/lib/zm/client/share/share.rb +2 -5
- data/lib/zm/client/share/shares_builder.rb +1 -1
- data/lib/zm/client/share/shares_collection.rb +5 -4
- data/lib/zm/client/signature/signature.rb +7 -13
- data/lib/zm/client/signature/signature_jsns_builder.rb +13 -13
- data/lib/zm/client/signature/signature_jsns_initializer.rb +2 -2
- data/lib/zm/client/signature/signatures_collection.rb +1 -1
- data/lib/zm/client/tag/account_object_tags_collection.rb +45 -47
- data/lib/zm/client/tag/tag.rb +3 -9
- data/lib/zm/client/tag/tag_jsns_builder.rb +3 -3
- data/lib/zm/client/tag/tags_builder.rb +1 -1
- data/lib/zm/client/tag/tags_collection.rb +2 -2
- data/lib/zm/client/task/task.rb +2 -2
- data/lib/zm/client/task/tasks_collection.rb +2 -2
- data/lib/zm/client/token.rb +4 -1
- data/lib/zm/client/upload.rb +179 -1
- data/lib/zm/client/{common/utils.rb → utils.rb} +6 -3
- data/lib/zm/client/zm_logger.rb +1 -1
- data/lib/zm/client.rb +227 -10
- data/lib/zm/connector/network_error_handler.rb +18 -0
- data/lib/zm/{client/connector → connector}/rest_connector.rb +46 -40
- data/lib/zm/{client/connector/soap_account.rb → connector/soap_account_connector.rb} +15 -17
- data/lib/zm/{client/connector/soap_admin.rb → connector/soap_admin_connector.rb} +3 -5
- data/lib/zm/connector/soap_base_connector.rb +115 -0
- data/lib/zm/connector.rb +13 -0
- data/lib/zm/error/auth_error.rb +8 -0
- data/lib/zm/error/connection_error.rb +8 -0
- data/lib/zm/error/rest_error.rb +8 -0
- data/lib/zm/{client/connector → error}/soap_error.rb +1 -10
- data/lib/zm/error/zm_error.rb +8 -0
- data/lib/zm/error.rb +11 -0
- data/lib/zm/relationship/has_many.rb +22 -0
- data/lib/zm/relationship/jsns_builder.rb +21 -0
- data/lib/zm/relationship/relationship.rb +113 -0
- data/lib/zm/relationship/schema.rb +32 -0
- data/lib/zm/relationship.rb +5 -0
- data/lib/zm/{client/soap_request → soap_request}/request_methods_admin.rb +11 -5
- data/lib/zm/{client/soap_request → soap_request}/request_methods_mailbox.rb +1 -1
- data/lib/zm/{client/soap_request/account_soap_constants.rb → soap_request/soap_account_constants.rb} +1 -1
- data/lib/zm/{client/soap_request/admin_soap_constants.rb → soap_request/soap_admin_constants.rb} +1 -1
- data/lib/zm/{client/soap_request → soap_request}/soap_constants.rb +1 -1
- data/lib/zm/{client/soap_request → soap_request}/soap_context.rb +13 -5
- data/lib/zm/{client/soap_request → soap_request}/soap_element.rb +1 -1
- data/lib/zm/{client/soap_request/mail_soap_constants.rb → soap_request/soap_mail_constants.rb} +1 -1
- data/lib/zm/soap_request.rb +14 -0
- data/lib/zm/support/cache/entry.rb +3 -3
- data/lib/zm/support/cache/file_store.rb +4 -6
- data/lib/zm/support/cache/null_store.rb +2 -4
- data/lib/zm/support/cache/store.rb +17 -9
- data/lib/zm/support/cache.rb +13 -8
- data/lib/zm/support.rb +7 -0
- data/lib/zm/{modules → utils}/belongs_to_folder.rb +1 -1
- data/lib/zm/{modules → utils}/belongs_to_tag.rb +2 -2
- data/lib/zm/utils/content_part.rb +9 -0
- data/lib/zm/utils/content_type.rb +11 -0
- data/lib/zm/{modules → utils}/has_soap_admin_connector.rb +1 -1
- data/lib/zm/utils/inspector.rb +26 -0
- data/lib/zm/utils/log_filter.rb +30 -0
- data/lib/zm/utils/missing_method_static_collection.rb +17 -0
- data/lib/zm/utils/regex.rb +11 -0
- data/lib/zm/utils/search_utils.rb +13 -0
- data/lib/zm/utils.rb +16 -0
- data/lib/zm-ruby-client.rb +12 -0
- data/sig/zm/client/admin_objects.rbs +261 -0
- data/sig/zm/client/base.rbs +191 -0
- data/sig/zm/client/cluster.rbs +152 -0
- data/sig/zm/client/mailbox.rbs +766 -0
- data/sig/zm/error.rbs +23 -0
- metadata +99 -91
- data/.gitignore +0 -59
- data/.rubocop.yml +0 -6
- data/.ruby-version +0 -1
- data/Gemfile +0 -11
- data/SECURITY.md +0 -21
- data/bin/console +0 -11
- data/lib/zm/client/account.rb +0 -9
- data/lib/zm/client/ace.rb +0 -7
- data/lib/zm/client/appointment.rb +0 -7
- data/lib/zm/client/backup.rb +0 -6
- data/lib/zm/client/base.rb +0 -21
- data/lib/zm/client/cluster.rb +0 -4
- data/lib/zm/client/common/message.rb +0 -10
- data/lib/zm/client/common.rb +0 -5
- data/lib/zm/client/connector/soap_base.rb +0 -104
- data/lib/zm/client/constant.rb +0 -229
- data/lib/zm/client/contact.rb +0 -11
- data/lib/zm/client/cos.rb +0 -10
- data/lib/zm/client/datasource.rb +0 -7
- data/lib/zm/client/distributionlist.rb +0 -8
- data/lib/zm/client/document.rb +0 -7
- data/lib/zm/client/domain.rb +0 -10
- data/lib/zm/client/filter_rule.rb +0 -7
- data/lib/zm/client/folder.rb +0 -14
- data/lib/zm/client/identity.rb +0 -7
- data/lib/zm/client/license.rb +0 -5
- data/lib/zm/client/message/attachments_collection.rb +0 -55
- data/lib/zm/client/message/message_flags.rb +0 -115
- data/lib/zm/client/message.rb +0 -10
- data/lib/zm/client/mountpoint.rb +0 -7
- data/lib/zm/client/mta_queue.rb +0 -7
- data/lib/zm/client/mta_queue_item.rb +0 -6
- data/lib/zm/client/resource.rb +0 -7
- data/lib/zm/client/search_folder.rb +0 -7
- data/lib/zm/client/server.rb +0 -7
- data/lib/zm/client/share.rb +0 -7
- data/lib/zm/client/signature.rb +0 -7
- data/lib/zm/client/soap_request.rb +0 -11
- data/lib/zm/client/tag.rb +0 -8
- data/lib/zm/client/task.rb +0 -6
- data/lib/zm/client/upload/upload.rb +0 -160
- data/lib/zm/modules/base.rb +0 -9
- data/lib/zm/modules/common/zimbra-attrs.json +0 -58
- data/lib/zm/modules/inspector.rb +0 -24
- data/lib/zm/modules/missing_method_static_collection.rb +0 -13
- data/lib/zm/modules/zm_model.rb +0 -43
- data/zm-ruby-client.gemspec +0 -27
- /data/lib/zm/client/mountpoint/{mountpoints_collection.rb → mount_points_collection.rb} +0 -0
|
@@ -5,6 +5,9 @@ module Zm
|
|
|
5
5
|
module Base
|
|
6
6
|
# class for account object jsns initializer
|
|
7
7
|
class BaseJsnsInitializer
|
|
8
|
+
INTEGER_REGEX = /\A(?:0|-?[1-9]\d*)\z/
|
|
9
|
+
SETTERS = Hash.new { |h, name| h[name] = :"#{name}=" }
|
|
10
|
+
|
|
8
11
|
class << self
|
|
9
12
|
def create(parent, json)
|
|
10
13
|
klass.new(parent).tap do |item|
|
|
@@ -26,32 +29,34 @@ module Zm
|
|
|
26
29
|
def formatted_json(json)
|
|
27
30
|
return [] if json[:a].nil?
|
|
28
31
|
|
|
29
|
-
json[:a].
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
hash_multivalued = json_map.each_with_object({}) do |(k, v), h|
|
|
33
|
-
h[k] ||= []
|
|
34
|
-
h[k].push(v)
|
|
32
|
+
json[:a].each_with_object({}) do |n, h|
|
|
33
|
+
add_value(h, n[:n], n[:_content]) unless n[:n].nil?
|
|
35
34
|
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def add_value(hash, key, value)
|
|
38
|
+
current = hash.fetch(key, hash)
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
if current.equal?(hash)
|
|
41
|
+
hash[key] = value
|
|
42
|
+
elsif current.is_a?(Array)
|
|
43
|
+
current << value
|
|
44
|
+
else
|
|
45
|
+
hash[key] = [current, value]
|
|
39
46
|
end
|
|
40
47
|
end
|
|
41
48
|
|
|
42
49
|
def valorise(item, k, v)
|
|
43
|
-
|
|
44
|
-
return unless item.respond_to?(
|
|
50
|
+
setter = SETTERS[k]
|
|
51
|
+
return unless item.respond_to?(setter)
|
|
45
52
|
|
|
46
|
-
item.send(
|
|
53
|
+
item.send(setter, convert_json_string_value(v))
|
|
47
54
|
end
|
|
48
55
|
|
|
49
56
|
def convert_json_string_value(value)
|
|
50
|
-
return value unless value.is_a?(String)
|
|
51
|
-
return 0 if value == '0'
|
|
57
|
+
return value unless value.is_a?(String) && INTEGER_REGEX.match?(value)
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
c.to_s == value ? c : value
|
|
59
|
+
value.to_i
|
|
55
60
|
end
|
|
56
61
|
end
|
|
57
62
|
end
|
|
@@ -2,96 +2,98 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
entries
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
entries
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
5
|
+
module Base
|
|
6
|
+
class MailboxInfosCollection
|
|
7
|
+
def initialize(parent)
|
|
8
|
+
@parent = parent
|
|
9
|
+
@sections = []
|
|
10
|
+
@rights = []
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def all
|
|
14
|
+
build_response
|
|
15
|
+
end
|
|
16
|
+
alias all! all
|
|
17
|
+
|
|
18
|
+
def clear
|
|
19
|
+
reset_query_params
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def sections(*entries)
|
|
23
|
+
entries.flatten!
|
|
24
|
+
@sections += entries
|
|
25
|
+
self
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def rights(*entries)
|
|
29
|
+
entries.flatten!
|
|
30
|
+
@rights += entries
|
|
31
|
+
self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def read
|
|
35
|
+
reset_query_params
|
|
36
|
+
@sections = ['mbox']
|
|
37
|
+
rep = build_response
|
|
38
|
+
@parent.id = rep[:id]
|
|
39
|
+
@parent.used = rep[:used]
|
|
40
|
+
@parent.public_url = rep[:publicURL]
|
|
41
|
+
@parent.zimbraCOSId = rep[:cos][:id]
|
|
42
|
+
@parent.home_url = rep[:rest]
|
|
43
|
+
rep
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def zimbraMailHost
|
|
47
|
+
@zimbraMailHost || zimbraMailHost!
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def zimbraMailHost!
|
|
51
|
+
return if @parent.name.nil? && @parent.id.nil?
|
|
52
|
+
|
|
53
|
+
soap_request = SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::GET_ACCOUNT_INFO_REQUEST)
|
|
54
|
+
|
|
55
|
+
node_entry = if @parent.id
|
|
56
|
+
SoapRequest::SoapElement.create(SoapRequest::SoapConstants::ACCOUNT)
|
|
57
|
+
.add_attribute(SoapRequest::SoapConstants::BY, SoapRequest::SoapConstants::ID)
|
|
58
|
+
.add_content(@parent.id)
|
|
59
|
+
else
|
|
60
|
+
SoapRequest::SoapElement.create(SoapRequest::SoapConstants::ACCOUNT)
|
|
61
|
+
.add_attribute(SoapRequest::SoapConstants::BY, SoapRequest::SoapConstants::NAME)
|
|
62
|
+
.add_content(@parent.name)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
soap_request.add_node(node_entry)
|
|
66
|
+
|
|
67
|
+
@zimbraMailHost = @parent.soap_connector
|
|
68
|
+
.invoke(soap_request)
|
|
69
|
+
.dig(:GetAccountInfoResponse, :_attrs, :zimbraMailHost)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
|
|
74
|
+
def build_response
|
|
75
|
+
make_query[:GetInfoResponse]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def make_query
|
|
79
|
+
soap_request = SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::GET_INFO_REQUEST)
|
|
80
|
+
.add_attributes(jsns)
|
|
81
|
+
@parent.soap_connector.invoke(soap_request)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def jsns
|
|
85
|
+
h = {
|
|
86
|
+
rights: @rights.join(','),
|
|
87
|
+
sections: @sections.join(',')
|
|
88
|
+
}
|
|
89
|
+
h.compact!
|
|
90
|
+
h
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def reset_query_params
|
|
94
|
+
@sections.clear
|
|
95
|
+
@rights.clear
|
|
96
|
+
end
|
|
95
97
|
end
|
|
96
98
|
end
|
|
97
99
|
end
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'zm/client/mailbox/mailbox_item_concern'
|
|
4
|
-
require 'zm/client/connector/rest_connector'
|
|
5
|
-
require 'zm/client/signature'
|
|
6
|
-
require 'zm/client/folder'
|
|
7
|
-
require 'zm/client/mountpoint'
|
|
8
|
-
require 'zm/client/search_folder'
|
|
9
|
-
require 'zm/client/share'
|
|
10
|
-
require 'zm/client/tag'
|
|
11
|
-
require 'zm/client/ace'
|
|
12
|
-
require 'zm/client/contact'
|
|
13
|
-
require 'zm/client/appointment'
|
|
14
|
-
require 'zm/client/task'
|
|
15
|
-
require 'zm/client/document'
|
|
16
|
-
require 'zm/client/message'
|
|
17
|
-
require 'zm/client/identity'
|
|
18
|
-
require 'zm/client/upload'
|
|
19
|
-
require 'zm/client/filter_rule'
|
|
20
|
-
require 'zm/client/datasource'
|
|
21
|
-
|
|
22
3
|
module Zm
|
|
23
4
|
module Client
|
|
24
5
|
module Base
|
|
25
6
|
# Abstract Class for Account and Resource
|
|
26
7
|
class MailboxObject < Object
|
|
27
|
-
include HasSoapAdminConnector
|
|
8
|
+
include Zm::Utils::HasSoapAdminConnector
|
|
9
|
+
extend Zm::Relationship
|
|
28
10
|
|
|
29
11
|
attr_accessor :home_url, :public_url, :password, :carLicense
|
|
30
12
|
attr_writer :used, :domain_key
|
|
@@ -32,7 +14,7 @@ module Zm
|
|
|
32
14
|
def soap_account_connector
|
|
33
15
|
return @soap_account_connector if defined? @soap_account_connector
|
|
34
16
|
|
|
35
|
-
@soap_account_connector = SoapAccountConnector.create(soap_config)
|
|
17
|
+
@soap_account_connector = Zm::Connector::SoapAccountConnector.create(soap_config)
|
|
36
18
|
end
|
|
37
19
|
|
|
38
20
|
def soap_connector
|
|
@@ -49,7 +31,7 @@ module Zm
|
|
|
49
31
|
@soap_connector.context.account(:name, @name)
|
|
50
32
|
end
|
|
51
33
|
else
|
|
52
|
-
raise ZmError, 'SoapConnector not defined'
|
|
34
|
+
raise Zm::Error::ZmError, 'SoapConnector not defined'
|
|
53
35
|
end
|
|
54
36
|
|
|
55
37
|
@soap_connector
|
|
@@ -61,17 +43,9 @@ module Zm
|
|
|
61
43
|
@domain_name = @name.split('@').last
|
|
62
44
|
end
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
@infos = MailboxInfosCollection.new(self)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def prefs
|
|
71
|
-
return @prefs if defined? @prefs
|
|
72
|
-
|
|
73
|
-
@prefs = MailboxPrefsCollection.new(self)
|
|
74
|
-
end
|
|
46
|
+
has_many :aliases, klass: :'Zm::Client::AccountAliasesCollection'
|
|
47
|
+
has_many :infos, klass: :'Zm::Client::Base::MailboxInfosCollection'
|
|
48
|
+
has_many :prefs, klass: :'Zm::Client::Base::MailboxPrefsCollection'
|
|
75
49
|
|
|
76
50
|
def used
|
|
77
51
|
@used || used!
|
|
@@ -90,8 +64,8 @@ module Zm
|
|
|
90
64
|
end
|
|
91
65
|
|
|
92
66
|
def mailbox_infos
|
|
93
|
-
soap_request = SoapElement.admin(SoapAdminConstants::GET_MAILBOX_REQUEST)
|
|
94
|
-
node_mbox = SoapElement.create(SoapConstants::MBOX).add_attribute(SoapConstants::ID, @id)
|
|
67
|
+
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::GET_MAILBOX_REQUEST)
|
|
68
|
+
node_mbox = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::MBOX).add_attribute(SoapRequest::SoapConstants::ID, @id)
|
|
95
69
|
soap_request.add_node(node_mbox)
|
|
96
70
|
sac.invoke(soap_request)[:GetMailboxResponse][:mbox].first
|
|
97
71
|
end
|
|
@@ -116,10 +90,10 @@ module Zm
|
|
|
116
90
|
end
|
|
117
91
|
|
|
118
92
|
def alive?
|
|
119
|
-
soap_request = SoapElement.mail(SoapMailConstants::NO_OP_REQUEST)
|
|
93
|
+
soap_request = SoapRequest::SoapElement.mail(SoapRequest::SoapMailConstants::NO_OP_REQUEST)
|
|
120
94
|
soap_connector.invoke(soap_request)
|
|
121
95
|
true
|
|
122
|
-
rescue Zm::
|
|
96
|
+
rescue Zm::Error::SoapError => e
|
|
123
97
|
logger.warn "Mailbox session token alive ? #{e.message}"
|
|
124
98
|
false
|
|
125
99
|
end
|
|
@@ -154,7 +128,7 @@ module Zm
|
|
|
154
128
|
|
|
155
129
|
def account_login_preauth(expires = 0)
|
|
156
130
|
logger.info 'Get Account session token by preauth access'
|
|
157
|
-
raise ZmError, 'domain key is required to login !' if domain_key.nil?
|
|
131
|
+
raise Zm::Error::ZmError, 'domain key is required to login !' if domain_key.nil?
|
|
158
132
|
|
|
159
133
|
content, by = account_content_by
|
|
160
134
|
|
|
@@ -163,7 +137,7 @@ module Zm
|
|
|
163
137
|
|
|
164
138
|
def account_login_password
|
|
165
139
|
logger.info 'Get Account session token by password access'
|
|
166
|
-
raise ZmError, 'password is required to login !' if password.nil?
|
|
140
|
+
raise Zm::Error::ZmError, 'password is required to login !' if password.nil?
|
|
167
141
|
|
|
168
142
|
content, by = account_content_by
|
|
169
143
|
|
|
@@ -177,13 +151,13 @@ module Zm
|
|
|
177
151
|
def admin_login
|
|
178
152
|
logger.info 'Get Account session token by Delegate access'
|
|
179
153
|
|
|
180
|
-
soap_request = SoapElement.admin(SoapAdminConstants::DELEGATE_AUTH_REQUEST)
|
|
181
|
-
node_account = SoapElement.create(SoapConstants::ACCOUNT)
|
|
154
|
+
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::DELEGATE_AUTH_REQUEST)
|
|
155
|
+
node_account = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::ACCOUNT)
|
|
182
156
|
|
|
183
157
|
if recorded?
|
|
184
|
-
node_account.add_attribute(SoapConstants::BY, SoapConstants::ID).add_content(@id)
|
|
158
|
+
node_account.add_attribute(SoapRequest::SoapConstants::BY, SoapRequest::SoapConstants::ID).add_content(@id)
|
|
185
159
|
else
|
|
186
|
-
node_account.add_attribute(SoapConstants::BY, SoapConstants::NAME).add_content(@name)
|
|
160
|
+
node_account.add_attribute(SoapRequest::SoapConstants::BY, SoapRequest::SoapConstants::NAME).add_content(@name)
|
|
187
161
|
end
|
|
188
162
|
|
|
189
163
|
soap_request.add_node(node_account)
|
|
@@ -194,114 +168,28 @@ module Zm
|
|
|
194
168
|
# Associations
|
|
195
169
|
# #################################################################
|
|
196
170
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return @mountpoints if defined? @mountpoints
|
|
211
|
-
|
|
212
|
-
@mountpoints = MountPointsCollection.new(self)
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
def search_folders
|
|
216
|
-
return @search_folders if defined? @search_folders
|
|
217
|
-
|
|
218
|
-
@search_folders = SearchFoldersCollection.new(self)
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
def identities
|
|
222
|
-
return @identities if defined? @identities
|
|
223
|
-
|
|
224
|
-
@identities = IdentitiesCollection.new(self)
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
def shares
|
|
228
|
-
return @shares if defined? @shares
|
|
229
|
-
|
|
230
|
-
@shares = SharesCollection.new(self)
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
def contacts
|
|
234
|
-
return @contacts if defined? @contacts
|
|
235
|
-
|
|
236
|
-
@contacts = ContactsCollection.new(self)
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
def appointments
|
|
240
|
-
return @appointments if defined? @appointments
|
|
241
|
-
|
|
242
|
-
@appointments = AppointmentsCollection.new(self)
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
def tags
|
|
246
|
-
return @tags if defined? @tags
|
|
247
|
-
|
|
248
|
-
@tags = TagsCollection.new(self)
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
def tasks
|
|
252
|
-
return @tasks if defined? @tasks
|
|
253
|
-
|
|
254
|
-
@tasks = TasksCollection.new(self)
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
def aces
|
|
258
|
-
return @aces if defined? @aces
|
|
259
|
-
|
|
260
|
-
@aces = AcesCollection.new(self)
|
|
261
|
-
end
|
|
171
|
+
has_many :messages
|
|
172
|
+
has_many :folders
|
|
173
|
+
has_many :mount_points
|
|
174
|
+
alias mountpoints mount_points
|
|
175
|
+
|
|
176
|
+
has_many :search_folders
|
|
177
|
+
has_many :identities
|
|
178
|
+
has_many :shares
|
|
179
|
+
has_many :contacts
|
|
180
|
+
has_many :appointments
|
|
181
|
+
has_many :tags
|
|
182
|
+
has_many :tasks
|
|
183
|
+
has_many :aces
|
|
262
184
|
alias rights aces
|
|
263
185
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return @documents if defined? @documents
|
|
272
|
-
|
|
273
|
-
@documents = DocumentsCollection.new(self)
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
def memberships
|
|
277
|
-
return @memberships if defined? @memberships
|
|
278
|
-
|
|
279
|
-
@memberships = AccountDlsMembershipCollection.new(self)
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
def dls_owner
|
|
283
|
-
return @dls_owner if defined? @dls_owner
|
|
284
|
-
|
|
285
|
-
@dls_owner = AccountDlsOwnerCollection.new(self)
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
def filter_rules
|
|
289
|
-
return @filter_rules if defined? @filter_rules
|
|
290
|
-
|
|
291
|
-
@filter_rules = FilterRulesCollection.new(self)
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
def outgoing_filter_rules
|
|
295
|
-
return @outgoing_filter_rules if defined? @outgoing_filter_rules
|
|
296
|
-
|
|
297
|
-
@outgoing_filter_rules = OutgoingFilterRulesCollection.new(self)
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
def data_sources
|
|
301
|
-
return @data_sources if defined? @data_sources
|
|
302
|
-
|
|
303
|
-
@data_sources = DataSourcesCollection.new(self)
|
|
304
|
-
end
|
|
186
|
+
has_many :signatures
|
|
187
|
+
has_many :documents
|
|
188
|
+
has_many :memberships, klass: :'Zm::Client::AccountDlsMembershipCollection'
|
|
189
|
+
has_many :dls_owner, klass: :'Zm::Client::AccountDlsOwnerCollection'
|
|
190
|
+
has_many :filter_rules
|
|
191
|
+
has_many :outgoing_filter_rules
|
|
192
|
+
has_many :data_sources
|
|
305
193
|
|
|
306
194
|
# #################################################################
|
|
307
195
|
# SOAP Actions
|
|
@@ -311,7 +199,7 @@ module Zm
|
|
|
311
199
|
new_password ||= @password
|
|
312
200
|
return false if new_password.nil?
|
|
313
201
|
|
|
314
|
-
soap_request = SoapElement.admin(SoapAdminConstants::SET_PASSWORD_REQUEST)
|
|
202
|
+
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::SET_PASSWORD_REQUEST)
|
|
315
203
|
soap_request.add_attributes({ id: @id, newPassword: new_password })
|
|
316
204
|
sac.invoke(soap_request)
|
|
317
205
|
|
|
@@ -319,7 +207,7 @@ module Zm
|
|
|
319
207
|
end
|
|
320
208
|
|
|
321
209
|
def local_transport
|
|
322
|
-
raise Zm::
|
|
210
|
+
raise Zm::Error::ZmError, 'zimbraMailHost is null' if zimbraMailHost.nil?
|
|
323
211
|
|
|
324
212
|
"lmtp:#{zimbraMailHost}:7025"
|
|
325
213
|
end
|
|
@@ -331,13 +219,13 @@ module Zm
|
|
|
331
219
|
def is_local_transport?
|
|
332
220
|
return false unless zimbraMailTransport
|
|
333
221
|
|
|
334
|
-
zimbraMailTransport.start_with?(SoapConstants::LMTP)
|
|
222
|
+
zimbraMailTransport.start_with?(SoapRequest::SoapConstants::LMTP)
|
|
335
223
|
end
|
|
336
224
|
|
|
337
225
|
def is_external_transport?
|
|
338
226
|
return false unless zimbraMailTransport
|
|
339
227
|
|
|
340
|
-
zimbraMailTransport.start_with?(SoapConstants::SMTP)
|
|
228
|
+
zimbraMailTransport.start_with?(SoapRequest::SoapConstants::SMTP)
|
|
341
229
|
end
|
|
342
230
|
|
|
343
231
|
def last_logon
|
|
@@ -350,16 +238,17 @@ module Zm
|
|
|
350
238
|
|
|
351
239
|
def build_uploader
|
|
352
240
|
tmp_token = soap_connector&.token
|
|
353
|
-
raise ZmError, 'token have to be set to instance Upload class' unless tmp_token
|
|
241
|
+
raise Zm::Error::ZmError, 'token have to be set to instance Upload class' unless tmp_token
|
|
354
242
|
|
|
355
|
-
Upload.new(rest_url, tmp_token, is_token_admin: soap_connector.is_a?(SoapAdminConnector), **rest_options)
|
|
243
|
+
Upload.new(rest_url, tmp_token, is_token_admin: soap_connector.is_a?(Zm::Connector::SoapAdminConnector), **rest_options)
|
|
356
244
|
end
|
|
357
245
|
|
|
358
246
|
def rest_options
|
|
359
247
|
if soap_config
|
|
360
248
|
{
|
|
361
249
|
timeout: soap_config.timeout,
|
|
362
|
-
verbose: soap_config.logger.debug
|
|
250
|
+
verbose: soap_config.logger.debug?,
|
|
251
|
+
ssl_options: soap_config.ssl_options
|
|
363
252
|
}
|
|
364
253
|
else
|
|
365
254
|
{}
|
|
@@ -367,19 +256,19 @@ module Zm
|
|
|
367
256
|
end
|
|
368
257
|
|
|
369
258
|
def rest_url
|
|
370
|
-
raise ZmError, 'name attribute is requuired for REST Url' unless @name
|
|
259
|
+
raise Zm::Error::ZmError, 'name attribute is requuired for REST Url' unless @name
|
|
371
260
|
|
|
372
261
|
if logged?
|
|
373
262
|
rest_account_url
|
|
374
263
|
elsif parent_logged?
|
|
375
264
|
rest_admin_url
|
|
376
265
|
else
|
|
377
|
-
raise ZmError, 'impossible to set rest_url'
|
|
266
|
+
raise Zm::Error::ZmError, 'impossible to set rest_url'
|
|
378
267
|
end
|
|
379
268
|
end
|
|
380
269
|
|
|
381
270
|
def rest_admin_url
|
|
382
|
-
raise ZmError, 'impossible to set rest_admin_url' unless soap_config.zimbra_admin_url
|
|
271
|
+
raise Zm::Error::ZmError, 'impossible to set rest_admin_url' unless soap_config.zimbra_admin_url
|
|
383
272
|
|
|
384
273
|
File.join(soap_config.zimbra_admin_url, 'home', @name)
|
|
385
274
|
end
|
|
@@ -390,7 +279,7 @@ module Zm
|
|
|
390
279
|
elsif home_url
|
|
391
280
|
home_url
|
|
392
281
|
else
|
|
393
|
-
raise ZmError, 'impossible to set rest_account_url'
|
|
282
|
+
raise Zm::Error::ZmError, 'impossible to set rest_account_url'
|
|
394
283
|
end
|
|
395
284
|
end
|
|
396
285
|
|