zm-ruby-client 3.1.1 → 3.2.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 +126 -0
- data/README.md +42 -0
- data/VERSION +1 -1
- data/lib/zm/client/account/account.rb +214 -8
- data/lib/zm/client/account/account_jsns_builder.rb +6 -18
- data/lib/zm/client/account/account_jsns_initializer.rb +1 -1
- data/lib/zm/client/account/accounts_collection.rb +1 -0
- data/lib/zm/client/account/accounts_response.rb +21 -0
- data/lib/zm/client/backup/backups_collection.rb +1 -1
- data/lib/zm/client/backup/backups_response.rb +16 -0
- data/lib/zm/client/base/admin_objects_collection.rb +18 -8
- data/lib/zm/client/base/admin_objects_response.rb +23 -0
- data/lib/zm/client/base/base_jsns_initializer.rb +34 -3
- data/lib/zm/client/base/has_cos.rb +75 -0
- data/lib/zm/client/base/has_zimbra_attributes.rb +133 -0
- data/lib/zm/client/base/object.rb +2 -0
- data/lib/zm/client/base/objects_builder.rb +1 -1
- data/lib/zm/client/base/zimbra_attributes_collection.rb +43 -166
- data/lib/zm/client/base/zimbra_attrs_jsns.rb +44 -0
- data/lib/zm/client/cluster/cluster.rb +16 -9
- data/lib/zm/client/cluster/cluster_config.rb +50 -18
- data/lib/zm/client/contact/contact_jsns_initializer.rb +16 -16
- data/lib/zm/client/contact/contact_members_collection.rb +19 -1
- data/lib/zm/client/cos/cos.rb +183 -11
- data/lib/zm/client/cos/cos_jsns_builder.rb +4 -16
- data/lib/zm/client/cos/cos_jsns_initializer.rb +2 -2
- data/lib/zm/client/cos/coses_collection.rb +1 -0
- data/lib/zm/client/cos/coses_response.rb +27 -0
- data/lib/zm/client/deprecation.rb +24 -0
- data/lib/zm/client/distributionlist/distributionlist.rb +11 -4
- data/lib/zm/client/distributionlist/distributionlist_jsns_builder.rb +4 -16
- data/lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb +1 -2
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +1 -0
- data/lib/zm/client/distributionlist/distributionlists_response.rb +16 -0
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +5 -5
- data/lib/zm/client/domain/domain.rb +51 -10
- data/lib/zm/client/domain/domain_jsns_builder.rb +4 -16
- data/lib/zm/client/domain/domain_jsns_initializer.rb +9 -2
- data/lib/zm/client/domain/domains_collection.rb +1 -0
- data/lib/zm/client/domain/domains_response.rb +23 -0
- data/lib/zm/client/folder/folder.rb +1 -0
- data/lib/zm/client/folder/folder_default.rb +3 -1
- data/lib/zm/client/folder/folder_grants_collection.rb +24 -0
- data/lib/zm/client/folder/folder_jsns_initializer.rb +4 -3
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +8 -0
- data/lib/zm/client/folder/folder_retention_policy.rb +2 -2
- data/lib/zm/client/folder/folder_view_filters.rb +32 -0
- data/lib/zm/client/folder/folders_builder.rb +31 -16
- data/lib/zm/client/folder/folders_collection.rb +21 -13
- data/lib/zm/client/folder/folders_response.rb +14 -0
- data/lib/zm/client/mailbox/mailbox_item_concern.rb +1 -3
- data/lib/zm/client/mailbox/mailbox_item_id.rb +7 -1
- data/lib/zm/client/mountpoint/mount_point.rb +1 -1
- data/lib/zm/client/mountpoint/mount_points_builder.rb +3 -3
- data/lib/zm/client/mountpoint/mount_points_collection.rb +0 -4
- data/lib/zm/client/mountpoint/mount_points_response.rb +10 -0
- data/lib/zm/client/resource/resource.rb +215 -4
- data/lib/zm/client/resource/resource_jsns_builder.rb +4 -16
- data/lib/zm/client/resource/resource_jsns_initializer.rb +1 -1
- data/lib/zm/client/resource/resources_collection.rb +1 -0
- data/lib/zm/client/resource/resources_response.rb +16 -0
- data/lib/zm/client/server/server.rb +28 -2
- data/lib/zm/client/server/servers_collection.rb +1 -0
- data/lib/zm/client/server/servers_response.rb +43 -0
- data/lib/zm/client/upload.rb +2 -0
- data/lib/zm/client/zm_logger.rb +32 -2
- data/lib/zm/client.rb +15 -0
- data/lib/zm/connector/network_error_handler.rb +2 -0
- data/lib/zm/connector/rest_connector.rb +2 -0
- data/lib/zm/connector/soap_account_connector.rb +2 -0
- data/lib/zm/connector/soap_base_connector.rb +11 -7
- data/lib/zm/connector/ssl.rb +10 -0
- data/lib/zm/connector.rb +2 -1
- data/lib/zm/soap_request/request_methods_admin.rb +10 -6
- data/lib/zm/soap_request/soap_context.rb +2 -2
- data/lib/zm/support/cache/file_store.rb +2 -11
- data/lib/zm/support/cache/store.rb +4 -2
- data/lib/zm/utils/log_filter.rb +13 -5
- data/lib/zm-ruby-client.rb +0 -2
- data/sig/zm/client/admin_objects.rbs +119 -11
- data/sig/zm/client/base.rbs +81 -4
- data/sig/zm/client/cluster.rbs +13 -6
- data/sig/zm/client/mailbox.rbs +91 -2
- metadata +18 -17
- data/lib/zm/modules/common/zimbra-attrs.csv +0 -737
|
@@ -4,6 +4,8 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
# class for distribution list jsns builder
|
|
6
6
|
class DistributionListJsnsBuilder
|
|
7
|
+
include Base::ZimbraAttrsJsns
|
|
8
|
+
|
|
7
9
|
def initialize(item)
|
|
8
10
|
@item = item
|
|
9
11
|
end
|
|
@@ -15,11 +17,11 @@ module Zm
|
|
|
15
17
|
add_attr_nodes(soap_request, attrs_only_set_h)
|
|
16
18
|
end
|
|
17
19
|
|
|
18
|
-
def to_update
|
|
20
|
+
def to_update(force: false)
|
|
19
21
|
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::MODIFY_DISTRIBUTION_LIST_REQUEST)
|
|
20
22
|
.add_attribute(SoapRequest::SoapConstants::ID, @item.id)
|
|
21
23
|
|
|
22
|
-
add_attr_nodes(soap_request,
|
|
24
|
+
add_attr_nodes(soap_request, attrs_to_update_h(force))
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def to_patch(hash)
|
|
@@ -39,20 +41,6 @@ module Zm
|
|
|
39
41
|
.add_attributes({ id: @item.id, newName: new_name })
|
|
40
42
|
end
|
|
41
43
|
|
|
42
|
-
def attrs_only_set_h
|
|
43
|
-
selected_attrs = @item.attrs_write.map { |a| Utils.arrow_name_sym(a) }
|
|
44
|
-
attrs_only_set = @item.instance_variables & selected_attrs
|
|
45
|
-
|
|
46
|
-
arr = attrs_only_set.map do |name|
|
|
47
|
-
n = name.to_s[1..]
|
|
48
|
-
values = @item.instance_variable_get(name)
|
|
49
|
-
values = [values] unless values.is_a?(Array)
|
|
50
|
-
[n, values]
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
arr.to_h
|
|
54
|
-
end
|
|
55
|
-
|
|
56
44
|
private
|
|
57
45
|
|
|
58
46
|
def add_attr_nodes(soap_request, hash)
|
|
@@ -11,8 +11,7 @@ module Zm
|
|
|
11
11
|
super
|
|
12
12
|
|
|
13
13
|
unless item.zimbraMailForwardingAddress.is_a?(Array)
|
|
14
|
-
item.zimbraMailForwardingAddress
|
|
15
|
-
item.zimbraMailForwardingAddress.compact!
|
|
14
|
+
item.instance_variable_set(:@zimbraMailForwardingAddress, [item.zimbraMailForwardingAddress].compact)
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
update_members(item, json)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# distribution lists returned by DistributionListsCollection#all and find_in_batches
|
|
6
|
+
class DistributionListsResponse < Base::AdminObjectsResponse
|
|
7
|
+
def groups
|
|
8
|
+
self.class.new(@collection, select(&:group?))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def mailing_lists
|
|
12
|
+
self.class.new(@collection, select(&:mailing_list?))
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -17,17 +17,17 @@ module Zm
|
|
|
17
17
|
|
|
18
18
|
def build_query
|
|
19
19
|
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::GET_DISTRIBUTION_LIST_MEMBERSHIP_REQUEST)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
soap_request.add_node(
|
|
20
|
+
node_dl = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::DL)
|
|
21
|
+
.add_attribute(SoapRequest::SoapConstants::BY, SoapRequest::SoapConstants::ID)
|
|
22
|
+
.add_content(@parent.id)
|
|
23
|
+
soap_request.add_node(node_dl)
|
|
24
24
|
soap_request
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
private
|
|
28
28
|
|
|
29
29
|
def build_response
|
|
30
|
-
collection = make_query.dig(:
|
|
30
|
+
collection = make_query.dig(:GetDistributionListMembershipResponse, :dl) || []
|
|
31
31
|
collection.map { |json| DlMembership.new(name: json[:name], id: json[:id], via: json[:via]) }
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -8,9 +8,58 @@ module Zm
|
|
|
8
8
|
has_jsns_builder
|
|
9
9
|
include Zm::Utils::HasSoapAdminConnector
|
|
10
10
|
include SoapRequest::RequestMethodsAdmin
|
|
11
|
+
extend Base::HasZimbraAttributes
|
|
12
|
+
|
|
13
|
+
zimbra_attr %i[
|
|
14
|
+
description zimbraNotes zimbraMailStatus zimbraPrefTimeZoneId zimbraMailTransport zimbraLocale zimbraPrefSkin
|
|
15
|
+
zimbraAvailableSkin zimbraFreebusyExchangeURL zimbraFreebusyExchangeAuthUsername
|
|
16
|
+
zimbraFreebusyExchangeAuthPassword zimbraFreebusyExchangeUserOrg zimbraFreebusyExchangeAuthScheme
|
|
17
|
+
zimbraFreebusyExchangeCachedIntervalStart zimbraFreebusyExchangeCachedInterval zimbraACE
|
|
18
|
+
zimbraReverseProxyUseExternalRoute zimbraExternalPop3Port zimbraExternalPop3SSLPort zimbraExternalImapPort
|
|
19
|
+
zimbraExternalImapSSLPort zimbraExternalPop3Hostname zimbraExternalPop3SSLHostname zimbraExternalImapHostname
|
|
20
|
+
zimbraExternalImapSSLHostname zimbraPrefSpellIgnoreWord zimbraPrefMailTrustedSenderList
|
|
21
|
+
zimbraMailTrustedSenderListMaxNumEntries zimbraFeatureCalendarReminderDeviceEmailEnabled
|
|
22
|
+
zimbraCalendarLocationDisabledFields zimbraExternalSharingEnabled zimbraExternalShareWhitelistDomain
|
|
23
|
+
zimbraExternalShareDomainWhitelistEnabled zimbraStandardClientCustomPrefTabsEnabled
|
|
24
|
+
zimbraStandardClientCustomPrefTab zimbraInternalSendersDomain zimbraFileUploadMaxSizePerFile
|
|
25
|
+
zimbraPublicSharingEnabled zimbraUCServiceId zimbraPrefColorMessagesEnabled zimbraMobileMetadataMaxSizeEnabled
|
|
26
|
+
zimbraMobileItemsToTrackPerFolderMaxSize zimbraForceClearCookies zimbraFeatureDistributionListFolderEnabled
|
|
27
|
+
zimbraFeatureSocialEnabled zimbraFeatureSocialExternalEnabled zimbraFeatureSocialExternalURL
|
|
28
|
+
zimbraFeatureSocialName zimbraCommunityAPIClientID zimbraCommunityAPIClientSecret zimbraCommunityUsernameMapping
|
|
29
|
+
zimbraCommunityBaseURL zimbraCommunityHomeURL zimbraPrefShowChatsFolderInMail
|
|
30
|
+
zimbraZimletUserPropertiesMaxNumEntries zimbraExportMaxDays zimbraSieveRejectMailEnabled
|
|
31
|
+
zimbraSieveNotifyActionRFCCompliant zimbraAdminSieveScriptBefore zimbraAdminSieveScriptAfter
|
|
32
|
+
zimbraAdminOutgoingSieveScriptBefore zimbraAdminOutgoingSieveScriptAfter zimbraSieveRequireControlEnabled
|
|
33
|
+
zimbraSieveEditHeaderEnabled zimbraSieveImmutableHeaders zimbraPreAuthKey zimbraGalAccountId
|
|
34
|
+
zimbraGalAlwaysIncludeLocalCalendarResources zimbraGalAutoCompleteLdapFilter zimbraGalGroupIndicatorEnabled
|
|
35
|
+
zimbraGalInternalSearchBase zimbraGalLdapAttrMap zimbraGalLdapPageSize zimbraGalLdapValueMap zimbraGalMaxResults
|
|
36
|
+
zimbraGalMode zimbraGalSyncLdapPageSize zimbraGalSyncMaxConcurrentClients zimbraGalSyncSizeLimit
|
|
37
|
+
zimbraGalSyncTimestampFormat zimbraGalTokenizeAutoCompleteKey zimbraGalTokenizeSearchKey
|
|
38
|
+
zimbraLdapGalSyncDisabled zimbraGalLdapBindDn zimbraGalLdapBindPassword zimbraGalLdapFilter
|
|
39
|
+
zimbraGalLdapSearchBase zimbraGalLdapURL zimbraDomainDefaultCOSId zimbraPublicServiceHostname
|
|
40
|
+
zimbraPublicServiceProtocol zimbraAdminConsoleCatchAllAddressEnabled zimbraAdminConsoleDNSCheckEnabled
|
|
41
|
+
zimbraAdminConsoleLDAPAuthEnabled zimbraAdminConsoleSkinEnabled zimbraAggregateQuotaLastUsage zimbraAuthMech
|
|
42
|
+
zimbraAutoProvBatchSize zimbraAutoProvNotificationBody zimbraAutoProvNotificationSubject zimbraBasicAuthRealm
|
|
43
|
+
zimbraChatConversationAuditEnabled zimbraDomainAggregateQuota zimbraDomainAggregateQuotaPolicy
|
|
44
|
+
zimbraDomainAggregateQuotaWarnPercent zimbraDomainMandatoryMailSignatureEnabled zimbraDomainStatus
|
|
45
|
+
zimbraExternalShareInvitationUrlExpiration zimbraFreebusyExchangeServerType
|
|
46
|
+
zimbraInternalSharingCrossDomainEnabled zimbraMailDomainQuota zimbraMailSSLClientCertPrincipalMap
|
|
47
|
+
zimbraReverseProxyClientCertMode zimbraReverseProxyExternalRouteIncludeOriginalAuthusername
|
|
48
|
+
zimbraSkinLogoAppBanner zimbraSkinLogoLoginBanner zimbraSkinLogoURL zimbraWebClientMaxInputBufferLength
|
|
49
|
+
zimbraWebClientStaySignedInDisabled zimbraWebClientSupportedHelps zimbraZimletDataSensitiveInMixedModeDisabled
|
|
50
|
+
DKIMDomain DKIMIdentity DKIMKey DKIMPublicKey DKIMSelector zimbraShowClientTOS
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
zimbra_attr %i[
|
|
54
|
+
zimbraId zimbraCreateTimestamp zimbraGalDefinitionLastModifiedTime zimbraDomainName zimbraDomainType
|
|
55
|
+
], readonly: true
|
|
56
|
+
|
|
57
|
+
LOCAL = 'local'
|
|
58
|
+
ALIAS = 'alias'
|
|
11
59
|
|
|
12
60
|
def create!
|
|
13
61
|
resp = sac.invoke(build_create)
|
|
62
|
+
clear_zimbra_attrs_changes
|
|
14
63
|
@id = resp[:CreateDomainResponse][:domain].first[:id]
|
|
15
64
|
end
|
|
16
65
|
|
|
@@ -20,17 +69,9 @@ module Zm
|
|
|
20
69
|
|
|
21
70
|
has_many :resources, klass: :'Zm::Client::DomainResourcesCollection'
|
|
22
71
|
|
|
23
|
-
|
|
24
|
-
return nil if zimbraDomainDefaultCOSId.nil?
|
|
25
|
-
|
|
26
|
-
return @cos if defined? @cos
|
|
72
|
+
extend Base::HasCos
|
|
27
73
|
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def attrs_write
|
|
32
|
-
@parent.zimbra_attributes.all_domain_attrs_writable_names
|
|
33
|
-
end
|
|
74
|
+
has_cos :zimbraDomainDefaultCOSId
|
|
34
75
|
|
|
35
76
|
def DKIMPublicTxt
|
|
36
77
|
return if self.DKIMPublicKey.nil?
|
|
@@ -4,6 +4,8 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
# class for domain jsns builder
|
|
6
6
|
class DomainJsnsBuilder
|
|
7
|
+
include Base::ZimbraAttrsJsns
|
|
8
|
+
|
|
7
9
|
def initialize(item)
|
|
8
10
|
@item = item
|
|
9
11
|
end
|
|
@@ -24,11 +26,11 @@ module Zm
|
|
|
24
26
|
soap_request
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
def to_update
|
|
29
|
+
def to_update(force: false)
|
|
28
30
|
soap_request = SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::MODIFY_DOMAIN_REQUEST)
|
|
29
31
|
.add_attribute(SoapRequest::SoapConstants::ID, @item.id)
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
attrs_to_update_h(force).each do |key, values|
|
|
32
34
|
values.each do |value|
|
|
33
35
|
node_attr = SoapRequest::SoapElement.create(SoapRequest::SoapConstants::A).add_attribute(SoapRequest::SoapConstants::N, key).add_content(value)
|
|
34
36
|
soap_request.add_node(node_attr)
|
|
@@ -59,20 +61,6 @@ module Zm
|
|
|
59
61
|
SoapRequest::SoapElement.admin(Zm::SoapRequest::SoapAdminConstants::DELETE_DOMAIN_REQUEST)
|
|
60
62
|
.add_attribute(SoapRequest::SoapConstants::ID, @item.id)
|
|
61
63
|
end
|
|
62
|
-
|
|
63
|
-
def attrs_only_set_h
|
|
64
|
-
selected_attrs = @item.attrs_write.map { |a| Utils.arrow_name_sym(a) }
|
|
65
|
-
attrs_only_set = @item.instance_variables & selected_attrs
|
|
66
|
-
|
|
67
|
-
arr = attrs_only_set.map do |name|
|
|
68
|
-
n = name.to_s[1..]
|
|
69
|
-
values = @item.instance_variable_get(name)
|
|
70
|
-
values = [values] unless values.is_a?(Array)
|
|
71
|
-
[n, values]
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
arr.to_h
|
|
75
|
-
end
|
|
76
64
|
end
|
|
77
65
|
end
|
|
78
66
|
end
|
|
@@ -10,11 +10,18 @@ module Zm
|
|
|
10
10
|
def update(item, json)
|
|
11
11
|
item = super
|
|
12
12
|
|
|
13
|
-
item
|
|
14
|
-
item
|
|
13
|
+
wrap_string(item, :@zimbraGalAccountId)
|
|
14
|
+
wrap_string(item, :@zimbraGalLdapAttrMap)
|
|
15
15
|
|
|
16
16
|
item
|
|
17
17
|
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def wrap_string(item, ivar)
|
|
22
|
+
value = item.instance_variable_get(ivar)
|
|
23
|
+
item.instance_variable_set(ivar, [value]) if value.is_a?(String)
|
|
24
|
+
end
|
|
18
25
|
end
|
|
19
26
|
end
|
|
20
27
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# domains returned by DomainsCollection#all and find_in_batches
|
|
6
|
+
class DomainsResponse < Base::AdminObjectsResponse
|
|
7
|
+
def locals
|
|
8
|
+
self.class.new(@collection, select { |domain| domain.zimbraDomainType == Domain::LOCAL })
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def aliases
|
|
12
|
+
self.class.new(@collection, select { |domain| domain.zimbraDomainType == Domain::ALIAS })
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def statuses
|
|
16
|
+
each_with_object({}) do |domain, counts|
|
|
17
|
+
status = domain.zimbraDomainStatus
|
|
18
|
+
counts[status] = counts.fetch(status, 0) + 1
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -17,6 +17,7 @@ module Zm
|
|
|
17
17
|
CHATS = FolderData.new(14, 'Chats', '/Chats', 'message')
|
|
18
18
|
TASKS = FolderData.new(15, 'Tasks', '/Tasks', 'task')
|
|
19
19
|
BRIEFCASE = FolderData.new(16, 'Briefcase', '/Briefcase', 'document')
|
|
20
|
+
ARCHIVE = FolderData.new(20, 'Archive', '/Archive', 'message')
|
|
20
21
|
|
|
21
22
|
ALL = [
|
|
22
23
|
ROOT,
|
|
@@ -30,7 +31,8 @@ module Zm
|
|
|
30
31
|
JUNK,
|
|
31
32
|
SENT,
|
|
32
33
|
TASKS,
|
|
33
|
-
TRASH
|
|
34
|
+
TRASH,
|
|
35
|
+
ARCHIVE
|
|
34
36
|
].freeze
|
|
35
37
|
|
|
36
38
|
IDS = ALL.map(&:id).freeze
|
|
@@ -55,6 +55,30 @@ module Zm
|
|
|
55
55
|
@all << fg
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
def accounts
|
|
59
|
+
@all.select(&:is_account?)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def distribution_lists
|
|
63
|
+
@all.select(&:is_dl?)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def domains
|
|
67
|
+
@all.select(&:is_dom?)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def publics
|
|
71
|
+
@all.select(&:is_public?)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def externals
|
|
75
|
+
@all.select(&:is_external?)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def keys
|
|
79
|
+
@all.select(&:is_key?)
|
|
80
|
+
end
|
|
81
|
+
|
|
58
82
|
def soap_account_connector
|
|
59
83
|
@parent.parent.soap_account_connector
|
|
60
84
|
end
|
|
@@ -12,7 +12,8 @@ module Zm
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def update(item, json)
|
|
15
|
-
|
|
15
|
+
type = json.delete(:type)
|
|
16
|
+
item.type = type unless type.nil?
|
|
16
17
|
item.id = json.delete(:id)
|
|
17
18
|
item.uuid = json.delete(:uuid)
|
|
18
19
|
item.name = json.delete(:name)
|
|
@@ -44,9 +45,9 @@ module Zm
|
|
|
44
45
|
|
|
45
46
|
update_grants(item, json)
|
|
46
47
|
|
|
47
|
-
if (policies = json.fetch(:retentionPolicy, []).first).is_a?(
|
|
48
|
+
if (policies = json.fetch(:retentionPolicy, []).first).is_a?(Hash)
|
|
48
49
|
policies.each do |policy, v|
|
|
49
|
-
params = v.first
|
|
50
|
+
params = v.first&.dig(:policy, 0)
|
|
50
51
|
next if params.nil?
|
|
51
52
|
|
|
52
53
|
type = params.delete(:type)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# filters by view of an Array of folders or mountpoints
|
|
6
|
+
module FolderViewFilters
|
|
7
|
+
def messages
|
|
8
|
+
by_view(FolderView::MESSAGE)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def appointments
|
|
12
|
+
by_view(FolderView::APPOINTMENT)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def contacts
|
|
16
|
+
by_view(FolderView::CONTACT)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def tasks
|
|
20
|
+
by_view(FolderView::TASK)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def documents
|
|
24
|
+
by_view(FolderView::DOCUMENT)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def by_view(view)
|
|
28
|
+
select { |item| item.view == view }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -7,48 +7,63 @@ module Zm
|
|
|
7
7
|
def initialize(parent, json)
|
|
8
8
|
super
|
|
9
9
|
@key = :folder
|
|
10
|
-
@root_folder = nil
|
|
11
|
-
@list = []
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
def ids
|
|
13
|
+
@ids = []
|
|
15
14
|
root = @json[:GetFolderResponse][@key]
|
|
16
15
|
construct_tree_ids(root.first[@key])
|
|
17
|
-
@
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def construct_tree_ids(json_folders)
|
|
21
|
-
json_folders.each do |json_folder|
|
|
22
|
-
@list << json_folder[:id]
|
|
23
|
-
construct_tree_ids(json_folder[@key]) if !json_folder[@key].nil? && json_folder[@key].any?
|
|
24
|
-
end
|
|
16
|
+
@ids.map! { |id| MailboxItemID.create(id) }
|
|
17
|
+
@ids
|
|
25
18
|
end
|
|
26
19
|
|
|
27
20
|
def make
|
|
28
21
|
root = @json[:GetFolderResponse][@key]
|
|
29
22
|
|
|
30
23
|
@root_folder = FolderJsnsInitializer.create(@parent, root.first)
|
|
24
|
+
@root_folder.absFolderPath ||= root_path(@root_folder)
|
|
31
25
|
|
|
32
26
|
construct_tree(@root_folder, root.first[@key]) if !root.first[@key].nil? && root.first[@key].any?
|
|
33
27
|
|
|
34
28
|
@root_folder
|
|
35
29
|
end
|
|
36
30
|
|
|
31
|
+
def flatten(folder: make, collector: [])
|
|
32
|
+
collector.push(folder)
|
|
33
|
+
folder.folders.each do |child|
|
|
34
|
+
flatten(folder: child, collector:)
|
|
35
|
+
end
|
|
36
|
+
collector
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def construct_tree_ids(json_folders)
|
|
42
|
+
json_folders.each do |json_folder|
|
|
43
|
+
@ids << json_folder[:id]
|
|
44
|
+
construct_tree_ids(json_folder[@key]) if !json_folder[@key].nil? && json_folder[@key].any?
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
37
48
|
def construct_tree(parent_folder, json_folders)
|
|
38
49
|
json_folders.each do |json_folder|
|
|
39
50
|
folder = FolderJsnsInitializer.create(@parent, json_folder)
|
|
51
|
+
folder.absFolderPath ||= child_path(parent_folder.absFolderPath, folder.name)
|
|
52
|
+
folder.view ||= parent_folder.view
|
|
40
53
|
parent_folder.folders << folder
|
|
41
54
|
|
|
42
55
|
construct_tree(folder, json_folder[@key]) if !json_folder[@key].nil? && json_folder[@key].any?
|
|
43
56
|
end
|
|
44
57
|
end
|
|
45
58
|
|
|
46
|
-
def
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
def root_path(folder)
|
|
60
|
+
FolderDefault::ROOT.path if folder.id.to_i == FolderDefault::ROOT.id
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def child_path(parent_path, name)
|
|
64
|
+
return if parent_path.nil? || name.nil?
|
|
65
|
+
|
|
66
|
+
parent_path.end_with?('/') ? "#{parent_path}#{name}" : "#{parent_path}/#{name}"
|
|
52
67
|
end
|
|
53
68
|
end
|
|
54
69
|
end
|
|
@@ -10,11 +10,10 @@ module Zm
|
|
|
10
10
|
@child_class = Folder
|
|
11
11
|
@builder_class = FoldersBuilder
|
|
12
12
|
super
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
reset_query_params
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
# TODO: forcer id en string
|
|
18
17
|
def find(id)
|
|
19
18
|
folder = @child_class.new(@parent) do |f|
|
|
20
19
|
f.id = id
|
|
@@ -34,12 +33,7 @@ module Zm
|
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
def ids
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def clear
|
|
41
|
-
@root = nil
|
|
42
|
-
reset_query_params
|
|
36
|
+
folder_builder.ids
|
|
43
37
|
end
|
|
44
38
|
|
|
45
39
|
def document
|
|
@@ -77,18 +71,32 @@ module Zm
|
|
|
77
71
|
jsns_builder.to_jsns
|
|
78
72
|
end
|
|
79
73
|
|
|
74
|
+
def tree
|
|
75
|
+
folder_builder.make
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def clear
|
|
79
|
+
reset_query_params
|
|
80
|
+
end
|
|
81
|
+
|
|
80
82
|
private
|
|
81
83
|
|
|
82
84
|
def build_response
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
folders
|
|
86
|
-
folders.select! { |folder| folder.view ==
|
|
85
|
+
view = @view
|
|
86
|
+
folders = folder_builder.flatten(collector: FoldersResponse.new)
|
|
87
|
+
# When folders are filtered by view, unknown folders remain in the list
|
|
88
|
+
folders.select! { |folder| folder.view == view } unless view.nil?
|
|
87
89
|
folders
|
|
88
90
|
end
|
|
89
91
|
|
|
92
|
+
def folder_builder
|
|
93
|
+
@builder_class.new(@parent, make_query)
|
|
94
|
+
end
|
|
95
|
+
|
|
90
96
|
def make_query
|
|
91
|
-
@parent.soap_connector.invoke(jsns_builder.to_jsns)
|
|
97
|
+
response = @parent.soap_connector.invoke(jsns_builder.to_jsns)
|
|
98
|
+
reset_query_params
|
|
99
|
+
response
|
|
92
100
|
end
|
|
93
101
|
|
|
94
102
|
def reset_query_params
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
MailboxItemID = Data.define(:item_id, :mailbox_id)
|
|
5
|
+
MailboxItemID = Data.define(:item_id, :mailbox_id) do
|
|
6
|
+
def self.create(remote_id)
|
|
7
|
+
parts = remote_id.to_s.split(':').reverse
|
|
8
|
+
parts << nil if parts.length == 1
|
|
9
|
+
new(*parts)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
6
12
|
end
|
|
7
13
|
end
|
|
@@ -8,7 +8,7 @@ module Zm
|
|
|
8
8
|
super
|
|
9
9
|
@key_link = :link
|
|
10
10
|
@key_folder = :folder
|
|
11
|
-
@list =
|
|
11
|
+
@list = MountPointsResponse.new
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def make
|
|
@@ -22,8 +22,8 @@ module Zm
|
|
|
22
22
|
def construct_tree(json_folders)
|
|
23
23
|
json_folders.each do |json_folder|
|
|
24
24
|
if json_folder[@key_link].is_a?(Array)
|
|
25
|
-
|
|
26
|
-
MountPointJsnsInitializer.create(@parent, json_link)
|
|
25
|
+
json_folder[@key_link].each do |json_link|
|
|
26
|
+
@list << MountPointJsnsInitializer.create(@parent, json_link)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -4,15 +4,12 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
# collection of mountpoints
|
|
6
6
|
class MountPointsCollection < Base::AccountObjectsCollection
|
|
7
|
-
attr_reader :root
|
|
8
|
-
|
|
9
7
|
attr_accessor :view, :tr, :visible, :needGranteeName, :depth
|
|
10
8
|
|
|
11
9
|
def initialize(parent)
|
|
12
10
|
@child_class = MountPoint
|
|
13
11
|
@builder_class = MountPointsBuilder
|
|
14
12
|
super
|
|
15
|
-
@root = nil
|
|
16
13
|
reset_query_params
|
|
17
14
|
end
|
|
18
15
|
|
|
@@ -23,7 +20,6 @@ module Zm
|
|
|
23
20
|
end
|
|
24
21
|
|
|
25
22
|
def clear
|
|
26
|
-
@root = nil
|
|
27
23
|
reset_query_params
|
|
28
24
|
end
|
|
29
25
|
|