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
|
@@ -15,7 +15,9 @@ module Zm
|
|
|
15
15
|
|
|
16
16
|
attrs_only_set_h.each do |key, values|
|
|
17
17
|
values.each do |value|
|
|
18
|
-
node_attr = SoapElement.create(SoapConstants::A)
|
|
18
|
+
node_attr = SoapElement.create(SoapConstants::A)
|
|
19
|
+
.add_attribute(SoapConstants::N, key)
|
|
20
|
+
.add_content(value)
|
|
19
21
|
soap_request.add_node(node_attr)
|
|
20
22
|
end
|
|
21
23
|
end
|
|
@@ -25,12 +27,15 @@ module Zm
|
|
|
25
27
|
|
|
26
28
|
def to_update
|
|
27
29
|
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_COS_REQUEST)
|
|
28
|
-
node_cos = SoapElement.create(SoapConstants::ID)
|
|
30
|
+
node_cos = SoapElement.create(SoapConstants::ID)
|
|
31
|
+
.add_content(@item.id)
|
|
29
32
|
soap_request.add_node(node_cos)
|
|
30
33
|
|
|
31
34
|
attrs_only_set_h.each do |key, values|
|
|
32
35
|
values.each do |value|
|
|
33
|
-
node_attr = SoapElement.create(SoapConstants::A)
|
|
36
|
+
node_attr = SoapElement.create(SoapConstants::A)
|
|
37
|
+
.add_attribute(SoapConstants::N, key)
|
|
38
|
+
.add_content(value)
|
|
34
39
|
soap_request.add_node(node_attr)
|
|
35
40
|
end
|
|
36
41
|
end
|
|
@@ -40,13 +45,16 @@ module Zm
|
|
|
40
45
|
|
|
41
46
|
def to_patch(hash)
|
|
42
47
|
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_COS_REQUEST)
|
|
43
|
-
node_cos = SoapElement.create(SoapConstants::ID)
|
|
48
|
+
node_cos = SoapElement.create(SoapConstants::ID)
|
|
49
|
+
.add_content(@item.id)
|
|
44
50
|
soap_request.add_node(node_cos)
|
|
45
51
|
|
|
46
52
|
hash.each do |key, values|
|
|
47
53
|
values = [values] unless values.is_a?(Array)
|
|
48
54
|
values.each do |value|
|
|
49
|
-
node_attr = SoapElement.create(SoapConstants::A)
|
|
55
|
+
node_attr = SoapElement.create(SoapConstants::A)
|
|
56
|
+
.add_attribute(SoapConstants::N, key)
|
|
57
|
+
.add_content(value)
|
|
50
58
|
soap_request.add_node(node_attr)
|
|
51
59
|
end
|
|
52
60
|
end
|
|
@@ -56,12 +64,17 @@ module Zm
|
|
|
56
64
|
|
|
57
65
|
def to_copy(new_name)
|
|
58
66
|
soap_request = SoapElement.admin(SoapAdminConstants::COPY_COS_REQUEST)
|
|
59
|
-
node_name = SoapElement.create(SoapConstants::NAME)
|
|
67
|
+
node_name = SoapElement.create(SoapConstants::NAME)
|
|
68
|
+
.add_content(new_name)
|
|
60
69
|
|
|
61
70
|
if @item.id
|
|
62
|
-
node_cos = SoapElement.create(SoapConstants::COS)
|
|
71
|
+
node_cos = SoapElement.create(SoapConstants::COS)
|
|
72
|
+
.add_attribute(SoapConstants::BY, SoapConstants::ID)
|
|
73
|
+
.add_content(@item.id)
|
|
63
74
|
elsif @item.name
|
|
64
|
-
node_cos = SoapElement.create(SoapConstants::COS)
|
|
75
|
+
node_cos = SoapElement.create(SoapConstants::COS)
|
|
76
|
+
.add_attribute(SoapConstants::BY, SoapConstants::NAME)
|
|
77
|
+
.add_content(@item.name)
|
|
65
78
|
else
|
|
66
79
|
raise Zm::Client::ZmError, 'id or name attributes are required to clone cos'
|
|
67
80
|
end
|
|
@@ -88,7 +101,7 @@ module Zm
|
|
|
88
101
|
[n, values]
|
|
89
102
|
end
|
|
90
103
|
|
|
91
|
-
|
|
104
|
+
arr.to_h
|
|
92
105
|
end
|
|
93
106
|
end
|
|
94
107
|
end
|
|
@@ -5,14 +5,10 @@ module Zm
|
|
|
5
5
|
# class for initialize cos
|
|
6
6
|
class CosJsnsInitializer < Base::BaseJsnsInitializer
|
|
7
7
|
class << self
|
|
8
|
-
def
|
|
9
|
-
item = Cos.new(parent)
|
|
10
|
-
|
|
11
|
-
update(item, json)
|
|
12
|
-
end
|
|
8
|
+
def klass = Cos
|
|
13
9
|
|
|
14
10
|
def update(item, json)
|
|
15
|
-
item = super
|
|
11
|
+
item = super
|
|
16
12
|
|
|
17
13
|
case item.zimbraMailHostPool
|
|
18
14
|
when String
|
|
@@ -9,14 +9,11 @@ module Zm
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def all
|
|
12
|
-
@
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def all!
|
|
16
|
-
@all = @parent.zimbraMailHostPool.map do |server_id|
|
|
12
|
+
@parent.zimbraMailHostPool.map do |server_id|
|
|
17
13
|
servers_collection.find_by(id: server_id)
|
|
18
14
|
end
|
|
19
15
|
end
|
|
16
|
+
alias all! all
|
|
20
17
|
|
|
21
18
|
def add!(*servers)
|
|
22
19
|
servers.flatten!
|
|
@@ -55,7 +52,9 @@ module Zm
|
|
|
55
52
|
end
|
|
56
53
|
|
|
57
54
|
def servers_collection
|
|
58
|
-
@servers_collection
|
|
55
|
+
return @servers_collection if defined? @servers_collection
|
|
56
|
+
|
|
57
|
+
@servers_collection = ServersCollection.new(@parent)
|
|
59
58
|
end
|
|
60
59
|
end
|
|
61
60
|
end
|
|
@@ -8,12 +8,14 @@ module Zm
|
|
|
8
8
|
@child_class = Cos
|
|
9
9
|
@builder_class = CosesBuilder
|
|
10
10
|
@search_type = SearchType::COS
|
|
11
|
-
super
|
|
11
|
+
super
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def find_by!(hash)
|
|
15
15
|
soap_request = SoapElement.admin(SoapAdminConstants::GET_COS_REQUEST)
|
|
16
|
-
node_cos = SoapElement.create(SoapConstants::COS)
|
|
16
|
+
node_cos = SoapElement.create(SoapConstants::COS)
|
|
17
|
+
.add_attribute(SoapConstants::BY, hash.keys.first)
|
|
18
|
+
.add_content(hash.values.first)
|
|
17
19
|
soap_request.add_node(node_cos)
|
|
18
20
|
soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma)
|
|
19
21
|
entry = sac.invoke(soap_request)[:GetCosResponse][:cos].first
|
|
@@ -22,8 +24,8 @@ module Zm
|
|
|
22
24
|
CosJsnsInitializer.create(@parent, entry)
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
def clone!(new_name, &
|
|
26
|
-
cos = Cos.new(parent, &
|
|
27
|
+
def clone!(new_name, &)
|
|
28
|
+
cos = Cos.new(parent, &)
|
|
27
29
|
cos.clone!(new_name)
|
|
28
30
|
end
|
|
29
31
|
|
|
@@ -4,18 +4,20 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
# class account data source
|
|
6
6
|
class DataSource < Base::Object
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
:
|
|
13
|
-
:
|
|
14
|
-
:
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
:
|
|
7
|
+
include RequestMethodsMailbox
|
|
8
|
+
|
|
9
|
+
TYPES = %i[cal caldav yab gal imap pop3 rss unknown].freeze
|
|
10
|
+
|
|
11
|
+
attr_accessor :a, :cconnectionType, :cdefaultSignature, :cemailAddress, :cfailingSince,
|
|
12
|
+
:cforwardReplySignature, :cfromDisplay, :chost, :cid, :cimportClass, :cimportOnly,
|
|
13
|
+
:cisEnabled, :cl, :clientId, :clientSecret, :cname, :connectionType, :cpassword,
|
|
14
|
+
:cpollingInterval, :cport, :crefreshToken, :crefreshTokenUrl, :creplyToAddress,
|
|
15
|
+
:creplyToDisplay, :csmtpAuthRequired, :csmtpConnectionType, :csmtpEnabled, :csmtpHost,
|
|
16
|
+
:csmtpPassword, :csmtpPort, :csmtpUsername, :cuseAddressForForwardReply, :cusername,
|
|
17
|
+
:defaultSignature, :emailAddress, :failingSince, :forwardReplySignature, :fromDisplay,
|
|
18
|
+
:host, :id, :importClass, :importOnly, :isEnabled, :l, :lastError, :leaveOnServer, :name,
|
|
19
|
+
:oauthToken, :password, :pollingInterval, :port, :refreshToken, :refreshTokenUrl,
|
|
20
|
+
:replyToAddress, :replyToDisplay, :smtpAuthRequired, :smtpConnectionType, :smtpEnabled,
|
|
19
21
|
:smtpHost, :smtpPassword, :smtpPort, :smtpUsername, :test, :useAddressForForwardReply, :username,
|
|
20
22
|
:type
|
|
21
23
|
|
|
@@ -28,42 +30,33 @@ module Zm
|
|
|
28
30
|
raise NotImplementedError
|
|
29
31
|
end
|
|
30
32
|
|
|
31
|
-
def
|
|
33
|
+
def build_create
|
|
32
34
|
raise NotImplementedError
|
|
33
35
|
end
|
|
34
36
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
do_update!(hash)
|
|
39
|
-
|
|
40
|
-
hash.each do |key, value|
|
|
41
|
-
update_attribute(key, value)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
true
|
|
37
|
+
def modify!
|
|
38
|
+
raise NotImplementedError
|
|
45
39
|
end
|
|
46
40
|
|
|
47
|
-
def
|
|
41
|
+
def build_modify
|
|
48
42
|
raise NotImplementedError
|
|
49
43
|
end
|
|
50
44
|
|
|
51
|
-
def
|
|
52
|
-
|
|
45
|
+
def rename!(*args)
|
|
46
|
+
raise NotImplementedError
|
|
47
|
+
end
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
def build_rename(*args)
|
|
50
|
+
raise NotImplementedError
|
|
56
51
|
end
|
|
57
52
|
|
|
58
53
|
private
|
|
59
54
|
|
|
60
|
-
def do_update!(hash)
|
|
61
|
-
@parent.sacc.invoke(jsns_builder.to_patch(hash))
|
|
62
|
-
end
|
|
63
|
-
|
|
64
55
|
def jsns_builder
|
|
65
|
-
@jsns_builder
|
|
56
|
+
return @jsns_builder if defined? @jsns_builder
|
|
57
|
+
|
|
58
|
+
@jsns_builder = DataSourceJsnsBuilder.new(self)
|
|
66
59
|
end
|
|
67
60
|
end
|
|
68
61
|
end
|
|
69
|
-
end
|
|
62
|
+
end
|
|
@@ -6,17 +6,16 @@ module Zm
|
|
|
6
6
|
class DataSourceJsnsInitializer
|
|
7
7
|
class << self
|
|
8
8
|
def create(parent, data_source_type, json)
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
DataSource.new(parent, data_source_type).tap do |item|
|
|
10
|
+
update(item, json)
|
|
11
|
+
end
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def update(item, json)
|
|
14
15
|
json.each do |k, v|
|
|
15
|
-
setter_method = "#{k}="
|
|
16
|
+
setter_method = :"#{k}="
|
|
16
17
|
|
|
17
|
-
if item.respond_to?(setter_method)
|
|
18
|
-
item.send(setter_method, v)
|
|
19
|
-
end
|
|
18
|
+
item.send(setter_method, v) if item.respond_to?(setter_method)
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
item
|
|
@@ -7,22 +7,19 @@ module Zm
|
|
|
7
7
|
def make
|
|
8
8
|
return [] if json_items.nil?
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
entries.each do |entry|
|
|
15
|
-
ds << DataSourceJsnsInitializer.create(@parent, data_source_type, entry)
|
|
10
|
+
json_items.slice(*DataSource::TYPES).flat_map do |data_source_type, entries|
|
|
11
|
+
entries.map do |entry|
|
|
12
|
+
DataSourceJsnsInitializer.create(@parent, data_source_type, entry)
|
|
16
13
|
end
|
|
17
14
|
end
|
|
18
|
-
|
|
19
|
-
ds
|
|
20
15
|
end
|
|
21
16
|
|
|
22
17
|
private
|
|
23
18
|
|
|
24
19
|
def json_items
|
|
25
|
-
@json_items
|
|
20
|
+
return @json_items if defined? @json_items
|
|
21
|
+
|
|
22
|
+
@json_items = @json[json_key]
|
|
26
23
|
end
|
|
27
24
|
end
|
|
28
25
|
end
|
|
@@ -7,14 +7,15 @@ module Zm
|
|
|
7
7
|
def initialize(parent)
|
|
8
8
|
@child_class = DataSource
|
|
9
9
|
@builder_class = DataSourceBuilder
|
|
10
|
-
super
|
|
10
|
+
super
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
private
|
|
14
|
-
|
|
15
13
|
def make_query
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
@parent.soap_connector.invoke(build_query)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def build_query
|
|
18
|
+
SoapElement.mail(SoapMailConstants::GET_DATA_SOURCES_REQUEST)
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
end
|
|
@@ -10,59 +10,43 @@ module Zm
|
|
|
10
10
|
# objectClass: zimbraDistributionList
|
|
11
11
|
class DistributionList < Base::Object
|
|
12
12
|
include HasSoapAdminConnector
|
|
13
|
+
include RequestMethodsAdmin
|
|
13
14
|
|
|
14
15
|
def aliases
|
|
15
|
-
@aliases
|
|
16
|
+
return @aliases if defined? @aliases
|
|
17
|
+
|
|
18
|
+
@aliases = DistributionListAliasesCollection.new(self)
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
def members
|
|
19
|
-
@members
|
|
22
|
+
return @members if defined? @members
|
|
23
|
+
|
|
24
|
+
@members = DistributionListMembersCollection.new(self)
|
|
20
25
|
end
|
|
21
26
|
|
|
22
27
|
def owners
|
|
23
|
-
@owners
|
|
28
|
+
return @owners if defined? @owners
|
|
29
|
+
|
|
30
|
+
@owners = DistributionListOwnersCollection.new(self)
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
def memberships
|
|
27
|
-
@memberships
|
|
34
|
+
return @memberships if defined? @memberships
|
|
35
|
+
|
|
36
|
+
@memberships = DlsMembershipCollection.new(self)
|
|
28
37
|
end
|
|
29
38
|
|
|
30
39
|
def aces
|
|
31
|
-
@aces
|
|
40
|
+
return @aces if defined? @aces
|
|
41
|
+
|
|
42
|
+
@aces = DistributionListAcesCollection.new(self)
|
|
32
43
|
end
|
|
33
44
|
|
|
34
45
|
def create!
|
|
35
|
-
resp = sac.invoke(
|
|
46
|
+
resp = sac.invoke(build_create)
|
|
36
47
|
@id = resp[:CreateDistributionListResponse][:dl].first[:id]
|
|
37
48
|
end
|
|
38
49
|
|
|
39
|
-
def modify!
|
|
40
|
-
sac.invoke(jsns_builder.to_update)
|
|
41
|
-
true
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def update!(hash)
|
|
45
|
-
return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?
|
|
46
|
-
|
|
47
|
-
do_update!(hash)
|
|
48
|
-
|
|
49
|
-
hash.each do |key, value|
|
|
50
|
-
update_attribute(key, value)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
true
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def rename!(new_name)
|
|
57
|
-
sac.invoke(jsns_builder.to_rename(new_name))
|
|
58
|
-
@name = new_name
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def delete!
|
|
62
|
-
sac.invoke(jsns_builder.to_delete)
|
|
63
|
-
@id = nil
|
|
64
|
-
end
|
|
65
|
-
|
|
66
50
|
def local_transport
|
|
67
51
|
raise Zm::Client::ZmError, 'zimbraMailHost is null' if zimbraMailHost.nil?
|
|
68
52
|
|
|
@@ -74,13 +58,13 @@ module Zm
|
|
|
74
58
|
end
|
|
75
59
|
|
|
76
60
|
def local_transport?
|
|
77
|
-
return
|
|
61
|
+
return false unless zimbraMailTransport
|
|
78
62
|
|
|
79
63
|
zimbraMailTransport.start_with?(SoapConstants::LMTP)
|
|
80
64
|
end
|
|
81
65
|
|
|
82
66
|
def external_transport?
|
|
83
|
-
return
|
|
67
|
+
return false unless zimbraMailTransport
|
|
84
68
|
|
|
85
69
|
zimbraMailTransport.start_with?(SoapConstants::SMTP)
|
|
86
70
|
end
|
|
@@ -101,14 +85,10 @@ module Zm
|
|
|
101
85
|
@parent.zimbra_attributes.all_distributionlist_attrs_writable_names
|
|
102
86
|
end
|
|
103
87
|
|
|
104
|
-
private
|
|
105
|
-
|
|
106
|
-
def do_update!(hash)
|
|
107
|
-
sac.invoke(jsns_builder.to_patch(hash))
|
|
108
|
-
end
|
|
109
|
-
|
|
110
88
|
def jsns_builder
|
|
111
|
-
@jsns_builder
|
|
89
|
+
return @jsns_builder if defined? @jsns_builder
|
|
90
|
+
|
|
91
|
+
@jsns_builder = DistributionListJsnsBuilder.new(self)
|
|
112
92
|
end
|
|
113
93
|
end
|
|
114
94
|
end
|
|
@@ -15,25 +15,33 @@ module Zm
|
|
|
15
15
|
def add!(email)
|
|
16
16
|
return false if @all.include?(Utils.format_email(email))
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
soap_request.add_attributes({ id: @parent.id, alias: email })
|
|
20
|
-
@parent.sac.invoke(soap_request)
|
|
18
|
+
@parent.sac.invoke(build_add(email))
|
|
21
19
|
|
|
22
20
|
@all.push(email)
|
|
23
21
|
true
|
|
24
22
|
end
|
|
25
23
|
|
|
24
|
+
def build_add(email)
|
|
25
|
+
soap_request = SoapElement.admin(SoapAdminConstants::ADD_DISTRIBUTION_LIST_ALIAS_REQUEST)
|
|
26
|
+
soap_request.add_attributes({ id: @parent.id, alias: email })
|
|
27
|
+
soap_request
|
|
28
|
+
end
|
|
29
|
+
|
|
26
30
|
def remove!(email)
|
|
27
31
|
return false unless @all.include?(Utils.format_email(email))
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
soap_request.add_attributes({ id: @parent.id, alias: email })
|
|
31
|
-
@parent.sac.invoke(soap_request)
|
|
33
|
+
@parent.sac.invoke(build_remove(email))
|
|
32
34
|
|
|
33
35
|
@all.delete(email)
|
|
34
36
|
true
|
|
35
37
|
end
|
|
36
38
|
|
|
39
|
+
def build_remove(email)
|
|
40
|
+
soap_request = SoapElement.admin(SoapAdminConstants::REMOVE_DISTRIBUTION_LIST_ALIAS_REQUEST)
|
|
41
|
+
soap_request.add_attributes({ id: @parent.id, alias: email })
|
|
42
|
+
soap_request
|
|
43
|
+
end
|
|
44
|
+
|
|
37
45
|
private
|
|
38
46
|
|
|
39
47
|
def build_aliases
|
|
@@ -9,13 +9,14 @@ module Zm
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def to_create
|
|
12
|
-
soap_request = SoapElement.admin(SoapAdminConstants::CREATE_DISTRIBUTION_LIST_REQUEST)
|
|
13
|
-
|
|
14
|
-
)
|
|
12
|
+
soap_request = SoapElement.admin(SoapAdminConstants::CREATE_DISTRIBUTION_LIST_REQUEST)
|
|
13
|
+
.add_attribute(SoapConstants::NAME, @item.name)
|
|
15
14
|
|
|
16
15
|
attrs_only_set_h.each do |key, values|
|
|
17
16
|
values.each do |value|
|
|
18
|
-
node_attr = SoapElement.create(SoapConstants::A)
|
|
17
|
+
node_attr = SoapElement.create(SoapConstants::A)
|
|
18
|
+
.add_attribute(SoapConstants::N, key)
|
|
19
|
+
.add_content(value)
|
|
19
20
|
soap_request.add_node(node_attr)
|
|
20
21
|
end
|
|
21
22
|
end
|
|
@@ -24,13 +25,14 @@ module Zm
|
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
def to_update
|
|
27
|
-
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DISTRIBUTION_LIST_REQUEST)
|
|
28
|
-
|
|
29
|
-
)
|
|
28
|
+
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DISTRIBUTION_LIST_REQUEST)
|
|
29
|
+
.add_attribute(SoapConstants::ID, @item.id)
|
|
30
30
|
|
|
31
31
|
attrs_only_set_h.each do |key, values|
|
|
32
32
|
values.each do |value|
|
|
33
|
-
node_attr = SoapElement.create(SoapConstants::A)
|
|
33
|
+
node_attr = SoapElement.create(SoapConstants::A)
|
|
34
|
+
.add_attribute(SoapConstants::N, key)
|
|
35
|
+
.add_content(value)
|
|
34
36
|
soap_request.add_node(node_attr)
|
|
35
37
|
end
|
|
36
38
|
end
|
|
@@ -39,14 +41,15 @@ module Zm
|
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
def to_patch(hash)
|
|
42
|
-
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DISTRIBUTION_LIST_REQUEST)
|
|
43
|
-
|
|
44
|
-
)
|
|
44
|
+
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DISTRIBUTION_LIST_REQUEST)
|
|
45
|
+
.add_attribute(SoapConstants::ID, @item.id)
|
|
45
46
|
|
|
46
47
|
hash.each do |key, values|
|
|
47
48
|
values = [values] unless values.is_a?(Array)
|
|
48
49
|
values.each do |value|
|
|
49
|
-
node_attr = SoapElement.create(SoapConstants::A)
|
|
50
|
+
node_attr = SoapElement.create(SoapConstants::A)
|
|
51
|
+
.add_attribute(SoapConstants::N, key)
|
|
52
|
+
.add_content(value)
|
|
50
53
|
soap_request.add_node(node_attr)
|
|
51
54
|
end
|
|
52
55
|
end
|
|
@@ -55,12 +58,13 @@ module Zm
|
|
|
55
58
|
end
|
|
56
59
|
|
|
57
60
|
def to_delete
|
|
58
|
-
SoapElement.admin(SoapAdminConstants::DELETE_DISTRIBUTION_LIST_REQUEST)
|
|
59
|
-
|
|
61
|
+
SoapElement.admin(SoapAdminConstants::DELETE_DISTRIBUTION_LIST_REQUEST)
|
|
62
|
+
.add_attribute(SoapConstants::ID, @item.id)
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
def to_rename(new_name)
|
|
63
|
-
SoapElement.admin(SoapAdminConstants::RENAME_DISTRIBUTION_LIST_REQUEST)
|
|
66
|
+
SoapElement.admin(SoapAdminConstants::RENAME_DISTRIBUTION_LIST_REQUEST)
|
|
67
|
+
.add_attributes({ id: @item.id, newName: new_name })
|
|
64
68
|
end
|
|
65
69
|
|
|
66
70
|
def attrs_only_set_h
|
|
@@ -74,7 +78,7 @@ module Zm
|
|
|
74
78
|
[n, values]
|
|
75
79
|
end
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
arr.to_h
|
|
78
82
|
end
|
|
79
83
|
end
|
|
80
84
|
end
|
|
@@ -5,19 +5,10 @@ module Zm
|
|
|
5
5
|
# class for initialize distribution list
|
|
6
6
|
class DistributionListJsnsInitializer < Base::BaseJsnsInitializer
|
|
7
7
|
class << self
|
|
8
|
-
def
|
|
9
|
-
item = DistributionList.new(parent)
|
|
10
|
-
|
|
11
|
-
update(item, json)
|
|
12
|
-
end
|
|
8
|
+
def klass = DistributionList
|
|
13
9
|
|
|
14
10
|
def update(item, json)
|
|
15
|
-
|
|
16
|
-
item.name = json[:name]
|
|
17
|
-
|
|
18
|
-
formatted_json(json).each do |k, v|
|
|
19
|
-
valorise(item, k, v)
|
|
20
|
-
end
|
|
11
|
+
super
|
|
21
12
|
|
|
22
13
|
unless item.zimbraMailForwardingAddress.is_a?(Array)
|
|
23
14
|
item.zimbraMailForwardingAddress = [item.zimbraMailForwardingAddress]
|
|
@@ -16,32 +16,40 @@ module Zm
|
|
|
16
16
|
emails.delete_if { |email| @all.include?(email) }
|
|
17
17
|
return false if emails.empty?
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
soap_request.add_attribute('id', @parent.id)
|
|
21
|
-
node_dlm = SoapElement.create('dlm')
|
|
22
|
-
node_dlm.add_content(emails)
|
|
23
|
-
soap_request.add_node(node_dlm)
|
|
24
|
-
@parent.sac.invoke(soap_request)
|
|
19
|
+
@parent.sac.invoke(build_add(emails))
|
|
25
20
|
|
|
26
21
|
@all += emails
|
|
27
22
|
true
|
|
28
23
|
end
|
|
29
24
|
|
|
25
|
+
def build_add(emails)
|
|
26
|
+
soap_request = SoapElement.admin(SoapAdminConstants::ADD_DISTRIBUTION_LIST_MEMBER_REQUEST)
|
|
27
|
+
soap_request.add_attribute(SoapConstants::ID, @parent.id)
|
|
28
|
+
node_dlm = SoapElement.create(SoapConstants::DLM)
|
|
29
|
+
node_dlm.add_content(emails)
|
|
30
|
+
soap_request.add_node(node_dlm)
|
|
31
|
+
soap_request
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
def remove!(emails)
|
|
31
35
|
emails.each { |email| Utils.format_email(email) }
|
|
32
36
|
emails.delete_if { |email| !@all.include?(email) }
|
|
33
37
|
return false if emails.empty?
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
soap_request.add_attribute('id', @parent.id)
|
|
37
|
-
node_dlm = SoapElement.create('dlm')
|
|
38
|
-
node_dlm.add_content(emails)
|
|
39
|
-
soap_request.add_node(node_dlm)
|
|
40
|
-
@parent.sac.invoke(soap_request)
|
|
39
|
+
@parent.sac.invoke(build_remove(emails))
|
|
41
40
|
|
|
42
41
|
@all -= emails
|
|
43
42
|
true
|
|
44
43
|
end
|
|
44
|
+
|
|
45
|
+
def build_remove(emails)
|
|
46
|
+
soap_request = SoapElement.admin(SoapAdminConstants::REMOVE_DISTRIBUTION_LIST_MEMBER_REQUEST)
|
|
47
|
+
soap_request.add_attribute(SoapConstants::ID, @parent.id)
|
|
48
|
+
node_dlm = SoapElement.create(SoapConstants::DLM)
|
|
49
|
+
node_dlm.add_content(emails)
|
|
50
|
+
soap_request.add_node(node_dlm)
|
|
51
|
+
soap_request
|
|
52
|
+
end
|
|
45
53
|
end
|
|
46
54
|
end
|
|
47
55
|
end
|