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
|
@@ -17,35 +17,46 @@ module Zm
|
|
|
17
17
|
emails.delete_if { |email| @all.include?(email) }
|
|
18
18
|
return false if emails.empty?
|
|
19
19
|
|
|
20
|
-
@parent.sac.invoke(
|
|
20
|
+
@parent.sac.invoke(build_add(emails))
|
|
21
21
|
|
|
22
22
|
@all += emails
|
|
23
23
|
true
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
def build_add(emails)
|
|
27
|
+
jsns('addOwners', emails)
|
|
28
|
+
end
|
|
29
|
+
|
|
26
30
|
def remove!(*emails)
|
|
27
31
|
emails.flatten!
|
|
28
32
|
emails.each { |email| Utils.format_email(email) }
|
|
29
33
|
emails.delete_if { |email| !@all.include?(email) }
|
|
30
34
|
return false if emails.empty?
|
|
31
35
|
|
|
32
|
-
@parent.sac.invoke(
|
|
36
|
+
@parent.sac.invoke(build_remove(emails))
|
|
33
37
|
|
|
34
38
|
@all -= emails
|
|
35
39
|
true
|
|
36
40
|
end
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
def build_remove(emails)
|
|
43
|
+
jsns('removeOwners', emails)
|
|
44
|
+
end
|
|
39
45
|
|
|
40
46
|
def jsns(op, emails)
|
|
41
47
|
soap_request = SoapElement.account(SoapAccountConstants::DISTRIBUTION_LIST_ACTION_REQUEST)
|
|
42
|
-
node_dl = SoapElement.create(
|
|
48
|
+
node_dl = SoapElement.create(SoapConstants::DL)
|
|
49
|
+
.add_attribute(SoapConstants::BY, SoapConstants::ID)
|
|
50
|
+
.add_content(@parent.id)
|
|
43
51
|
soap_request.add_node(node_dl)
|
|
44
|
-
node_action = SoapElement.create(SoapConstants::ACTION)
|
|
52
|
+
node_action = SoapElement.create(SoapConstants::ACTION)
|
|
53
|
+
.add_attributes({ op: op, owner: jsns_owners(emails) })
|
|
45
54
|
soap_request.add_node(node_action)
|
|
46
55
|
soap_request
|
|
47
56
|
end
|
|
48
57
|
|
|
58
|
+
private
|
|
59
|
+
|
|
49
60
|
def jsns_owners(emails)
|
|
50
61
|
emails.map { |email| { by: :name, type: :usr, _content: email } }
|
|
51
62
|
end
|
|
@@ -8,20 +8,26 @@ module Zm
|
|
|
8
8
|
@child_class = DistributionList
|
|
9
9
|
@builder_class = DistributionListsBuilder
|
|
10
10
|
@search_type = SearchType::DL
|
|
11
|
-
super
|
|
11
|
+
super
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def find_by!(hash)
|
|
15
|
-
|
|
16
|
-
node_dl = SoapElement.create(SoapConstants::DL).add_attribute(SoapConstants::BY, hash.keys.first).add_content(hash.values.first)
|
|
17
|
-
soap_request.add_node(node_dl)
|
|
18
|
-
soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma)
|
|
19
|
-
entry = sac.invoke(soap_request)[:GetDistributionListResponse][:dl].first
|
|
15
|
+
entry = sac.invoke(build_find_by(hash))[:GetDistributionListResponse][:dl].first
|
|
20
16
|
|
|
21
17
|
reset_query_params
|
|
22
18
|
DistributionListJsnsInitializer.create(@parent, entry)
|
|
23
19
|
end
|
|
24
20
|
|
|
21
|
+
def build_find_by(hash)
|
|
22
|
+
soap_request = SoapElement.admin(SoapAdminConstants::GET_DISTRIBUTION_LIST_REQUEST)
|
|
23
|
+
node_dl = SoapElement.create(SoapConstants::DL)
|
|
24
|
+
.add_attribute(SoapConstants::BY, hash.keys.first)
|
|
25
|
+
.add_content(hash.values.first)
|
|
26
|
+
soap_request.add_node(node_dl)
|
|
27
|
+
soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma)
|
|
28
|
+
soap_request
|
|
29
|
+
end
|
|
30
|
+
|
|
25
31
|
private
|
|
26
32
|
|
|
27
33
|
def reset_query_params
|
|
@@ -9,18 +9,24 @@ module Zm
|
|
|
9
9
|
@parent = parent
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
private
|
|
13
|
-
|
|
14
12
|
def make_query
|
|
13
|
+
sac.invoke(build_query)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def build_query
|
|
15
17
|
soap_request = SoapElement.admin(SoapAdminConstants::GET_DISTRIBUTION_LIST_MEMBERSHIP_REQUEST)
|
|
16
|
-
node_account = SoapElement.create(SoapConstants::ACCOUNT)
|
|
18
|
+
node_account = SoapElement.create(SoapConstants::ACCOUNT)
|
|
19
|
+
.add_attribute(SoapConstants::BY, SoapConstants::ID)
|
|
20
|
+
.add_content(@parent.id)
|
|
17
21
|
soap_request.add_node(node_account)
|
|
18
|
-
|
|
22
|
+
soap_request
|
|
19
23
|
end
|
|
20
24
|
|
|
25
|
+
private
|
|
26
|
+
|
|
21
27
|
def build_response
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
collection = make_query.dig(:Body, :GetDistributionListMembershipResponse, :dl) || []
|
|
29
|
+
collection.map { |json| DlMembership.new(json[:name], json[:id], json[:via]) }
|
|
24
30
|
end
|
|
25
31
|
end
|
|
26
32
|
end
|
|
@@ -6,6 +6,7 @@ module Zm
|
|
|
6
6
|
class Document < Base::Object
|
|
7
7
|
include BelongsToFolder
|
|
8
8
|
include BelongsToTag
|
|
9
|
+
include RequestMethodsMailbox
|
|
9
10
|
|
|
10
11
|
attr_accessor :id, :uuid, :name, :s, :d, :l, :luuid, :ms, :mdver, :md, :rev, :f, :t, :meta, :ct,
|
|
11
12
|
:descEnabled, :ver, :leb, :cr, :cd, :acl, :loid, :sf, :tn
|
|
@@ -14,10 +15,18 @@ module Zm
|
|
|
14
15
|
raise NotImplementedError
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
def build_create
|
|
19
|
+
raise NotImplementedError
|
|
20
|
+
end
|
|
21
|
+
|
|
17
22
|
def modify!
|
|
18
23
|
raise NotImplementedError
|
|
19
24
|
end
|
|
20
25
|
|
|
26
|
+
def build_modify
|
|
27
|
+
raise NotImplementedError
|
|
28
|
+
end
|
|
29
|
+
|
|
21
30
|
def update!(*args)
|
|
22
31
|
raise NotImplementedError
|
|
23
32
|
end
|
|
@@ -26,11 +35,8 @@ module Zm
|
|
|
26
35
|
raise NotImplementedError
|
|
27
36
|
end
|
|
28
37
|
|
|
29
|
-
def
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@parent.sacc.invoke(jsns_builder.to_delete)
|
|
33
|
-
@id = nil
|
|
38
|
+
def build_rename(*args)
|
|
39
|
+
raise NotImplementedError
|
|
34
40
|
end
|
|
35
41
|
|
|
36
42
|
def reload!
|
|
@@ -38,14 +44,16 @@ module Zm
|
|
|
38
44
|
end
|
|
39
45
|
|
|
40
46
|
def download(dest_file_path)
|
|
41
|
-
uploader =
|
|
42
|
-
uploader.download_file(
|
|
47
|
+
uploader = @parent.build_uploader
|
|
48
|
+
uploader.download_file(dest_file_path, id, nil)
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
private
|
|
46
52
|
|
|
47
53
|
def jsns_builder
|
|
48
|
-
@jsns_builder
|
|
54
|
+
return @jsns_builder if defined? @jsns_builder
|
|
55
|
+
|
|
56
|
+
@jsns_builder = DocumentJsnsBuilder.new(self)
|
|
49
57
|
end
|
|
50
58
|
end
|
|
51
59
|
end
|
|
@@ -6,35 +6,36 @@ module Zm
|
|
|
6
6
|
class DocumentJsnsInitializer
|
|
7
7
|
class << self
|
|
8
8
|
def create(parent, json)
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
Document.new(parent).tap do |item|
|
|
10
|
+
update(item, json)
|
|
11
|
+
end
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def update(item, json)
|
|
14
|
-
item.id = json
|
|
15
|
-
item.uuid = json
|
|
16
|
-
item.name = json
|
|
17
|
-
item.s = json
|
|
18
|
-
item.d = json
|
|
19
|
-
item.l = json
|
|
20
|
-
item.luuid = json
|
|
21
|
-
item.ms = json
|
|
22
|
-
item.mdver = json
|
|
23
|
-
item.md = json
|
|
24
|
-
item.rev = json
|
|
25
|
-
item.f = json
|
|
26
|
-
item.tn = json
|
|
27
|
-
item.t = json
|
|
28
|
-
item.meta = json
|
|
29
|
-
item.ct = json
|
|
30
|
-
item.descEnabled = json
|
|
31
|
-
item.ver = json
|
|
32
|
-
item.leb = json
|
|
33
|
-
item.cr = json
|
|
34
|
-
item.cd = json
|
|
35
|
-
item.acl = json
|
|
36
|
-
item.loid = json
|
|
37
|
-
item.sf = json
|
|
15
|
+
item.id = json.delete(:id)
|
|
16
|
+
item.uuid = json.delete(:uuid)
|
|
17
|
+
item.name = json.delete(:name)
|
|
18
|
+
item.s = json.delete(:s)
|
|
19
|
+
item.d = json.delete(:d)
|
|
20
|
+
item.l = json.delete(:l)
|
|
21
|
+
item.luuid = json.delete(:luuid)
|
|
22
|
+
item.ms = json.delete(:ms)
|
|
23
|
+
item.mdver = json.delete(:mdver)
|
|
24
|
+
item.md = json.delete(:md)
|
|
25
|
+
item.rev = json.delete(:rev)
|
|
26
|
+
item.f = json.delete(:f)
|
|
27
|
+
item.tn = json.delete(:tn)
|
|
28
|
+
item.t = json.delete(:t)
|
|
29
|
+
item.meta = json.delete(:meta)
|
|
30
|
+
item.ct = json.delete(:ct)
|
|
31
|
+
item.descEnabled = json.delete(:descEnabled)
|
|
32
|
+
item.ver = json.delete(:ver)
|
|
33
|
+
item.leb = json.delete(:leb)
|
|
34
|
+
item.cr = json.delete(:cr)
|
|
35
|
+
item.cd = json.delete(:cd)
|
|
36
|
+
item.acl = json.delete(:acl)
|
|
37
|
+
item.loid = json.delete(:loid)
|
|
38
|
+
item.sf = json.delete(:sf)
|
|
38
39
|
|
|
39
40
|
item
|
|
40
41
|
end
|
|
@@ -5,53 +5,38 @@ module Zm
|
|
|
5
5
|
# objectClass: zimbraDomain
|
|
6
6
|
class Domain < Base::Object
|
|
7
7
|
include HasSoapAdminConnector
|
|
8
|
+
include RequestMethodsAdmin
|
|
8
9
|
|
|
9
10
|
def create!
|
|
10
|
-
resp = sac.invoke(
|
|
11
|
+
resp = sac.invoke(build_create)
|
|
11
12
|
@id = resp[:CreateDomainResponse][:domain].first[:id]
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
def modify!
|
|
15
|
-
sac.invoke(jsns_builder.to_update)
|
|
16
|
-
true
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def update!(hash)
|
|
20
|
-
return false if hash.delete_if { |k, v| v.nil? || !respond_to?(k) }.empty?
|
|
21
|
-
|
|
22
|
-
do_update!(hash)
|
|
23
|
-
|
|
24
|
-
hash.each do |key, value|
|
|
25
|
-
update_attribute(key, value)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
true
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def delete!
|
|
32
|
-
soap_request = SoapElement.admin(SoapAdminConstants::DELETE_DOMAIN_REQUEST).add_attribute(SoapConstants::ID,
|
|
33
|
-
@id)
|
|
34
|
-
sac.invoke(soap_request)
|
|
35
|
-
@id = nil
|
|
36
|
-
end
|
|
37
|
-
|
|
38
15
|
def accounts
|
|
39
|
-
@accounts
|
|
16
|
+
return @accounts if defined? @accounts
|
|
17
|
+
|
|
18
|
+
@accounts = DomainAccountsCollection.new(self)
|
|
40
19
|
end
|
|
41
20
|
|
|
42
21
|
def distributionlists
|
|
43
|
-
@distributionlists
|
|
22
|
+
return @distributionlists if defined? @distributionlists
|
|
23
|
+
|
|
24
|
+
@distributionlists = DomainDistributionListsCollection.new(self)
|
|
44
25
|
end
|
|
45
26
|
alias distribution_lists distributionlists
|
|
46
27
|
|
|
47
28
|
def resources
|
|
48
|
-
@resources
|
|
29
|
+
return @resources if defined? @resources
|
|
30
|
+
|
|
31
|
+
@resources = DomainResourcesCollection.new(self)
|
|
49
32
|
end
|
|
50
33
|
|
|
51
34
|
def cos
|
|
52
|
-
return nil if
|
|
35
|
+
return nil if zimbraDomainDefaultCOSId.nil?
|
|
36
|
+
|
|
37
|
+
return @cos if defined? @cos
|
|
53
38
|
|
|
54
|
-
@cos
|
|
39
|
+
@cos = @parent.coses.find_by(id: zimbraDomainDefaultCOSId)
|
|
55
40
|
end
|
|
56
41
|
|
|
57
42
|
def attrs_write
|
|
@@ -74,14 +59,10 @@ module Zm
|
|
|
74
59
|
@DKIMPublicTxt = matches.first.first.strip
|
|
75
60
|
end
|
|
76
61
|
|
|
77
|
-
private
|
|
78
|
-
|
|
79
|
-
def do_update!(hash)
|
|
80
|
-
sac.invoke(jsns_builder.to_patch(hash))
|
|
81
|
-
end
|
|
82
|
-
|
|
83
62
|
def jsns_builder
|
|
84
|
-
@jsns_builder
|
|
63
|
+
return @jsns_builder if defined? @jsns_builder
|
|
64
|
+
|
|
65
|
+
@jsns_builder = DomainJsnsBuilder.new(self)
|
|
85
66
|
end
|
|
86
67
|
end
|
|
87
68
|
end
|
|
@@ -9,12 +9,14 @@ module Zm
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def to_create
|
|
12
|
-
soap_request = SoapElement.admin(SoapAdminConstants::CREATE_DOMAIN_REQUEST)
|
|
13
|
-
|
|
12
|
+
soap_request = SoapElement.admin(SoapAdminConstants::CREATE_DOMAIN_REQUEST)
|
|
13
|
+
.add_attribute(SoapConstants::NAME, @item.name)
|
|
14
14
|
|
|
15
15
|
attrs_only_set_h.each do |key, values|
|
|
16
16
|
values.each do |value|
|
|
17
|
-
node_attr = SoapElement.create(SoapConstants::A)
|
|
17
|
+
node_attr = SoapElement.create(SoapConstants::A)
|
|
18
|
+
.add_attribute(SoapConstants::N, key)
|
|
19
|
+
.add_content(value)
|
|
18
20
|
soap_request.add_node(node_attr)
|
|
19
21
|
end
|
|
20
22
|
end
|
|
@@ -23,8 +25,8 @@ module Zm
|
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def to_update
|
|
26
|
-
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
|
|
27
|
-
|
|
28
|
+
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
|
|
29
|
+
.add_attribute(SoapConstants::ID, @item.id)
|
|
28
30
|
|
|
29
31
|
attrs_only_set_h.each do |key, values|
|
|
30
32
|
values.each do |value|
|
|
@@ -37,13 +39,15 @@ module Zm
|
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
def to_patch(hash)
|
|
40
|
-
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
|
|
41
|
-
|
|
42
|
+
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
|
|
43
|
+
.add_attribute(SoapConstants::ID, @item.id)
|
|
42
44
|
|
|
43
45
|
hash.each do |key, values|
|
|
44
46
|
values = [values] unless values.is_a?(Array)
|
|
45
47
|
values.each do |value|
|
|
46
|
-
node_attr = SoapElement.create(SoapConstants::A)
|
|
48
|
+
node_attr = SoapElement.create(SoapConstants::A)
|
|
49
|
+
.add_attribute(SoapConstants::N, key)
|
|
50
|
+
.add_content(value)
|
|
47
51
|
soap_request.add_node(node_attr)
|
|
48
52
|
end
|
|
49
53
|
end
|
|
@@ -51,6 +55,11 @@ module Zm
|
|
|
51
55
|
soap_request
|
|
52
56
|
end
|
|
53
57
|
|
|
58
|
+
def to_delete
|
|
59
|
+
SoapElement.admin(SoapAdminConstants::DELETE_DOMAIN_REQUEST)
|
|
60
|
+
.add_attribute(SoapConstants::ID, @item.id)
|
|
61
|
+
end
|
|
62
|
+
|
|
54
63
|
def attrs_only_set_h
|
|
55
64
|
selected_attrs = @item.attrs_write.map { |a| Utils.arrow_name_sym(a) }
|
|
56
65
|
attrs_only_set = @item.instance_variables & selected_attrs
|
|
@@ -62,7 +71,7 @@ module Zm
|
|
|
62
71
|
[n, values]
|
|
63
72
|
end
|
|
64
73
|
|
|
65
|
-
|
|
74
|
+
arr.to_h
|
|
66
75
|
end
|
|
67
76
|
end
|
|
68
77
|
end
|
|
@@ -5,14 +5,10 @@ module Zm
|
|
|
5
5
|
# class for initialize domain
|
|
6
6
|
class DomainJsnsInitializer < Base::BaseJsnsInitializer
|
|
7
7
|
class << self
|
|
8
|
-
def
|
|
9
|
-
item = Domain.new(parent)
|
|
10
|
-
|
|
11
|
-
update(item, json)
|
|
12
|
-
end
|
|
8
|
+
def klass = Domain
|
|
13
9
|
|
|
14
10
|
def update(item, json)
|
|
15
|
-
item = super
|
|
11
|
+
item = super
|
|
16
12
|
|
|
17
13
|
item.zimbraGalAccountId = [item.zimbraGalAccountId] if item.zimbraGalAccountId.is_a?(String)
|
|
18
14
|
item.zimbraGalLdapAttrMap = [item.zimbraGalLdapAttrMap] if item.zimbraGalLdapAttrMap.is_a?(String)
|
|
@@ -8,20 +8,26 @@ module Zm
|
|
|
8
8
|
@child_class = Domain
|
|
9
9
|
@builder_class = DomainsBuilder
|
|
10
10
|
@search_type = SearchType::DOMAIN
|
|
11
|
-
super
|
|
11
|
+
super
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def find_by!(hash)
|
|
15
|
-
|
|
16
|
-
node_domain = SoapElement.create(SoapConstants::DOMAIN).add_attribute(SoapConstants::BY, hash.keys.first).add_content(hash.values.first)
|
|
17
|
-
soap_request.add_node(node_domain)
|
|
18
|
-
soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma)
|
|
19
|
-
entry = sac.invoke(soap_request)[:GetDomainResponse][:domain].first
|
|
15
|
+
entry = sac.invoke(build_find_by(hash))[:GetDomainResponse][:domain].first
|
|
20
16
|
|
|
21
17
|
reset_query_params
|
|
22
18
|
DomainJsnsInitializer.create(@parent, entry)
|
|
23
19
|
end
|
|
24
20
|
|
|
21
|
+
def build_find_by(hash)
|
|
22
|
+
soap_request = SoapElement.admin(SoapAdminConstants::GET_DOMAIN_REQUEST)
|
|
23
|
+
node_domain = SoapElement.create(SoapConstants::DOMAIN)
|
|
24
|
+
.add_attribute(SoapConstants::BY, hash.keys.first)
|
|
25
|
+
.add_content(hash.values.first)
|
|
26
|
+
soap_request.add_node(node_domain)
|
|
27
|
+
soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma)
|
|
28
|
+
soap_request
|
|
29
|
+
end
|
|
30
|
+
|
|
25
31
|
private
|
|
26
32
|
|
|
27
33
|
def reset_query_params
|
|
@@ -5,15 +5,6 @@ module Zm
|
|
|
5
5
|
# class account filter rule
|
|
6
6
|
class FilterRule < Base::Object
|
|
7
7
|
attr_accessor :name, :active, :filterTests, :filterActions
|
|
8
|
-
|
|
9
|
-
def to_h
|
|
10
|
-
{
|
|
11
|
-
name: name,
|
|
12
|
-
active: active,
|
|
13
|
-
filterTests: filterTests,
|
|
14
|
-
filterActions: filterActions
|
|
15
|
-
}
|
|
16
|
-
end
|
|
17
8
|
end
|
|
18
9
|
end
|
|
19
10
|
end
|
|
@@ -6,15 +6,16 @@ module Zm
|
|
|
6
6
|
class FilterRuleJsnsInitializer
|
|
7
7
|
class << self
|
|
8
8
|
def create(parent, json)
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
FilterRule.new(parent).tap do |item|
|
|
10
|
+
update(item, json)
|
|
11
|
+
end
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def update(item, json)
|
|
14
|
-
item.name = json
|
|
15
|
-
item.active = json
|
|
16
|
-
item.filterTests = json
|
|
17
|
-
item.filterActions = json
|
|
15
|
+
item.name = json.delete(:name)
|
|
16
|
+
item.active = json.delete(:active)
|
|
17
|
+
item.filterTests = json.delete(:filterTests)
|
|
18
|
+
item.filterActions = json.delete(:filterActions)
|
|
18
19
|
|
|
19
20
|
item
|
|
20
21
|
end
|
|
@@ -7,25 +7,15 @@ module Zm
|
|
|
7
7
|
def initialize(parent)
|
|
8
8
|
@child_class = FilterRule
|
|
9
9
|
@builder_class = FilterRulesBuilder
|
|
10
|
-
super
|
|
10
|
+
super
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
soap_request = SoapElement.mail(SoapMailConstants::MODIFY_FILTER_RULES_REQUEST)
|
|
17
|
-
node_rules = SoapElement.create(:filterRules).add_attribute(:filterRule, @all.map(&:to_h))
|
|
18
|
-
soap_request.add_node(node_rules)
|
|
19
|
-
@parent.sacc.invoke(soap_request)
|
|
20
|
-
|
|
21
|
-
true
|
|
13
|
+
def make_query
|
|
14
|
+
@parent.soap_connector.invoke(build_query)
|
|
22
15
|
end
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def make_query
|
|
27
|
-
soap_request = SoapElement.mail(SoapMailConstants::GET_FILTER_RULES_REQUEST)
|
|
28
|
-
@parent.sacc.invoke(soap_request)
|
|
17
|
+
def build_query
|
|
18
|
+
SoapElement.mail(SoapMailConstants::GET_FILTER_RULES_REQUEST)
|
|
29
19
|
end
|
|
30
20
|
end
|
|
31
21
|
end
|
|
@@ -7,8 +7,11 @@ module Zm
|
|
|
7
7
|
private
|
|
8
8
|
|
|
9
9
|
def make_query
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
@parent.soap_connector.invoke(build_query)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def build_query
|
|
14
|
+
SoapElement.mail(SoapMailConstants::GET_OUTGOING_FILTER_RULES_REQUEST)
|
|
12
15
|
end
|
|
13
16
|
end
|
|
14
17
|
end
|