zm-ruby-client 0.18.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +2 -2
- data/README.md +7 -0
- data/lib/zm/client/account/account.rb +31 -308
- data/lib/zm/client/account/account_aliases_collection.rb +52 -0
- data/lib/zm/client/account/account_dls_membership_collection.rb +4 -1
- data/lib/zm/client/account/account_dls_owner_collection.rb +8 -1
- data/lib/zm/client/account/account_jsns_builder.rb +77 -0
- data/lib/zm/client/account/account_jsns_initializer.rb +9 -24
- data/lib/zm/client/account/accounts_builder.rb +0 -1
- data/lib/zm/client/account/accounts_collection.rb +32 -8
- data/lib/zm/client/account.rb +1 -0
- data/lib/zm/client/ace/ace.rb +6 -22
- data/lib/zm/client/ace/ace_jsns_builder.rb +15 -16
- data/lib/zm/client/ace/ace_jsns_initializer.rb +0 -1
- data/lib/zm/client/ace/aces_builder.rb +0 -1
- data/lib/zm/client/ace/aces_collection.rb +2 -18
- data/lib/zm/client/appointment/appointment.rb +38 -30
- data/lib/zm/client/appointment/appointment_jsns_builder.rb +22 -34
- data/lib/zm/client/appointment/appointment_jsns_initializer.rb +6 -3
- data/lib/zm/client/appointment/appointments_builder.rb +6 -18
- data/lib/zm/client/appointment/appointments_collection.rb +25 -4
- data/lib/zm/client/backup/backup.rb +4 -32
- data/lib/zm/client/backup/backup_jsns_initializer.rb +26 -0
- data/lib/zm/client/backup/backups_builder.rb +8 -13
- data/lib/zm/client/backup/backups_collection.rb +2 -1
- data/lib/zm/client/backup.rb +1 -0
- data/lib/zm/client/base/account_search_objects_collection.rb +34 -13
- data/lib/zm/client/base/admin_objects_collection.rb +82 -17
- data/lib/zm/client/base/base_account_jsns_builder.rb +98 -0
- data/lib/zm/client/base/base_jsns_builder.rb +47 -0
- data/lib/zm/client/base/base_jsns_initializer.rb +43 -12
- data/lib/zm/client/base/ldap_filter.rb +20 -5
- data/lib/zm/client/base/mailbox_infos_collection.rb +68 -0
- data/lib/zm/client/base/mailbox_object.rb +299 -0
- data/lib/zm/client/base/mailbox_prefs_collection.rb +75 -0
- data/lib/zm/client/base/object.rb +28 -62
- data/lib/zm/client/base/objects_builder.rb +4 -10
- data/lib/zm/client/base/objects_collection.rb +13 -10
- data/lib/zm/client/base/zimbra_attribute.rb +10 -8
- data/lib/zm/client/base/zimbra_attributes_collection.rb +154 -10
- data/lib/zm/client/base.rb +5 -5
- data/lib/zm/client/cluster/cluster.rb +43 -39
- data/lib/zm/client/cluster/cluster_config.rb +5 -5
- data/lib/zm/client/common/recipients.rb +3 -3
- data/lib/zm/client/common/token_metadata.rb +4 -1
- data/lib/zm/client/common/utils.rb +57 -0
- data/lib/zm/client/common.rb +2 -1
- data/lib/zm/client/connector/rest_account.rb +15 -28
- data/lib/zm/client/connector/soap_account.rb +38 -441
- data/lib/zm/client/connector/soap_admin.rb +16 -552
- data/lib/zm/client/connector/soap_base.rb +30 -21
- data/lib/zm/client/connector/soap_error.rb +1 -3
- data/lib/zm/client/constant.rb +21 -11
- data/lib/zm/client/contact/contact.rb +42 -83
- data/lib/zm/client/contact/contact_jsns_builder.rb +60 -0
- data/lib/zm/client/contact/contact_jsns_initializer.rb +78 -0
- data/lib/zm/client/contact/contact_member.rb +29 -28
- data/lib/zm/client/contact/contact_members_collection.rb +44 -0
- data/lib/zm/client/contact/contacts_builder.rb +8 -1
- data/lib/zm/client/contact/contacts_collection.rb +17 -1
- data/lib/zm/client/contact/group_contact_jsns_builder.rb +51 -0
- data/lib/zm/client/contact/mod_group_contact.rb +4 -67
- data/lib/zm/client/contact.rb +5 -1
- data/lib/zm/client/cos/cos.rb +35 -40
- data/lib/zm/client/cos/cos_accounts_collection.rb +19 -0
- data/lib/zm/client/cos/cos_domains_collection.rb +20 -0
- data/lib/zm/client/cos/cos_jsns_builder.rb +72 -0
- data/lib/zm/client/cos/cos_jsns_initializer.rb +29 -0
- data/lib/zm/client/cos/cos_servers_collection.rb +60 -0
- data/lib/zm/client/cos/coses_builder.rb +8 -1
- data/lib/zm/client/cos/coses_collection.rb +8 -5
- data/lib/zm/client/cos.rb +5 -0
- data/lib/zm/client/datasource/datasource.rb +69 -0
- data/lib/zm/client/datasource/datasource_jsns_builder.rb +32 -0
- data/lib/zm/client/datasource/datasource_jsns_initializer.rb +27 -0
- data/lib/zm/client/datasource/datasources_builder.rb +29 -0
- data/lib/zm/client/datasource/datasources_collection.rb +21 -0
- data/lib/zm/client/datasource.rb +7 -0
- data/lib/zm/client/distributionlist/distributionlist.rb +52 -118
- data/lib/zm/client/distributionlist/distributionlist_aces_collection.rb +31 -0
- data/lib/zm/client/distributionlist/distributionlist_aliases_collection.rb +53 -0
- data/lib/zm/client/distributionlist/distributionlist_jsns_builder.rb +82 -0
- data/lib/zm/client/distributionlist/distributionlist_jsns_initializer.rb +32 -0
- data/lib/zm/client/distributionlist/distributionlist_members_collection.rb +47 -0
- data/lib/zm/client/distributionlist/distributionlist_owners_collection.rb +52 -0
- data/lib/zm/client/distributionlist/distributionlists_builder.rb +8 -1
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +8 -9
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +4 -1
- data/lib/zm/client/distributionlist.rb +2 -0
- data/lib/zm/client/document/document.rb +27 -24
- data/lib/zm/client/document/document_jsns_builder.rb +18 -0
- data/lib/zm/client/document/document_jsns_initializer.rb +44 -0
- data/lib/zm/client/document/documents_builder.rb +6 -16
- data/lib/zm/client/document/documents_collection.rb +17 -67
- data/lib/zm/client/document.rb +2 -0
- data/lib/zm/client/domain/domain.rb +39 -55
- data/lib/zm/client/domain/domain_accounts_collection.rb +1 -1
- data/lib/zm/client/domain/domain_distributionlists_collection.rb +13 -0
- data/lib/zm/client/domain/domain_jsns_builder.rb +69 -0
- data/lib/zm/client/domain/domain_jsns_initializer.rb +25 -0
- data/lib/zm/client/domain/domain_resources_collection.rb +13 -0
- data/lib/zm/client/domain/domains_builder.rb +8 -1
- data/lib/zm/client/domain/domains_collection.rb +7 -7
- data/lib/zm/client/domain.rb +4 -0
- data/lib/zm/client/filter_rule.rb +7 -0
- data/lib/zm/client/filter_rules/filter_rule.rb +10 -0
- data/lib/zm/client/filter_rules/filter_rule_jsns_initializer.rb +24 -0
- data/lib/zm/client/filter_rules/filter_rules_builder.rb +21 -0
- data/lib/zm/client/filter_rules/filter_rules_collection.rb +21 -0
- data/lib/zm/client/filter_rules/outgoing_filter_rules_collection.rb +15 -0
- data/lib/zm/client/folder/folder.rb +77 -61
- data/lib/zm/client/folder/folder_grant.rb +34 -14
- data/lib/zm/client/folder/folder_grant_jsns_builder.rb +15 -4
- data/lib/zm/client/folder/folder_grants_collection.rb +36 -2
- data/lib/zm/client/folder/folder_jsns_builder.rb +22 -48
- data/lib/zm/client/folder/folder_jsns_initializer.rb +34 -17
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +2 -3
- data/lib/zm/client/folder/folder_retention_policy.rb +0 -1
- data/lib/zm/client/folder/folders_builder.rb +7 -10
- data/lib/zm/client/folder/folders_collection.rb +5 -2
- data/lib/zm/client/folder/folders_jsns_builder.rb +3 -1
- data/lib/zm/client/folder/mod_document_folder.rb +10 -6
- data/lib/zm/client/folder.rb +1 -1
- data/lib/zm/client/identity/identities_builder.rb +8 -1
- data/lib/zm/client/identity/identities_collection.rb +2 -1
- data/lib/zm/client/identity/identity.rb +34 -42
- data/lib/zm/client/identity/identity_jsns_builder.rb +57 -0
- data/lib/zm/client/identity/identity_jsns_initializer.rb +29 -0
- data/lib/zm/client/identity.rb +3 -1
- data/lib/zm/client/license/license.rb +9 -22
- data/lib/zm/client/license/license_jsns_initializer.rb +20 -0
- data/lib/zm/client/license/licenses_collection.rb +3 -13
- data/lib/zm/client/license.rb +2 -1
- data/lib/zm/client/message/attachments_collection.rb +55 -0
- data/lib/zm/client/message/message.rb +36 -264
- data/lib/zm/client/message/message_flags.rb +107 -0
- data/lib/zm/client/message/message_jsns_builder.rb +85 -0
- data/lib/zm/client/message/message_jsns_initializer.rb +71 -0
- data/lib/zm/client/message/message_recipients.rb +59 -0
- data/lib/zm/client/message/messages_builder.rb +7 -18
- data/lib/zm/client/message/messages_collection.rb +17 -2
- data/lib/zm/client/message.rb +5 -0
- data/lib/zm/client/mountpoint/mountpoint.rb +43 -20
- data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +8 -53
- data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +22 -13
- data/lib/zm/client/mountpoint/mountpoints_builder.rb +4 -5
- data/lib/zm/client/mountpoint/mountpoints_collection.rb +1 -2
- data/lib/zm/client/mta_queue/mta_queue.rb +13 -28
- data/lib/zm/client/mta_queue/mta_queue_jsns_builder.rb +41 -0
- data/lib/zm/client/mta_queue/mta_queue_jsns_initializer.rb +23 -0
- data/lib/zm/client/mta_queue/mta_queues_builder.rb +4 -8
- data/lib/zm/client/mta_queue/mta_queues_collection.rb +8 -27
- data/lib/zm/client/mta_queue.rb +2 -0
- data/lib/zm/client/mta_queue_item/mta_queue_item.rb +4 -31
- data/lib/zm/client/mta_queue_item/mta_queue_item_jsns_initializer.rb +33 -0
- data/lib/zm/client/mta_queue_item/mta_queue_items_builder.rb +4 -9
- data/lib/zm/client/mta_queue_item/mta_queue_items_collection.rb +7 -42
- data/lib/zm/client/mta_queue_item.rb +2 -1
- data/lib/zm/client/resource/resource.rb +24 -91
- data/lib/zm/client/resource/resource_jsns_builder.rb +79 -0
- data/lib/zm/client/resource/resource_jsns_initializer.rb +29 -0
- data/lib/zm/client/resource/resources_builder.rb +8 -1
- data/lib/zm/client/resource/resources_collection.rb +9 -7
- data/lib/zm/client/resource.rb +2 -0
- data/lib/zm/client/search_folder/search_folder.rb +38 -16
- data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +38 -19
- data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +17 -13
- data/lib/zm/client/search_folder/search_folders_builder.rb +0 -1
- data/lib/zm/client/search_folder/search_folders_collection.rb +2 -1
- data/lib/zm/client/server/server.rb +16 -488
- data/lib/zm/client/server/server_jsns_initializer.rb +16 -0
- data/lib/zm/client/server/servers_builder.rb +8 -1
- data/lib/zm/client/server/servers_collection.rb +13 -5
- data/lib/zm/client/server.rb +1 -0
- data/lib/zm/client/share/share.rb +5 -43
- data/lib/zm/client/share/share_jsns_initializer.rb +32 -0
- data/lib/zm/client/share/share_mountpoints_collection.rb +38 -0
- data/lib/zm/client/share/shares_builder.rb +8 -1
- data/lib/zm/client/share/shares_collection.rb +11 -16
- data/lib/zm/client/share.rb +2 -0
- data/lib/zm/client/signature/signature.rb +25 -29
- data/lib/zm/client/signature/signature_jsns_builder.rb +31 -13
- data/lib/zm/client/signature/signature_jsns_initializer.rb +16 -12
- data/lib/zm/client/signature/signatures_builder.rb +1 -2
- data/lib/zm/client/signature/signatures_collection.rb +2 -1
- data/lib/zm/client/signature.rb +1 -1
- data/lib/zm/client/soap_request/account_soap_constants.rb +76 -0
- data/lib/zm/client/soap_request/admin_soap_constants.rb +214 -0
- data/lib/zm/client/soap_request/mail_soap_constants.rb +162 -0
- data/lib/zm/client/soap_request/soap_constants.rb +55 -0
- data/lib/zm/client/soap_request/soap_context.rb +38 -0
- data/lib/zm/client/soap_request/soap_element.rb +90 -0
- data/lib/zm/client/soap_request.rb +8 -0
- data/lib/zm/client/tag/account_object_tags_collection.rb +65 -0
- data/lib/zm/client/tag/tag.rb +34 -22
- data/lib/zm/client/tag/tag_jsns_builder.rb +14 -35
- data/lib/zm/client/tag/tag_jsns_initializer.rb +4 -6
- data/lib/zm/client/tag/tags_builder.rb +0 -1
- data/lib/zm/client/tag/tags_collection.rb +2 -1
- data/lib/zm/client/tag.rb +1 -0
- data/lib/zm/client/task/task.rb +18 -49
- data/lib/zm/client/task/task_jsns_initializer.rb +45 -0
- data/lib/zm/client/task/tasks_builder.rb +6 -16
- data/lib/zm/client/task/tasks_collection.rb +29 -0
- data/lib/zm/client/task.rb +1 -0
- data/lib/zm/client/upload/upload.rb +26 -30
- data/lib/zm/client/version.rb +3 -3
- data/lib/zm/client.rb +4 -1
- data/lib/zm/modules/base.rb +10 -0
- data/lib/zm/modules/belongs_to_folder.rb +37 -0
- data/lib/zm/modules/belongs_to_tag.rb +11 -0
- data/lib/zm/modules/common/zimbra-attrs.json +1 -1
- data/lib/zm/modules/has_soap_admin_connector.rb +12 -0
- data/lib/zm/modules/inspector.rb +24 -0
- data/lib/zm/modules/missing_method_static_collection.rb +13 -0
- data/lib/zm/modules/zm_logger.rb +3 -1
- data/lib/zm/modules/zm_model.rb +4 -2
- data/lib/zm/utils/thread_pool.rb +4 -2
- data/lib/zm-ruby-client.rb +2 -0
- data/zm-ruby-client.gemspec +12 -9
- metadata +93 -34
- data/lib/zm/client/base/account_object.rb +0 -51
- data/lib/zm/client/base/admin_object.rb +0 -51
- data/lib/zm/client/base/folder_object.rb +0 -41
- data/lib/zm/client/config.rb +0 -12
- data/lib/zm/client/data_source.rb +0 -5
- data/lib/zm/modules/common/account_common.rb +0 -71
- data/lib/zm/modules/common/cos_common.rb +0 -463
- data/lib/zm/modules/common/dl_common.rb +0 -38
- data/lib/zm/modules/common/identity_common.rb +0 -19
- data/lib/zm/modules/common/resource_common.rb +0 -59
- data/lib/zm/modules/common/signature_common.rb +0 -16
- data/lib/zm/modules/common/zimbra-attrs.json.bak +0 -1
- data/test/accounts.rb +0 -89
- data/test/ace.rb +0 -50
- data/test/cluster.rb +0 -41
- data/test/cluster_config.rb +0 -30
- data/test/cluster_zimbra_attributes.rb +0 -38
- data/test/coses.rb +0 -26
- data/test/domains.rb +0 -70
- data/test/folder.rb +0 -125
- data/test/folder_grant.rb +0 -51
- data/test/mountpoint.rb +0 -49
- data/test/retention_policies.rb +0 -40
- data/test/search_folder.rb +0 -67
- data/test/signature.rb +0 -53
- data/test/tag.rb +0 -65
- data/test/zimbra_attributes.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e22c8126c13210fc0be35b5358b30d5ae7cbf12118bffe8ad522e6fdc2a2379
|
4
|
+
data.tar.gz: 81eca4a1ef8efd633447c93bf782cd68e522a19db80f968475404aa3fca5c5cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c5a99d6ff59e84e662c6715fca60e03b0087874c9679bc71309430c78c8264afea3e21c3634d4734987a3306f18c48f59e7eb94802cc1185b80893cd8615c34
|
7
|
+
data.tar.gz: 44cba59215626852bf2e2dc0189f10164112ffca3fa8c1878815515fa2e5e8e1ce5943f6ee235a74f8883f8a8a4a5acc2c2df5f69994a61b12ebc29fbd3f28aa
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,10 +2,17 @@
|
|
2
2
|
|
3
3
|
Library to interface with Zimbra simply.
|
4
4
|
|
5
|
+
Author: Maxime Désécot <maxime.desecot@gmail.com>
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
9
|
+
OS: Linux distribution LTS
|
10
|
+
|
11
|
+
Language: Ruby2.7+
|
12
|
+
|
7
13
|
```bash
|
8
14
|
sudo apt install make gcc curl libcurl4-openssl-dev
|
15
|
+
gem install zm-ruby-client
|
9
16
|
```
|
10
17
|
|
11
18
|
## Examples of uses:
|
@@ -1,345 +1,68 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'zm/
|
4
|
-
# require_relative '../../modules/common/account_galsync'
|
5
|
-
require 'zm/client/common'
|
6
|
-
require 'zm/client/connector/rest_account'
|
7
|
-
require 'zm/client/signature'
|
8
|
-
require 'zm/client/folder'
|
9
|
-
require 'zm/client/mountpoint'
|
10
|
-
require 'zm/client/search_folder'
|
11
|
-
require 'zm/client/share'
|
12
|
-
require 'zm/client/tag'
|
13
|
-
require 'zm/client/ace'
|
14
|
-
require 'zm/client/contact'
|
15
|
-
require 'zm/client/appointment'
|
16
|
-
require 'zm/client/task'
|
17
|
-
require 'zm/client/document'
|
18
|
-
# require 'zm/client/data_source'
|
19
|
-
require 'zm/client/message'
|
20
|
-
require 'zm/client/identity'
|
21
|
-
require 'zm/client/upload'
|
22
|
-
require 'addressable/uri'
|
3
|
+
require 'zm/client/account/account_aliases_collection'
|
23
4
|
|
24
5
|
module Zm
|
25
6
|
module Client
|
26
7
|
# objectClass: zimbraAccount
|
27
|
-
class Account < Base::
|
28
|
-
|
8
|
+
class Account < Base::MailboxObject
|
9
|
+
# #################################################################
|
10
|
+
# Associations
|
11
|
+
# #################################################################
|
29
12
|
|
30
|
-
def
|
31
|
-
|
32
|
-
super(parent)
|
33
|
-
@grantee_type = 'usr'.freeze
|
34
|
-
end
|
35
|
-
|
36
|
-
def all_instance_variable_keys
|
37
|
-
AccountCommon::ZM_ACCOUNT_ATTRS
|
38
|
-
end
|
39
|
-
|
40
|
-
def rest_account_connector
|
41
|
-
@rest_account_connector ||= RestAccountConnector.new
|
42
|
-
end
|
43
|
-
|
44
|
-
alias rac rest_account_connector
|
45
|
-
|
46
|
-
def logged?
|
47
|
-
!@token.nil?
|
48
|
-
end
|
49
|
-
|
50
|
-
def login
|
51
|
-
if @parent.logged?
|
52
|
-
admin_login
|
53
|
-
else
|
54
|
-
account_login
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def account_login
|
59
|
-
if password
|
60
|
-
account_login_password
|
61
|
-
else
|
62
|
-
account_login_preauth
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def account_login_preauth
|
67
|
-
domain_key
|
68
|
-
raise ZmError, 'domain key is required to login !' if @domainkey.nil?
|
69
|
-
|
70
|
-
@token = sacc.auth_preauth(@name, @domainkey)
|
71
|
-
end
|
72
|
-
|
73
|
-
def account_login_password
|
74
|
-
raise ZmError, 'password is required to login !' if password.nil?
|
75
|
-
|
76
|
-
@token = sacc.auth_password(@name, @password)
|
77
|
-
end
|
78
|
-
|
79
|
-
def admin_login
|
80
|
-
@token = sac.delegate_auth(@name)
|
81
|
-
end
|
82
|
-
|
83
|
-
def token_metadata
|
84
|
-
@token_metadata ||= TokenMetaData.new(@token)
|
85
|
-
end
|
86
|
-
|
87
|
-
def domain_name
|
88
|
-
@domain_name ||= @name.split('@').last
|
89
|
-
end
|
90
|
-
|
91
|
-
def domain_key
|
92
|
-
@domainkey ||= @parent.domain_key(domain_name)
|
93
|
-
end
|
94
|
-
|
95
|
-
def domain_key=(key)
|
96
|
-
@domainkey = key
|
97
|
-
end
|
98
|
-
|
99
|
-
def infos
|
100
|
-
@infos || read_infos
|
101
|
-
end
|
102
|
-
|
103
|
-
def read_infos
|
104
|
-
@infos = sacc.get_info(@token)[:Body][:GetInfoResponse]
|
105
|
-
@id = @infos[:id]
|
106
|
-
@used = @infos[:used]
|
107
|
-
@public_url = @infos[:publicURL]
|
108
|
-
@zimbraCOSId = @infos[:cos][:id]
|
109
|
-
@home_url = @infos[:rest]
|
110
|
-
@infos
|
13
|
+
def aliases
|
14
|
+
@aliases ||= AccountAliasesCollection.new(self)
|
111
15
|
end
|
112
16
|
|
113
17
|
def cos
|
114
18
|
@cos ||= @parent.coses.find_by(id: zimbraCOSId)
|
115
19
|
end
|
116
20
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
def public_url
|
122
|
-
infos if @infos.nil?
|
123
|
-
@public_url
|
124
|
-
end
|
125
|
-
|
126
|
-
def home_url
|
127
|
-
infos if @infos.nil?
|
128
|
-
@home_url
|
129
|
-
end
|
130
|
-
|
131
|
-
def messages
|
132
|
-
@messages ||= MessagesCollection.new(self)
|
133
|
-
end
|
134
|
-
|
135
|
-
def folders
|
136
|
-
@folders ||= FoldersCollection.new(self)
|
137
|
-
end
|
138
|
-
|
139
|
-
def mountpoints
|
140
|
-
@mountpointss ||= MountPointsCollection.new(self)
|
141
|
-
end
|
142
|
-
|
143
|
-
def search_folders
|
144
|
-
@search_folders ||= SearchFoldersCollection.new(self)
|
145
|
-
end
|
146
|
-
|
147
|
-
def identities
|
148
|
-
@identities ||= IdentitiesCollection.new(self)
|
149
|
-
end
|
150
|
-
|
151
|
-
def shares
|
152
|
-
@shares ||= SharesCollection.new(self)
|
153
|
-
end
|
154
|
-
|
155
|
-
def contacts
|
156
|
-
@contacts ||= ContactsCollection.new(self)
|
157
|
-
end
|
158
|
-
|
159
|
-
def appointments
|
160
|
-
@appointments ||= AppointmentsCollection.new(self)
|
161
|
-
end
|
162
|
-
|
163
|
-
def tags
|
164
|
-
@tags ||= TagsCollection.new(self)
|
165
|
-
end
|
166
|
-
|
167
|
-
def tasks
|
168
|
-
@tasks ||= TasksCollection.new(self)
|
169
|
-
end
|
170
|
-
|
171
|
-
def aces
|
172
|
-
@aces ||= AcesCollection.new(self)
|
173
|
-
end
|
174
|
-
alias rights aces
|
175
|
-
|
176
|
-
def signatures
|
177
|
-
@signatures ||= SignaturesCollection.new(self)
|
178
|
-
end
|
179
|
-
|
180
|
-
def data_sources
|
181
|
-
@data_sources ||= DataSourcesCollection.new sac, self
|
182
|
-
end
|
183
|
-
|
184
|
-
def documents
|
185
|
-
@documents ||= DocumentsCollection.new(self)
|
186
|
-
end
|
187
|
-
|
188
|
-
def message_folders
|
189
|
-
@message_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::MESSAGE.to_s }
|
190
|
-
end
|
191
|
-
|
192
|
-
def contact_folders
|
193
|
-
@contact_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::CONTACT.to_s }
|
194
|
-
end
|
195
|
-
|
196
|
-
def calendar_folders
|
197
|
-
@calendar_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::APPOINTMENT.to_s }
|
198
|
-
end
|
199
|
-
|
200
|
-
def task_folders
|
201
|
-
@task_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::TASK.to_s }
|
202
|
-
end
|
203
|
-
|
204
|
-
def document_folders
|
205
|
-
@document_folders ||= folders.all.select { |f| f.view == Zm::Client::FolderView::DOCUMENT.to_s }
|
206
|
-
end
|
21
|
+
# #################################################################
|
22
|
+
# SOAP Actions
|
23
|
+
# #################################################################
|
207
24
|
|
208
25
|
def delete!
|
209
|
-
sac.
|
210
|
-
|
211
|
-
|
212
|
-
def password!(new_password)
|
213
|
-
sac.set_password(@id, new_password)
|
214
|
-
@password = new_password
|
215
|
-
end
|
216
|
-
|
217
|
-
def update!(hash)
|
218
|
-
sac.modify_account(@id, hash)
|
219
|
-
|
220
|
-
hash.each do |k, v|
|
221
|
-
arrow_attr_sym = "@#{k}".to_sym
|
222
|
-
|
223
|
-
if v.respond_to?(:empty?) && v.empty?
|
224
|
-
self.remove_instance_variable(arrow_attr_sym) if self.instance_variable_get(arrow_attr_sym)
|
225
|
-
else
|
226
|
-
self.instance_variable_set(arrow_attr_sym, v)
|
227
|
-
end
|
228
|
-
end
|
26
|
+
sac.invoke(jsns_builder.to_delete)
|
27
|
+
@id = nil
|
229
28
|
end
|
230
29
|
|
231
30
|
def modify!
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
sac.modify_account(@id, attrs_to_modify)
|
31
|
+
sac.invoke(jsns_builder.to_update)
|
32
|
+
true
|
236
33
|
end
|
237
34
|
|
238
35
|
def create!
|
239
|
-
|
240
|
-
|
241
|
-
@password,
|
242
|
-
instance_variables_array(attrs_write)
|
243
|
-
)
|
244
|
-
@id = rep[:Body][:CreateAccountResponse][:account].first[:id]
|
245
|
-
end
|
246
|
-
|
247
|
-
def set_password(new_password = nil)
|
248
|
-
new_password ||= @password
|
249
|
-
sac.set_password(@id, new_password)
|
250
|
-
@password = new_password
|
251
|
-
end
|
252
|
-
|
253
|
-
def aliases
|
254
|
-
@aliases ||= set_aliases
|
255
|
-
end
|
256
|
-
|
257
|
-
def set_aliases
|
258
|
-
return [] if zimbraMailAlias.nil?
|
259
|
-
return [zimbraMailAlias] if zimbraMailAlias.is_a?(String)
|
260
|
-
zimbraMailAlias
|
261
|
-
end
|
262
|
-
|
263
|
-
def add_alias!(email)
|
264
|
-
sac.add_account_alias(@id, email)
|
265
|
-
aliases.push(email)
|
266
|
-
end
|
267
|
-
|
268
|
-
def remove_alias!(email)
|
269
|
-
sac.remove_account_alias(@id, email)
|
270
|
-
aliases.delete(email)
|
271
|
-
end
|
272
|
-
|
273
|
-
def rename!(email)
|
274
|
-
sac.rename_account(@id, email)
|
275
|
-
@name = email
|
276
|
-
end
|
277
|
-
|
278
|
-
def local_transport
|
279
|
-
raise Zm::Client::SoapError, 'zimbraMailHost is null' if zimbraMailHost.nil?
|
280
|
-
|
281
|
-
"lmtp:#{zimbraMailHost}:7025"
|
282
|
-
end
|
283
|
-
|
284
|
-
def local_transport!
|
285
|
-
update!(zimbraMailTransport: local_transport)
|
286
|
-
end
|
287
|
-
|
288
|
-
def is_local_transport?
|
289
|
-
return nil unless zimbraMailTransport
|
290
|
-
|
291
|
-
zimbraMailTransport.start_with?('lmtp')
|
292
|
-
end
|
293
|
-
|
294
|
-
def is_external_transport?
|
295
|
-
return nil unless zimbraMailTransport
|
296
|
-
|
297
|
-
zimbraMailTransport.start_with?('smtp')
|
298
|
-
end
|
299
|
-
|
300
|
-
def uploader
|
301
|
-
@uploader ||= Upload.new(self)
|
302
|
-
end
|
303
|
-
|
304
|
-
def last_logon
|
305
|
-
@last_logon ||= Time.parse zimbraLastLogonTimestamp unless zimbraLastLogonTimestamp.nil?
|
36
|
+
resp = sac.invoke(jsns_builder.to_create)
|
37
|
+
@id = resp[:CreateAccountResponse][:account].first[:id]
|
306
38
|
end
|
307
39
|
|
308
40
|
def created_at
|
309
|
-
@created_at ||= Time.parse
|
41
|
+
@created_at ||= Time.parse(zimbraCreateTimestamp) unless zimbraCreateTimestamp.nil?
|
310
42
|
end
|
311
43
|
|
312
44
|
def flush_cache!
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
45
|
+
soap_request = SoapElement.admin(SoapAdminConstants::FLUSH_CACHE_REQUEST)
|
46
|
+
node_cache = SoapElement.create('cache').add_attributes({ type: SoapConstants::ACCOUNT, allServers: 1 })
|
47
|
+
soap_request.add_node(node_cache)
|
48
|
+
node_entry = SoapElement.create('entry').add_attribute(SoapConstants::BY, SoapConstants::ID).add_content(@id)
|
49
|
+
node_cache.add_node(node_entry)
|
50
|
+
sac.invoke(soap_request)
|
51
|
+
true
|
320
52
|
end
|
321
53
|
|
322
|
-
def
|
323
|
-
|
324
|
-
resp[:Body][:QueryMailboxMoveResponse][:account].nil?
|
54
|
+
def attrs_write
|
55
|
+
@parent.zimbra_attributes.all_account_attrs_writable_names
|
325
56
|
end
|
326
57
|
|
327
|
-
|
328
|
-
@memberships ||= AccountDlsMembershipCollection.new(self)
|
329
|
-
end
|
330
|
-
|
331
|
-
def dls_owner
|
332
|
-
@dls_owner ||= AccountDlsOwnerCollection.new(self)
|
333
|
-
end
|
58
|
+
private
|
334
59
|
|
335
|
-
def
|
336
|
-
|
60
|
+
def do_update!(hash)
|
61
|
+
sac.invoke(jsns_builder.to_patch(hash))
|
337
62
|
end
|
338
63
|
|
339
|
-
def
|
340
|
-
@
|
341
|
-
@zimbraMailQuota = json[:limit] if json[:limit]
|
342
|
-
super(json)
|
64
|
+
def jsns_builder
|
65
|
+
@jsns_builder ||= AccountJsnsBuilder.new(self)
|
343
66
|
end
|
344
67
|
end
|
345
68
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zm
|
4
|
+
module Client
|
5
|
+
# Collection Account Aliases
|
6
|
+
class AccountAliasesCollection
|
7
|
+
def initialize(parent)
|
8
|
+
@parent = parent
|
9
|
+
build_aliases
|
10
|
+
end
|
11
|
+
|
12
|
+
def all
|
13
|
+
@parent.zimbraMailAlias
|
14
|
+
end
|
15
|
+
|
16
|
+
def add!(email)
|
17
|
+
return false if all.include?(Utils.format_email(email))
|
18
|
+
|
19
|
+
soap_request = SoapElement.admin(SoapAdminConstants::ADD_ACCOUNT_ALIAS_REQUEST)
|
20
|
+
soap_request.add_attributes({ id: @parent.id, alias: email })
|
21
|
+
@parent.sac.invoke(soap_request)
|
22
|
+
|
23
|
+
all.push(email)
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def remove!(email)
|
28
|
+
return false unless all.include?(Utils.format_email(email))
|
29
|
+
|
30
|
+
soap_request = SoapElement.admin(SoapAdminConstants::REMOVE_ACCOUNT_ALIAS_REQUEST)
|
31
|
+
soap_request.add_attributes({ id: @parent.id, alias: email })
|
32
|
+
@parent.sac.invoke(soap_request)
|
33
|
+
|
34
|
+
all.delete(email)
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def build_aliases
|
41
|
+
return if @parent.zimbraMailAlias.is_a?(Array)
|
42
|
+
|
43
|
+
if @parent.zimbraMailAlias.nil?
|
44
|
+
@parent.zimbraMailAlias = []
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
48
|
+
@parent.zimbraMailAlias = [@parent.zimbraMailAlias]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -11,7 +11,10 @@ module Zm
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def make_query
|
14
|
-
|
14
|
+
soap_request = SoapElement.admin(SoapAdminConstants::GET_ACCOUNT_MEMBERSHIP_REQUEST)
|
15
|
+
node_account = SoapElement.create(SoapConstants::ACCOUNT).add_attribute(SoapConstants::BY, SoapConstants::ID).add_content(@parent.id)
|
16
|
+
soap_request.add_node(node_account)
|
17
|
+
sac.invoke(soap_request)
|
15
18
|
end
|
16
19
|
|
17
20
|
def build_response
|
@@ -11,7 +11,14 @@ module Zm
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def make_query
|
14
|
-
|
14
|
+
jsns = {
|
15
|
+
query: "(zimbraACE=#{@parent.id} usr ownDistList)",
|
16
|
+
types: SearchType::DL
|
17
|
+
}
|
18
|
+
|
19
|
+
soap_request = SoapElement.admin(SoapAdminConstants::SEARCH_DIRECTORY_REQUEST)
|
20
|
+
soap_request.add_attributes(jsns)
|
21
|
+
@parent.sac.invoke(soap_request)
|
15
22
|
end
|
16
23
|
|
17
24
|
def build_response
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zm
|
4
|
+
module Client
|
5
|
+
# class for account jsns builder
|
6
|
+
class AccountJsnsBuilder
|
7
|
+
def initialize(item)
|
8
|
+
@item = item
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_create
|
12
|
+
req = {
|
13
|
+
name: @item.name,
|
14
|
+
password: @item.password
|
15
|
+
}.reject { |_, v| v.nil? }
|
16
|
+
|
17
|
+
soap_request = SoapElement.admin(SoapAdminConstants::CREATE_ACCOUNT_REQUEST).add_attributes(req)
|
18
|
+
|
19
|
+
attrs_only_set_h.each do |key, values|
|
20
|
+
values.each do |value|
|
21
|
+
node_attr = SoapElement.create(SoapConstants::A).add_attribute(SoapConstants::N, key).add_content(value)
|
22
|
+
soap_request.add_node(node_attr)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
soap_request
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_update
|
30
|
+
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_ACCOUNT_REQUEST).add_attribute(SoapConstants::ID,
|
31
|
+
@item.id)
|
32
|
+
|
33
|
+
attrs_only_set_h.each do |key, values|
|
34
|
+
values.each do |value|
|
35
|
+
node_attr = SoapElement.create(SoapConstants::A).add_attribute(SoapConstants::N, key).add_content(value)
|
36
|
+
soap_request.add_node(node_attr)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
soap_request
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_patch(hash)
|
44
|
+
soap_request = SoapElement.admin(SoapAdminConstants::MODIFY_ACCOUNT_REQUEST).add_attribute(SoapConstants::ID,
|
45
|
+
@item.id)
|
46
|
+
|
47
|
+
hash.each do |key, values|
|
48
|
+
values = [values] unless values.is_a?(Array)
|
49
|
+
values.each do |value|
|
50
|
+
node_attr = SoapElement.create(SoapConstants::A).add_attribute(SoapConstants::N, key).add_content(value)
|
51
|
+
soap_request.add_node(node_attr)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
soap_request
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_delete
|
59
|
+
SoapElement.admin(SoapAdminConstants::DELETE_ACCOUNT_REQUEST).add_attribute('id', @item.id)
|
60
|
+
end
|
61
|
+
|
62
|
+
def attrs_only_set_h
|
63
|
+
selected_attrs = @item.attrs_write.map { |a| Utils.arrow_name_sym(a) }
|
64
|
+
attrs_only_set = @item.instance_variables & selected_attrs
|
65
|
+
|
66
|
+
arr = attrs_only_set.map do |name|
|
67
|
+
n = name.to_s[1..]
|
68
|
+
values = @item.instance_variable_get(name)
|
69
|
+
values = [values] unless values.is_a?(Array)
|
70
|
+
[n, values]
|
71
|
+
end
|
72
|
+
|
73
|
+
Hash[arr]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Zm
|
4
4
|
module Client
|
5
5
|
# class for initialize account
|
6
|
-
class AccountJsnsInitializer
|
6
|
+
class AccountJsnsInitializer < Base::BaseJsnsInitializer
|
7
7
|
class << self
|
8
8
|
def create(parent, json)
|
9
9
|
item = Account.new(parent)
|
@@ -12,29 +12,14 @@ module Zm
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def update(item, json)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
json[:a]&.reject! { |n| n[:n].nil? }
|
24
|
-
# json_map = Hash[json[:a].map { |n| [n[:n], n[:_content]] }].freeze
|
25
|
-
|
26
|
-
# puts json_map
|
27
|
-
|
28
|
-
# item.parent.zimbra_attributes.all_account_attrs.each do |attr|
|
29
|
-
# if attr.type.nil?
|
30
|
-
# # p attr
|
31
|
-
# else
|
32
|
-
# json_field = json_map[attr.name]
|
33
|
-
# puts json_field unless json_field.nil?
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
|
37
|
-
item.init_from_json(json)
|
15
|
+
item.id = json[:id]
|
16
|
+
item.name = json[:name]
|
17
|
+
item.used = json[:used] unless json[:used].nil?
|
18
|
+
item.zimbraMailQuota = json[:limit] unless json[:limit].nil?
|
19
|
+
|
20
|
+
formatted_json(json).each do |k, v|
|
21
|
+
valorise(item, k, v)
|
22
|
+
end
|
38
23
|
|
39
24
|
item
|
40
25
|
end
|
@@ -11,19 +11,43 @@ module Zm
|
|
11
11
|
super(parent)
|
12
12
|
end
|
13
13
|
|
14
|
-
def find_by(hash)
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def find_by!(hash)
|
15
|
+
soap_request = SoapElement.admin(SoapAdminConstants::GET_ACCOUNT_REQUEST)
|
16
|
+
node_account = SoapElement.create(SoapConstants::ACCOUNT).add_attribute(SoapConstants::BY, hash.keys.first).add_content(hash.values.first)
|
17
|
+
soap_request.add_node(node_account)
|
18
|
+
soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma)
|
19
|
+
soap_request.add_attribute(SoapConstants::APPLY_COS, @apply_cos)
|
20
|
+
entry = sac.invoke(soap_request)[:GetAccountResponse][:account].first
|
18
21
|
|
19
22
|
reset_query_params
|
20
|
-
|
23
|
+
AccountJsnsInitializer.create(@parent, entry)
|
21
24
|
end
|
22
25
|
|
23
|
-
def quotas
|
24
|
-
return nil if
|
26
|
+
def quotas(domain_name: @domain_name, target_server_id: @target_server_id)
|
27
|
+
return nil if domain_name.nil? && target_server_id.nil?
|
28
|
+
|
29
|
+
if target_server_id.nil?
|
30
|
+
@all_servers = SoapUtils::ON
|
31
|
+
else
|
32
|
+
sac.context.target_server(target_server_id)
|
33
|
+
end
|
34
|
+
|
35
|
+
jsns = {
|
36
|
+
domain: domain_name,
|
37
|
+
allServers: @all_servers,
|
38
|
+
limit: @limit,
|
39
|
+
offset: @offset,
|
40
|
+
sortBy: @sort_by,
|
41
|
+
sortAscending: @sort_ascending,
|
42
|
+
refresh: @refresh
|
43
|
+
}.delete_if { |_, value| value.nil? }
|
44
|
+
|
45
|
+
soap_request = SoapElement.admin(SoapAdminConstants::GET_QUOTA_USAGE_REQUEST)
|
46
|
+
soap_request.add_attributes(jsns)
|
47
|
+
json = sac.invoke(soap_request)
|
48
|
+
|
49
|
+
sac.context.target_server(nil) unless target_server_id.nil?
|
25
50
|
|
26
|
-
json = sac.get_quota_usage(@domain_name, @all_servers, @limit, @offset, @sort_by, @sort_ascending, @refresh, @target_server_id)
|
27
51
|
reset_query_params
|
28
52
|
@builder_class.new(@parent, json).make
|
29
53
|
end
|