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
|
@@ -2,70 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
module Base
|
|
6
|
+
class MailboxPrefsCollection
|
|
7
|
+
def initialize(parent)
|
|
8
|
+
@parent = parent
|
|
9
|
+
@preferences = []
|
|
10
|
+
end
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
def all
|
|
13
|
+
build_response
|
|
14
|
+
end
|
|
15
|
+
alias all! all
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
def clear
|
|
18
|
+
reset_query_params
|
|
19
|
+
end
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
def preferences(*entries)
|
|
22
|
+
entries.flatten!
|
|
23
|
+
@preferences += entries
|
|
24
|
+
self
|
|
25
|
+
end
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
def update!(hash)
|
|
28
|
+
# The JSON version is different:
|
|
29
|
+
# {
|
|
30
|
+
# ModifyPrefsRequest: {
|
|
31
|
+
# "_attrs": {
|
|
32
|
+
# "prefName1": "prefValue1",
|
|
33
|
+
# "prefName2": "prefValue2"
|
|
34
|
+
# "+nameOfMulitValuedPref3": "addedPrefValue3",
|
|
35
|
+
# "-nameOfMulitValuedPref4": "removedPrefValue4",
|
|
36
|
+
# "nameOfMulitValuedPref5": ["prefValue5one","prefValue5two"],
|
|
37
|
+
# ...
|
|
38
|
+
# },
|
|
39
|
+
# _jsns: "urn:zimbraAccount"
|
|
40
|
+
# }
|
|
41
|
+
# }
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
req = {
|
|
44
|
+
_attrs: hash
|
|
45
|
+
}
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
soap_request = SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::MODIFY_PREFS_REQUEST).add_attributes(req)
|
|
48
|
+
@parent.soap_connector.invoke(soap_request)
|
|
49
|
+
end
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
private
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
def build_response
|
|
54
|
+
make_query.dig(:GetPrefsResponse, :_attrs)
|
|
55
|
+
end
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
def make_query
|
|
58
|
+
soap_request = SoapRequest::SoapElement.account(Zm::SoapRequest::SoapAccountConstants::GET_PREFS_REQUEST).add_attributes(jsns)
|
|
59
|
+
@parent.soap_connector.invoke(soap_request)
|
|
60
|
+
end
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
def jsns
|
|
63
|
+
return nil if @preferences.empty?
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
{ prefs: @preferences.map { |name| { name: } } }
|
|
66
|
+
end
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
def reset_query_params
|
|
69
|
+
@preferences.clear
|
|
70
|
+
end
|
|
69
71
|
end
|
|
70
72
|
end
|
|
71
73
|
end
|
|
@@ -5,10 +5,11 @@ module Zm
|
|
|
5
5
|
module Base
|
|
6
6
|
# Abstract Class Provisionning Object
|
|
7
7
|
class Object
|
|
8
|
-
attr_accessor :parent, :token, :name, :id
|
|
8
|
+
attr_accessor :parent, :token, :name, :id, :updated
|
|
9
9
|
|
|
10
10
|
def initialize(parent)
|
|
11
11
|
@parent = parent
|
|
12
|
+
@updated = false
|
|
12
13
|
yield(self) if block_given?
|
|
13
14
|
end
|
|
14
15
|
|
|
@@ -16,13 +17,19 @@ module Zm
|
|
|
16
17
|
!@id.nil?
|
|
17
18
|
end
|
|
18
19
|
|
|
20
|
+
def updated?
|
|
21
|
+
@updated
|
|
22
|
+
end
|
|
23
|
+
|
|
19
24
|
def save!
|
|
20
25
|
recorded? ? modify! : create!
|
|
21
26
|
end
|
|
22
27
|
|
|
23
28
|
def clone
|
|
24
29
|
obj = super
|
|
25
|
-
obj.remove_instance_variable(:@id)
|
|
30
|
+
obj.remove_instance_variable(:@id) if obj.instance_variable_defined?(:@id)
|
|
31
|
+
obj.remove_instance_variable(:@jsns_builder) if obj.instance_variable_defined?(:@jsns_builder)
|
|
32
|
+
obj.remove_dependents_of(self)
|
|
26
33
|
yield(obj) if block_given?
|
|
27
34
|
obj
|
|
28
35
|
end
|
|
@@ -59,6 +66,16 @@ module Zm
|
|
|
59
66
|
keys.delete(:@parent)
|
|
60
67
|
keys.map { |key| [key, instance_variable_get(key)] }
|
|
61
68
|
end
|
|
69
|
+
|
|
70
|
+
protected
|
|
71
|
+
|
|
72
|
+
def remove_dependents_of(item)
|
|
73
|
+
instance_variables.each do |key|
|
|
74
|
+
next if key == :@parent
|
|
75
|
+
|
|
76
|
+
remove_instance_variable(key) if instance_variable_get(key).instance_variable_get(:@parent).equal?(item)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
62
79
|
end
|
|
63
80
|
end
|
|
64
81
|
end
|
|
@@ -5,7 +5,7 @@ module Zm
|
|
|
5
5
|
module Base
|
|
6
6
|
# Abstract Class Collection
|
|
7
7
|
class ObjectsCollection
|
|
8
|
-
include Zm::Inspector
|
|
8
|
+
include Zm::Utils::Inspector
|
|
9
9
|
|
|
10
10
|
METHODS_MISSING_LIST = %i[select each map length].to_set.freeze
|
|
11
11
|
attr_reader :parent
|
|
@@ -17,7 +17,7 @@ module Zm
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def find(id)
|
|
20
|
-
find_by(id:
|
|
20
|
+
find_by(id:)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def first
|
|
@@ -46,7 +46,7 @@ module Zm
|
|
|
46
46
|
end
|
|
47
47
|
alias offset page
|
|
48
48
|
|
|
49
|
-
def order(sort_by, sort_ascending =
|
|
49
|
+
def order(sort_by, sort_ascending = Zm::Utils::SearchUtils::ON)
|
|
50
50
|
return self if @sort_by == sort_by && @sort_ascending == sort_ascending
|
|
51
51
|
|
|
52
52
|
@sort_by = sort_by
|
|
@@ -88,19 +88,19 @@ module Zm
|
|
|
88
88
|
# @attrs.compact!
|
|
89
89
|
return nil if @attrs.empty?
|
|
90
90
|
|
|
91
|
-
@attrs.join(
|
|
91
|
+
@attrs.join(',')
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def reset_query_params
|
|
95
|
-
@max_result =
|
|
95
|
+
@max_result = Zm::Utils::SearchUtils::MAX_RESULT
|
|
96
96
|
@limit = nil
|
|
97
97
|
@offset = nil
|
|
98
98
|
@sort_by = nil
|
|
99
|
-
@sort_ascending =
|
|
100
|
-
@count_only =
|
|
101
|
-
@all_servers =
|
|
102
|
-
@refresh =
|
|
103
|
-
@apply_cos =
|
|
99
|
+
@sort_ascending = Zm::Utils::SearchUtils::ON
|
|
100
|
+
@count_only = Zm::Utils::SearchUtils::OFF
|
|
101
|
+
@all_servers = Zm::Utils::SearchUtils::OFF
|
|
102
|
+
@refresh = Zm::Utils::SearchUtils::OFF
|
|
103
|
+
@apply_cos = Zm::Utils::SearchUtils::ON
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
end
|
|
@@ -4,119 +4,105 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
module Base
|
|
6
6
|
class ZimbraAttribute
|
|
7
|
-
attr_reader :name, :
|
|
8
|
-
:min, :since
|
|
7
|
+
attr_reader :name, :type, :objects_scope
|
|
9
8
|
|
|
10
|
-
def initialize(name: nil, optionalIn: nil,
|
|
11
|
-
immutable: nil, type: nil, value: nil, max: nil, min: nil, since: nil)
|
|
9
|
+
def initialize(name: nil, optionalIn: nil, requiredIn: nil, immutable: nil, type: nil, **)
|
|
12
10
|
@name = name
|
|
13
|
-
@
|
|
14
|
-
@
|
|
15
|
-
@
|
|
16
|
-
@cardinality = cardinality
|
|
17
|
-
@callback = callback
|
|
18
|
-
@immutable = immutable
|
|
19
|
-
@type = type
|
|
20
|
-
@value = value
|
|
21
|
-
@max = max
|
|
22
|
-
@min = min
|
|
23
|
-
@since = since
|
|
11
|
+
@type = type && -type
|
|
12
|
+
@immutable = immutable == '1'
|
|
13
|
+
@objects_scope = (optionalIn.to_s.split(',') + requiredIn.to_s.split(',')).map!(&:-@).freeze
|
|
24
14
|
end
|
|
25
15
|
|
|
26
16
|
def immutable?
|
|
27
|
-
immutable
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def objects_scope
|
|
31
|
-
@objects_scope ||= (optionalIn + requiredIn).freeze
|
|
17
|
+
@immutable
|
|
32
18
|
end
|
|
33
19
|
|
|
34
20
|
def is_account_scoped?
|
|
35
|
-
|
|
21
|
+
objects_scope.include?('account')
|
|
36
22
|
end
|
|
37
23
|
|
|
38
24
|
def is_aclTarget_scoped?
|
|
39
|
-
|
|
25
|
+
objects_scope.include?('aclTarget')
|
|
40
26
|
end
|
|
41
27
|
|
|
42
28
|
def is_alias_scoped?
|
|
43
|
-
|
|
29
|
+
objects_scope.include?('alias')
|
|
44
30
|
end
|
|
45
31
|
|
|
46
32
|
def is_alwaysOnCluster_scoped?
|
|
47
|
-
|
|
33
|
+
objects_scope.include?('alwaysOnCluster')
|
|
48
34
|
end
|
|
49
35
|
|
|
50
36
|
def is_calendarResource_scoped?
|
|
51
|
-
|
|
37
|
+
objects_scope.include?('calendarResource') || objects_scope.include?('account')
|
|
52
38
|
end
|
|
53
39
|
|
|
54
40
|
def is_cos_scoped?
|
|
55
|
-
|
|
41
|
+
objects_scope.include?('cos')
|
|
56
42
|
end
|
|
57
43
|
|
|
58
44
|
def is_dataSource_scoped?
|
|
59
|
-
|
|
45
|
+
objects_scope.include?('dataSource')
|
|
60
46
|
end
|
|
61
47
|
|
|
62
48
|
def is_distributionList_scoped?
|
|
63
|
-
|
|
49
|
+
objects_scope.include?('distributionList')
|
|
64
50
|
end
|
|
65
51
|
|
|
66
52
|
def is_domain_scoped?
|
|
67
|
-
|
|
53
|
+
objects_scope.include?('domain')
|
|
68
54
|
end
|
|
69
55
|
|
|
70
56
|
def is_globalConfig_scoped?
|
|
71
|
-
|
|
57
|
+
objects_scope.include?('globalConfig')
|
|
72
58
|
end
|
|
73
59
|
|
|
74
60
|
def is_group_scoped?
|
|
75
|
-
|
|
61
|
+
objects_scope.include?('group')
|
|
76
62
|
end
|
|
77
63
|
|
|
78
64
|
def is_groupDynamicUnit_scoped?
|
|
79
|
-
|
|
65
|
+
objects_scope.include?('groupDynamicUnit')
|
|
80
66
|
end
|
|
81
67
|
|
|
82
68
|
def is_groupStaticUnit_scoped?
|
|
83
|
-
|
|
69
|
+
objects_scope.include?('groupStaticUnit')
|
|
84
70
|
end
|
|
85
71
|
|
|
86
72
|
def is_identity_scoped?
|
|
87
|
-
|
|
73
|
+
objects_scope.include?('identity')
|
|
88
74
|
end
|
|
89
75
|
|
|
90
76
|
def is_mailRecipient_scoped?
|
|
91
|
-
|
|
77
|
+
objects_scope.include?('mailRecipient')
|
|
92
78
|
end
|
|
93
79
|
|
|
94
80
|
def is_mimeEntry_scoped?
|
|
95
|
-
|
|
81
|
+
objects_scope.include?('mimeEntry')
|
|
96
82
|
end
|
|
97
83
|
|
|
98
84
|
def is_objectEntry_scoped?
|
|
99
|
-
|
|
85
|
+
objects_scope.include?('objectEntry')
|
|
100
86
|
end
|
|
101
87
|
|
|
102
88
|
def is_server_scoped?
|
|
103
|
-
|
|
89
|
+
objects_scope.include?('server')
|
|
104
90
|
end
|
|
105
91
|
|
|
106
92
|
def is_signature_scoped?
|
|
107
|
-
|
|
93
|
+
objects_scope.include?('signature')
|
|
108
94
|
end
|
|
109
95
|
|
|
110
96
|
def is_ucService_scoped?
|
|
111
|
-
|
|
97
|
+
objects_scope.include?('ucService')
|
|
112
98
|
end
|
|
113
99
|
|
|
114
100
|
def is_xmppComponent_scoped?
|
|
115
|
-
|
|
101
|
+
objects_scope.include?('xmppComponent')
|
|
116
102
|
end
|
|
117
103
|
|
|
118
104
|
def is_zimletEntry_scoped?
|
|
119
|
-
|
|
105
|
+
objects_scope.include?('zimletEntry')
|
|
120
106
|
end
|
|
121
107
|
end
|
|
122
108
|
end
|
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'zm/client/base/zimbra_attribute'
|
|
4
3
|
require 'csv'
|
|
5
4
|
|
|
6
5
|
module Zm
|
|
7
6
|
module Client
|
|
8
7
|
module Base
|
|
9
8
|
class ZimbraAttributesCollection
|
|
10
|
-
include MissingMethodStaticCollection
|
|
9
|
+
include Zm::Utils::MissingMethodStaticCollection
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
MUTEX = Mutex.new
|
|
12
|
+
CSV_OPTIONS = {
|
|
13
|
+
headers: true, skip_blanks: true, strip: true, header_converters: ->(header) { header.to_sym }
|
|
14
|
+
}.freeze
|
|
15
|
+
|
|
16
|
+
class << self
|
|
17
|
+
def shared(parent)
|
|
18
|
+
path = File.expand_path(parent.config.zimbra_attributes_path)
|
|
19
|
+
MUTEX.synchronize { shared_instances[path] ||= new(parent).tap(&:set_methods) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def load_attributes(path)
|
|
23
|
+
CSV.open(path, **CSV_OPTIONS).map do |attr|
|
|
24
|
+
attr_h = attr.to_h
|
|
25
|
+
attr_h.compact!
|
|
26
|
+
ZimbraAttribute.new(**attr_h)
|
|
27
|
+
end.freeze
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def shared_instances
|
|
33
|
+
@shared_instances ||= {}
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
attr_reader :path
|
|
13
38
|
|
|
14
39
|
def initialize(parent)
|
|
15
|
-
@
|
|
16
|
-
|
|
17
|
-
@all = CSV.open(
|
|
18
|
-
File.expand_path(@parent.config.zimbra_attributes_path),
|
|
19
|
-
headers: true,
|
|
20
|
-
skip_blanks: true,
|
|
21
|
-
strip: true,
|
|
22
|
-
header_converters: lambda { |header| header.to_sym }
|
|
23
|
-
).map do |attr|
|
|
24
|
-
attr_h = attr.to_h
|
|
25
|
-
attr_h.compact!
|
|
26
|
-
ZimbraAttribute.new(**attr_h)
|
|
27
|
-
end.freeze
|
|
40
|
+
@path = File.expand_path(parent.config.zimbra_attributes_path)
|
|
41
|
+
@all = self.class.load_attributes(@path)
|
|
28
42
|
end
|
|
29
43
|
|
|
30
44
|
def set_methods
|
|
@@ -53,7 +67,7 @@ module Zm
|
|
|
53
67
|
end
|
|
54
68
|
|
|
55
69
|
def all_cos_attr_types_h
|
|
56
|
-
@all_cos_attr_types_h ||= all_cos_attrs.
|
|
70
|
+
@all_cos_attr_types_h ||= all_cos_attrs.to_h { |attr| [attr.name, attr.type] }.freeze
|
|
57
71
|
end
|
|
58
72
|
|
|
59
73
|
def set_cos_methods
|
|
@@ -77,7 +91,7 @@ module Zm
|
|
|
77
91
|
end
|
|
78
92
|
|
|
79
93
|
def all_server_attr_types_h
|
|
80
|
-
@all_server_attr_types_h ||= all_server_attrs.
|
|
94
|
+
@all_server_attr_types_h ||= all_server_attrs.to_h { |attr| [attr.name, attr.type] }.freeze
|
|
81
95
|
end
|
|
82
96
|
|
|
83
97
|
def set_server_methods
|
|
@@ -101,7 +115,7 @@ module Zm
|
|
|
101
115
|
end
|
|
102
116
|
|
|
103
117
|
def all_domain_attr_types_h
|
|
104
|
-
@all_domain_attr_types_h ||= all_domain_attrs.
|
|
118
|
+
@all_domain_attr_types_h ||= all_domain_attrs.to_h { |attr| [attr.name, attr.type] }.freeze
|
|
105
119
|
end
|
|
106
120
|
|
|
107
121
|
def set_domain_methods
|
|
@@ -125,7 +139,7 @@ module Zm
|
|
|
125
139
|
end
|
|
126
140
|
|
|
127
141
|
def all_account_attr_types_h
|
|
128
|
-
@all_account_attr_types_h ||= all_account_attrs.
|
|
142
|
+
@all_account_attr_types_h ||= all_account_attrs.to_h { |attr| [attr.name, attr.type] }.freeze
|
|
129
143
|
end
|
|
130
144
|
|
|
131
145
|
def set_account_methods
|
|
@@ -151,9 +165,9 @@ module Zm
|
|
|
151
165
|
end
|
|
152
166
|
|
|
153
167
|
def all_distributionlist_attrs_types_h
|
|
154
|
-
@all_distributionlist_attrs_types_h ||= all_distributionlist_attrs.
|
|
155
|
-
|
|
156
|
-
|
|
168
|
+
@all_distributionlist_attrs_types_h ||= all_distributionlist_attrs.to_h do |attr|
|
|
169
|
+
[attr.name, attr.type]
|
|
170
|
+
end.freeze
|
|
157
171
|
end
|
|
158
172
|
|
|
159
173
|
def set_distributionlist_methods
|
|
@@ -177,7 +191,7 @@ module Zm
|
|
|
177
191
|
end
|
|
178
192
|
|
|
179
193
|
def all_resource_attrs_types_h
|
|
180
|
-
@all_resource_attrs_types_h ||= all_resource_attrs.
|
|
194
|
+
@all_resource_attrs_types_h ||= all_resource_attrs.to_h { |attr| [attr.name, attr.type] }.freeze
|
|
181
195
|
end
|
|
182
196
|
|
|
183
197
|
def set_resource_methods
|
|
@@ -25,7 +25,7 @@ module Zm
|
|
|
25
25
|
private
|
|
26
26
|
|
|
27
27
|
def build(onerror)
|
|
28
|
-
soap_request = SoapElement.new(SoapConstants::BATCH_REQUEST, SoapConstants::NAMESPACE_STR)
|
|
28
|
+
soap_request = SoapRequest::SoapElement.new(SoapRequest::SoapConstants::BATCH_REQUEST, SoapRequest::SoapConstants::NAMESPACE_STR)
|
|
29
29
|
soap_request.add_attribute(:onerror, onerror)
|
|
30
30
|
|
|
31
31
|
@requests.each_with_index do |request, index|
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'zm/client/connector/soap_admin'
|
|
4
|
-
require 'zm/client/connector/soap_account'
|
|
5
|
-
require 'zm/client/common'
|
|
6
|
-
require 'zm/client/account'
|
|
7
|
-
require 'zm/client/resource'
|
|
8
|
-
require 'zm/client/distributionlist'
|
|
9
|
-
require 'zm/client/domain'
|
|
10
|
-
require 'zm/client/server'
|
|
11
|
-
require 'zm/client/cos'
|
|
12
|
-
require 'zm/client/license'
|
|
13
|
-
require 'zm/client/cluster/batch_request'
|
|
14
|
-
|
|
15
3
|
module Zm
|
|
16
4
|
module Client
|
|
17
5
|
# class admin connection
|
|
18
6
|
class Cluster
|
|
7
|
+
extend Zm::Relationship
|
|
8
|
+
|
|
9
|
+
COUNT_OBJECT_TYPES = %i[userAccount account alias dl domain cos server calresource internalUserAccount].freeze
|
|
10
|
+
|
|
19
11
|
attr_reader :soap_admin_connector, :config, :zimbra_attributes, :type, :version, :release, :buildDate, :host,
|
|
20
12
|
:majorversion, :minorversion, :microversion
|
|
21
13
|
|
|
@@ -23,10 +15,9 @@ module Zm
|
|
|
23
15
|
@config = config
|
|
24
16
|
@version = config.zimbra_version
|
|
25
17
|
|
|
26
|
-
@zimbra_attributes = Base::ZimbraAttributesCollection.
|
|
27
|
-
@zimbra_attributes.set_methods
|
|
18
|
+
@zimbra_attributes = Base::ZimbraAttributesCollection.shared(self)
|
|
28
19
|
|
|
29
|
-
@soap_admin_connector = SoapAdminConnector.create(@config)
|
|
20
|
+
@soap_admin_connector = Zm::Connector::SoapAdminConnector.create(@config)
|
|
30
21
|
end
|
|
31
22
|
|
|
32
23
|
def has_admin_credentials?
|
|
@@ -50,9 +41,9 @@ module Zm
|
|
|
50
41
|
|
|
51
42
|
@soap_admin_connector.token = nil if logged?
|
|
52
43
|
|
|
53
|
-
soap_request = SoapElement.admin(SoapAdminConstants::AUTH_REQUEST)
|
|
44
|
+
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::AUTH_REQUEST)
|
|
54
45
|
soap_request.add_attributes(name: @config.zimbra_admin_login, password: @config.zimbra_admin_password)
|
|
55
|
-
soap_resp = @soap_admin_connector.invoke(soap_request, Zm::
|
|
46
|
+
soap_resp = @soap_admin_connector.invoke(soap_request, Zm::Error::AuthError)
|
|
56
47
|
soap_resp_token = soap_resp[:AuthResponse][:authToken].first[:_content]
|
|
57
48
|
self.token = soap_resp_token
|
|
58
49
|
end
|
|
@@ -62,10 +53,10 @@ module Zm
|
|
|
62
53
|
end
|
|
63
54
|
|
|
64
55
|
def alive?
|
|
65
|
-
soap_request = SoapElement.admin(SoapAdminConstants::NO_OP_REQUEST)
|
|
56
|
+
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::NO_OP_REQUEST)
|
|
66
57
|
@soap_admin_connector.invoke(soap_request)
|
|
67
58
|
true
|
|
68
|
-
rescue Zm::
|
|
59
|
+
rescue Zm::Error::SoapError => e
|
|
69
60
|
logger.error "Admin session token alive ? #{e.message}"
|
|
70
61
|
false
|
|
71
62
|
end
|
|
@@ -78,48 +69,19 @@ module Zm
|
|
|
78
69
|
return @license if defined? @license
|
|
79
70
|
|
|
80
71
|
@license = LicensesCollection.new(self).find
|
|
81
|
-
rescue Zm::
|
|
72
|
+
rescue Zm::Error::SoapError => e
|
|
82
73
|
logger.error "Get License info #{e.message}"
|
|
83
74
|
nil
|
|
84
75
|
end
|
|
85
76
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def accounts
|
|
93
|
-
return @accounts if defined? @accounts
|
|
94
|
-
|
|
95
|
-
@accounts = AccountsCollection.new self
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def resources
|
|
99
|
-
return @resources if defined? @resources
|
|
100
|
-
|
|
101
|
-
@resources = ResourcesCollection.new self
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def servers
|
|
105
|
-
return @servers if defined? @servers
|
|
106
|
-
|
|
107
|
-
@servers = ServersCollection.new self
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def coses
|
|
111
|
-
return @coses if defined? @coses
|
|
112
|
-
|
|
113
|
-
@coses = CosesCollection.new self
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def distributionlists
|
|
117
|
-
return @distributionlists if defined? @distributionlists
|
|
118
|
-
|
|
119
|
-
@distributionlists = DistributionListsCollection.new self
|
|
120
|
-
end
|
|
77
|
+
has_many :domains
|
|
78
|
+
has_many :accounts
|
|
79
|
+
has_many :resources
|
|
80
|
+
has_many :servers
|
|
81
|
+
has_many :coses
|
|
82
|
+
has_many :distribution_lists
|
|
121
83
|
|
|
122
|
-
alias distribution_lists
|
|
84
|
+
alias distributionlists distribution_lists
|
|
123
85
|
|
|
124
86
|
def domain_key(domain_name)
|
|
125
87
|
if logged?
|
|
@@ -130,9 +92,10 @@ module Zm
|
|
|
130
92
|
end
|
|
131
93
|
|
|
132
94
|
def count_object(type)
|
|
133
|
-
|
|
95
|
+
type = type.to_sym if type.is_a?(String)
|
|
96
|
+
raise Zm::Error::ZmError, 'Unknown object type' unless COUNT_OBJECT_TYPES.include?(type)
|
|
134
97
|
|
|
135
|
-
soap_request = SoapElement.admin(SoapAdminConstants::COUNT_OBJECTS_REQUEST)
|
|
98
|
+
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::COUNT_OBJECTS_REQUEST)
|
|
136
99
|
soap_request.add_attribute('type', type)
|
|
137
100
|
soap_resp = @soap_admin_connector.invoke(soap_request)
|
|
138
101
|
soap_resp[:CountObjectsResponse][:num]
|
|
@@ -142,17 +105,17 @@ module Zm
|
|
|
142
105
|
jsns = {
|
|
143
106
|
query: "(mail=#{email})",
|
|
144
107
|
types: 'accounts,distributionlists,aliases,resources',
|
|
145
|
-
countOnly:
|
|
108
|
+
countOnly: Zm::Utils::SearchUtils::ON
|
|
146
109
|
}
|
|
147
110
|
|
|
148
|
-
soap_request = SoapElement.admin(SoapAdminConstants::SEARCH_DIRECTORY_REQUEST)
|
|
111
|
+
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::SEARCH_DIRECTORY_REQUEST)
|
|
149
112
|
soap_request.add_attributes(jsns)
|
|
150
113
|
soap_resp = @soap_admin_connector.invoke(soap_request)
|
|
151
114
|
!soap_resp[:SearchDirectoryResponse][:num].zero?
|
|
152
115
|
end
|
|
153
116
|
|
|
154
117
|
def infos!
|
|
155
|
-
soap_request = SoapElement.admin(SoapAdminConstants::GET_VERSION_INFO_REQUEST)
|
|
118
|
+
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::GET_VERSION_INFO_REQUEST)
|
|
156
119
|
soap_response = @soap_admin_connector.invoke(soap_request)
|
|
157
120
|
|
|
158
121
|
json = soap_response[:GetVersionInfoResponse][:info].first
|