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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
|
-
module
|
|
4
|
+
module SoapRequest
|
|
5
5
|
module RequestMethodsAdmin
|
|
6
6
|
def delete!
|
|
7
7
|
sac.invoke(build_delete)
|
|
@@ -14,7 +14,7 @@ module Zm
|
|
|
14
14
|
|
|
15
15
|
def modify!
|
|
16
16
|
sac.invoke(build_modify)
|
|
17
|
-
true
|
|
17
|
+
@updated = true
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def build_modify
|
|
@@ -25,20 +25,26 @@ module Zm
|
|
|
25
25
|
jsns_builder.to_create
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def update!(hash)
|
|
28
|
+
def update!(hash = nil, update_attributes: true, **attrs)
|
|
29
|
+
hash = hash.nil? ? attrs : hash.merge(attrs)
|
|
29
30
|
return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?
|
|
30
31
|
|
|
31
32
|
do_update!(hash)
|
|
32
33
|
|
|
34
|
+
do_update_attributes(hash) if update_attributes
|
|
35
|
+
|
|
36
|
+
@updated = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def do_update_attributes(hash)
|
|
33
40
|
hash.each do |key, value|
|
|
34
41
|
update_attribute(key, value)
|
|
35
42
|
end
|
|
36
|
-
|
|
37
|
-
true
|
|
38
43
|
end
|
|
39
44
|
|
|
40
45
|
def rename!(new_name)
|
|
41
46
|
sac.invoke(build_rename(new_name))
|
|
47
|
+
@updated = true
|
|
42
48
|
@name = new_name
|
|
43
49
|
end
|
|
44
50
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
|
-
module
|
|
4
|
+
module SoapRequest
|
|
5
5
|
class SoapContext
|
|
6
|
-
# attr_reader :token, :user_agent, :target_server
|
|
7
|
-
|
|
8
6
|
def initialize
|
|
9
7
|
@token = nil
|
|
10
8
|
@user_agent = 'zmsoap'
|
|
@@ -12,11 +10,21 @@ module Zm
|
|
|
12
10
|
@account = nil
|
|
13
11
|
end
|
|
14
12
|
|
|
13
|
+
def initialize_copy(source)
|
|
14
|
+
super
|
|
15
|
+
@source = source
|
|
16
|
+
@token = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def token(str)
|
|
16
20
|
@token = str
|
|
17
21
|
self
|
|
18
22
|
end
|
|
19
23
|
|
|
24
|
+
def auth_token
|
|
25
|
+
@token || @source&.auth_token
|
|
26
|
+
end
|
|
27
|
+
|
|
20
28
|
def user_agent(str)
|
|
21
29
|
@user_agent = str
|
|
22
30
|
self
|
|
@@ -28,13 +36,13 @@ module Zm
|
|
|
28
36
|
end
|
|
29
37
|
|
|
30
38
|
def account(by, value)
|
|
31
|
-
@account = { by
|
|
39
|
+
@account = { by:, _content: value }
|
|
32
40
|
self
|
|
33
41
|
end
|
|
34
42
|
|
|
35
43
|
def to_hash
|
|
36
44
|
h = {
|
|
37
|
-
authToken:
|
|
45
|
+
authToken: auth_token,
|
|
38
46
|
userAgent: { name: @user_agent },
|
|
39
47
|
account: @account,
|
|
40
48
|
targetServer: @target_server
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module SoapRequest
|
|
5
|
+
autoload :SoapContext, 'zm/soap_request/soap_context'
|
|
6
|
+
autoload :SoapAdminConstants, 'zm/soap_request/soap_admin_constants'
|
|
7
|
+
autoload :SoapAccountConstants, 'zm/soap_request/soap_account_constants'
|
|
8
|
+
autoload :SoapMailConstants, 'zm/soap_request/soap_mail_constants'
|
|
9
|
+
autoload :SoapConstants, 'zm/soap_request/soap_constants'
|
|
10
|
+
autoload :SoapElement, 'zm/soap_request/soap_element'
|
|
11
|
+
autoload :RequestMethodsAdmin, 'zm/soap_request/request_methods_admin'
|
|
12
|
+
autoload :RequestMethodsMailbox, 'zm/soap_request/request_methods_mailbox'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -10,12 +10,12 @@ module Zm
|
|
|
10
10
|
def factory
|
|
11
11
|
@factory ||= MessagePack::Factory.new.tap do |msgpack_factory|
|
|
12
12
|
msgpack_factory.register_type(
|
|
13
|
-
|
|
13
|
+
0x02,
|
|
14
14
|
self,
|
|
15
15
|
packer: ->(entry) { entry.pack.to_msgpack },
|
|
16
16
|
unpacker: lambda { |data|
|
|
17
17
|
value, expires_at, version = MessagePack.unpack(data)
|
|
18
|
-
new(
|
|
18
|
+
new(value, version:, expires_at:)
|
|
19
19
|
}
|
|
20
20
|
)
|
|
21
21
|
end
|
|
@@ -49,7 +49,7 @@ module Zm
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def pack
|
|
52
|
-
members = [
|
|
52
|
+
members = [@value, @expires_at, @version]
|
|
53
53
|
members.pop while !members.empty? && members.last.nil?
|
|
54
54
|
members
|
|
55
55
|
end
|
|
@@ -6,10 +6,8 @@ module Zm
|
|
|
6
6
|
module Support
|
|
7
7
|
module Cache
|
|
8
8
|
class FileStore < Store
|
|
9
|
-
Cache.register_storage(:file_store, self)
|
|
10
|
-
|
|
11
9
|
class << self
|
|
12
|
-
def
|
|
10
|
+
def valid_options?(options)
|
|
13
11
|
options.key?(:cache_path)
|
|
14
12
|
end
|
|
15
13
|
end
|
|
@@ -54,7 +52,7 @@ module Zm
|
|
|
54
52
|
def read_serialized_entry(key, **)
|
|
55
53
|
File.binread(key) if File.exist?(key)
|
|
56
54
|
rescue StandardError => e
|
|
57
|
-
|
|
55
|
+
@logger&.error "FileStoreError (#{e}): #{e.message}"
|
|
58
56
|
nil
|
|
59
57
|
end
|
|
60
58
|
|
|
@@ -64,7 +62,7 @@ module Zm
|
|
|
64
62
|
|
|
65
63
|
def write_serialized_entry(key, payload, **)
|
|
66
64
|
ensure_cache_path(File.dirname(key))
|
|
67
|
-
File.
|
|
65
|
+
File.open(key, 'wb', 0o600) { |f| f.write(payload) }
|
|
68
66
|
true
|
|
69
67
|
end
|
|
70
68
|
|
|
@@ -120,7 +118,7 @@ module Zm
|
|
|
120
118
|
end
|
|
121
119
|
|
|
122
120
|
def ensure_cache_path(path)
|
|
123
|
-
FileUtils.makedirs(path)
|
|
121
|
+
FileUtils.makedirs(path, mode: 0o700)
|
|
124
122
|
end
|
|
125
123
|
|
|
126
124
|
def search_dir(dir, &callback)
|
|
@@ -4,10 +4,8 @@ module Zm
|
|
|
4
4
|
module Support
|
|
5
5
|
module Cache
|
|
6
6
|
class NullStore < Store
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def fetch(_name, _options = nil, &block)
|
|
10
|
-
block.call
|
|
7
|
+
def fetch(_name, _options = nil)
|
|
8
|
+
yield
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
def read(_name, _options = nil)
|
|
@@ -4,13 +4,17 @@ module Zm
|
|
|
4
4
|
module Support
|
|
5
5
|
module Cache
|
|
6
6
|
class Store
|
|
7
|
+
class << self
|
|
8
|
+
def valid_options?(options)
|
|
9
|
+
options.is_a?(Hash)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
attr_reader :options
|
|
8
14
|
attr_writer :logger
|
|
9
15
|
|
|
10
16
|
def initialize(options = {})
|
|
11
17
|
@options = options
|
|
12
|
-
@coder = Cache::Entry.factory
|
|
13
|
-
@digest = OpenSSL::Digest.new('sha256')
|
|
14
18
|
@logger = nil
|
|
15
19
|
end
|
|
16
20
|
|
|
@@ -64,7 +68,7 @@ module Zm
|
|
|
64
68
|
key = normalize_key(name, options)
|
|
65
69
|
version = normalize_version(options)
|
|
66
70
|
|
|
67
|
-
entry = Entry.new(value, **options, version:
|
|
71
|
+
entry = Entry.new(value, **options, version:)
|
|
68
72
|
write_entry(key, entry, **options)
|
|
69
73
|
end
|
|
70
74
|
|
|
@@ -114,9 +118,9 @@ module Zm
|
|
|
114
118
|
end
|
|
115
119
|
|
|
116
120
|
if namespace
|
|
117
|
-
|
|
121
|
+
OpenSSL::Digest::SHA256.hexdigest("#{namespace}:#{key}")
|
|
118
122
|
else
|
|
119
|
-
|
|
123
|
+
OpenSSL::Digest::SHA256.hexdigest(key)
|
|
120
124
|
end
|
|
121
125
|
end
|
|
122
126
|
|
|
@@ -177,18 +181,22 @@ module Zm
|
|
|
177
181
|
|
|
178
182
|
value = yield
|
|
179
183
|
|
|
180
|
-
entry = Entry.new(value, **options, version:
|
|
184
|
+
entry = Entry.new(value, **options, version:)
|
|
181
185
|
write_entry(key, entry, **options)
|
|
182
186
|
value
|
|
183
187
|
end
|
|
184
188
|
|
|
189
|
+
def coder
|
|
190
|
+
@coder ||= Entry.factory
|
|
191
|
+
end
|
|
192
|
+
|
|
185
193
|
def serialize_entry(entry, **)
|
|
186
|
-
|
|
194
|
+
coder.dump(entry)
|
|
187
195
|
end
|
|
188
196
|
|
|
189
197
|
def deserialize_entry(payload, **)
|
|
190
|
-
|
|
191
|
-
rescue DeserializationError
|
|
198
|
+
coder.load(payload)
|
|
199
|
+
rescue DeserializationError, MessagePack::UnpackError, EOFError
|
|
192
200
|
nil
|
|
193
201
|
end
|
|
194
202
|
end
|
data/lib/zm/support/cache.rb
CHANGED
|
@@ -5,22 +5,27 @@ module Zm
|
|
|
5
5
|
module Cache
|
|
6
6
|
DeserializationError = Class.new(StandardError)
|
|
7
7
|
|
|
8
|
+
autoload :Entry, 'zm/support/cache/entry'
|
|
9
|
+
autoload :Strategy, 'zm/support/cache/strategy'
|
|
10
|
+
autoload :RequestStrategy, 'zm/support/cache/request_strategy'
|
|
11
|
+
autoload :Store, 'zm/support/cache/store'
|
|
12
|
+
autoload :NullStore, 'zm/support/cache/null_store'
|
|
13
|
+
autoload :FileStore, 'zm/support/cache/file_store'
|
|
14
|
+
|
|
8
15
|
class << self
|
|
9
16
|
def registered_storage
|
|
10
|
-
@registered_storage ||= {}
|
|
17
|
+
@registered_storage ||= { null_store: :NullStore, file_store: :FileStore }
|
|
11
18
|
end
|
|
12
19
|
|
|
13
20
|
def register_storage(key, klass)
|
|
14
21
|
registered_storage[key] = klass
|
|
15
22
|
end
|
|
23
|
+
|
|
24
|
+
def storage(key)
|
|
25
|
+
klass = registered_storage[key]
|
|
26
|
+
klass.is_a?(Symbol) ? const_get(klass) : klass
|
|
27
|
+
end
|
|
16
28
|
end
|
|
17
29
|
end
|
|
18
30
|
end
|
|
19
31
|
end
|
|
20
|
-
|
|
21
|
-
require 'zm/support/cache/entry'
|
|
22
|
-
require 'zm/support/cache/strategy'
|
|
23
|
-
require 'zm/support/cache/request_strategy'
|
|
24
|
-
require 'zm/support/cache/store'
|
|
25
|
-
require 'zm/support/cache/null_store'
|
|
26
|
-
require 'zm/support/cache/file_store'
|
data/lib/zm/support.rb
ADDED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
|
-
module
|
|
4
|
+
module Utils
|
|
5
5
|
module BelongsToTag
|
|
6
6
|
def tags
|
|
7
7
|
return @tags if defined? @tags
|
|
8
8
|
|
|
9
|
-
@tags =
|
|
9
|
+
@tags = Zm::Client::AccountObjectTagsCollection.new(self)
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Utils
|
|
5
|
+
module Inspector
|
|
6
|
+
def to_s
|
|
7
|
+
inspect
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def to_h
|
|
11
|
+
instance_variables_map.to_h
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def inspect
|
|
15
|
+
keys_str = to_h.map { |k, v| "#{k}: #{v}" }.join(', ')
|
|
16
|
+
"#{self.class}:#{format('0x00%x', object_id << 1)} #{keys_str}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def instance_variables_map
|
|
20
|
+
keys = instance_variables.dup
|
|
21
|
+
keys.delete(:@parent)
|
|
22
|
+
keys.map { |key| [key, instance_variable_get(key)] }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Utils
|
|
5
|
+
# mask credentials and tokens in logged SOAP and HTTP payloads
|
|
6
|
+
module LogFilter
|
|
7
|
+
FILTERED = '[FILTERED]'
|
|
8
|
+
JSON_STRING = '"(?:[^"\\\\]|\\\\.)*"'
|
|
9
|
+
|
|
10
|
+
PATTERNS = [
|
|
11
|
+
[/("(?:password|newPassword|authToken)":)#{JSON_STRING}/o, "\\1\"#{FILTERED}\""],
|
|
12
|
+
[/("(?:authToken|preauth)":\[?\{[^}]*?"_content":)#{JSON_STRING}/o, "\\1\"#{FILTERED}\""],
|
|
13
|
+
[/("n":"(?:userPassword|zimbraPreAuthKey)","_content":)#{JSON_STRING}/o, "\\1\"#{FILTERED}\""],
|
|
14
|
+
[/(ZM_(?:ADMIN_)?AUTH_TOKEN=)[^;\s"]+/, "\\1#{FILTERED}"]
|
|
15
|
+
].freeze
|
|
16
|
+
|
|
17
|
+
module_function
|
|
18
|
+
|
|
19
|
+
def filter(str)
|
|
20
|
+
return str if str.nil?
|
|
21
|
+
|
|
22
|
+
PATTERNS.inject(str) { |result, (pattern, replacement)| result.gsub(pattern, replacement) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def apply(formatter)
|
|
26
|
+
PATTERNS.each { |pattern, replacement| formatter.filter(pattern, replacement) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Utils
|
|
5
|
+
module MissingMethodStaticCollection
|
|
6
|
+
attr_reader :all
|
|
7
|
+
|
|
8
|
+
def method_missing(method, *, &)
|
|
9
|
+
if @all.respond_to?(method)
|
|
10
|
+
@all.send(method, *, &)
|
|
11
|
+
else
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Utils
|
|
5
|
+
module Regex
|
|
6
|
+
UUID_REGEX = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
|
|
7
|
+
BASEDN_REGEX = /^uid=/
|
|
8
|
+
SHARED_CONTACT = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}:[0-9]+/
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
data/lib/zm/utils.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Utils
|
|
5
|
+
autoload :Inspector, 'zm/utils/inspector'
|
|
6
|
+
autoload :MissingMethodStaticCollection, 'zm/utils/missing_method_static_collection'
|
|
7
|
+
autoload :HasSoapAdminConnector, 'zm/utils/has_soap_admin_connector'
|
|
8
|
+
autoload :BelongsToFolder, 'zm/utils/belongs_to_folder'
|
|
9
|
+
autoload :BelongsToTag, 'zm/utils/belongs_to_tag'
|
|
10
|
+
autoload :Regex, 'zm/utils/regex'
|
|
11
|
+
autoload :ContentPart, 'zm/utils/content_part'
|
|
12
|
+
autoload :ContentType, 'zm/utils/content_type'
|
|
13
|
+
autoload :SearchUtils, 'zm/utils/search_utils'
|
|
14
|
+
autoload :LogFilter, 'zm/utils/log_filter'
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/zm-ruby-client.rb
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'date'
|
|
4
|
+
require 'time'
|
|
5
|
+
require 'faraday'
|
|
6
|
+
require 'openssl'
|
|
7
|
+
require 'json'
|
|
8
|
+
|
|
9
|
+
require 'zm/error'
|
|
10
|
+
require 'zm/utils'
|
|
11
|
+
require 'zm/connector'
|
|
12
|
+
require 'zm/support'
|
|
13
|
+
require 'zm/relationship'
|
|
14
|
+
require 'zm/soap_request'
|
|
3
15
|
require 'zm/client'
|