zm-ruby-client 0.14.0 → 0.18.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/.gitignore +1 -0
- data/Gemfile +4 -5
- data/README.md +6 -0
- data/lib/zm/client/account/account.rb +29 -17
- data/lib/zm/client/account/account_jsns_initializer.rb +44 -0
- data/lib/zm/client/account/accounts_builder.rb +6 -3
- data/lib/zm/client/account/accounts_collection.rb +11 -20
- data/lib/zm/client/account.rb +1 -0
- data/lib/zm/client/ace/ace.rb +22 -9
- data/lib/zm/client/ace/ace_jsns_builder.rb +38 -0
- data/lib/zm/client/ace/ace_jsns_initializer.rb +26 -0
- data/lib/zm/client/ace/aces_builder.rb +6 -9
- data/lib/zm/client/ace/aces_collection.rb +23 -9
- data/lib/zm/client/ace.rb +2 -0
- data/lib/zm/client/appointment/appointment.rb +9 -6
- data/lib/zm/client/appointment/appointments_collection.rb +6 -90
- data/lib/zm/client/backup/backup.rb +8 -4
- data/lib/zm/client/base/account_object.rb +34 -0
- data/lib/zm/client/base/account_objects_collection.rb +14 -0
- data/lib/zm/client/base/account_search_objects_collection.rb +125 -0
- data/lib/zm/client/base/admin_object.rb +6 -0
- data/lib/zm/client/base/admin_objects_collection.rb +65 -0
- data/lib/zm/client/base/base_jsns_builder.rb +19 -0
- data/lib/zm/client/base/base_jsns_initializer.rb +29 -0
- data/lib/zm/client/base/folder_object.rb +41 -0
- data/lib/zm/client/base/ldap_filter.rb +33 -0
- data/lib/zm/client/base/object.rb +19 -0
- data/lib/zm/client/base/objects_builder.rb +4 -0
- data/lib/zm/client/base/objects_collection.rb +11 -32
- data/lib/zm/client/base/zimbra_attribute.rb +119 -0
- data/lib/zm/client/base/zimbra_attributes_collection.rb +38 -0
- data/lib/zm/client/base.rb +15 -0
- data/lib/zm/client/cluster/cluster.rb +43 -7
- data/lib/zm/client/cluster/cluster_config.rb +19 -17
- data/lib/zm/client/connector/rest_account.rb +0 -3
- data/lib/zm/client/connector/soap_account.rb +76 -177
- data/lib/zm/client/connector/soap_admin.rb +82 -51
- data/lib/zm/client/connector/soap_base.rb +12 -12
- data/lib/zm/client/contact/contact.rb +2 -1
- data/lib/zm/client/contact/contacts_builder.rb +3 -13
- data/lib/zm/client/contact/contacts_collection.rb +6 -12
- data/lib/zm/client/cos/cos.rb +11 -6
- data/lib/zm/client/cos/coses_builder.rb +1 -16
- data/lib/zm/client/cos/coses_collection.rb +6 -9
- data/lib/zm/client/distributionlist/distributionlist.rb +44 -6
- data/lib/zm/client/distributionlist/distributionlists_builder.rb +2 -17
- data/lib/zm/client/distributionlist/distributionlists_collection.rb +4 -11
- data/lib/zm/client/distributionlist/dls_membership_collection.rb +24 -0
- data/lib/zm/client/distributionlist.rb +1 -0
- data/lib/zm/client/document/document.rb +7 -9
- data/lib/zm/client/domain/domain.rb +11 -6
- data/lib/zm/client/domain/domain_accounts_collection.rb +13 -0
- data/lib/zm/client/domain/domains_builder.rb +1 -19
- data/lib/zm/client/domain/domains_collection.rb +7 -10
- data/lib/zm/client/domain.rb +1 -0
- data/lib/zm/client/folder/folder.rb +50 -124
- data/lib/zm/client/folder/folder_grant.rb +44 -22
- data/lib/zm/client/folder/folder_grant_jsns_builder.rb +43 -0
- data/lib/zm/client/folder/folder_grants_collection.rb +35 -0
- data/lib/zm/client/folder/folder_jsns_builder.rb +132 -0
- data/lib/zm/client/folder/folder_jsns_initializer.rb +49 -0
- data/lib/zm/client/folder/folder_retention_policies_collection.rb +40 -0
- data/lib/zm/client/folder/folder_retention_policy.rb +8 -30
- data/lib/zm/client/folder/folders_builder.rb +2 -2
- data/lib/zm/client/folder/folders_collection.rb +21 -19
- data/lib/zm/client/folder/folders_jsns_builder.rb +22 -0
- data/lib/zm/client/folder.rb +6 -0
- data/lib/zm/client/identity/identities_builder.rb +4 -15
- data/lib/zm/client/identity/identities_collection.rb +7 -13
- data/lib/zm/client/identity/identity.rb +19 -19
- data/lib/zm/client/message/message.rb +111 -21
- data/lib/zm/client/message/messages_builder.rb +1 -1
- data/lib/zm/client/message/messages_collection.rb +10 -92
- data/lib/zm/client/mountpoint/mountpoint.rb +15 -68
- data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +100 -0
- data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +33 -0
- data/lib/zm/client/mountpoint/mountpoints_builder.rb +1 -1
- data/lib/zm/client/mountpoint/mountpoints_collection.rb +14 -23
- data/lib/zm/client/mountpoint.rb +2 -0
- data/lib/zm/client/resource/resource.rb +5 -5
- data/lib/zm/client/resource/resources_builder.rb +1 -16
- data/lib/zm/client/resource/resources_collection.rb +5 -13
- data/lib/zm/client/search_folder/search_folder.rb +19 -39
- data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +86 -0
- data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +33 -0
- data/lib/zm/client/search_folder/search_folders_builder.rb +7 -11
- data/lib/zm/client/search_folder/search_folders_collection.rb +7 -15
- data/lib/zm/client/search_folder.rb +2 -0
- data/lib/zm/client/server/server.rb +7 -14
- data/lib/zm/client/server/server_accounts_collection.rb +19 -0
- data/lib/zm/client/server/servers_builder.rb +4 -16
- data/lib/zm/client/server/servers_collection.rb +5 -10
- data/lib/zm/client/server.rb +1 -0
- data/lib/zm/client/share/share.rb +2 -9
- data/lib/zm/client/share/shares_builder.rb +3 -12
- data/lib/zm/client/signature/signature.rb +17 -13
- data/lib/zm/client/signature/signature_jsns_builder.rb +5 -1
- data/lib/zm/client/signature/signature_jsns_initializer.rb +25 -0
- data/lib/zm/client/signature/signatures_builder.rb +7 -11
- data/lib/zm/client/signature/signatures_collection.rb +6 -14
- data/lib/zm/client/signature.rb +1 -0
- data/lib/zm/client/tag/tag.rb +27 -20
- data/lib/zm/client/tag/tag_jsns_builder.rb +55 -0
- data/lib/zm/client/tag/tag_jsns_initializer.rb +26 -0
- data/lib/zm/client/tag/tags_builder.rb +6 -9
- data/lib/zm/client/tag/tags_collection.rb +6 -12
- data/lib/zm/client/tag.rb +2 -0
- data/lib/zm/client/task/tasks_collection.rb +6 -90
- data/lib/zm/client/upload/upload.rb +1 -1
- data/lib/zm/client/version.rb +1 -1
- data/lib/zm/modules/common/dl_common.rb +3 -1
- data/lib/zm/modules/common/zimbra-attrs.json.bak +1 -0
- data/lib/zm/modules/zm_logger.rb +24 -0
- data/lib/zm/modules/zm_model.rb +41 -0
- data/test/accounts.rb +15 -1
- data/test/ace.rb +50 -0
- data/test/cluster.rb +41 -0
- data/test/cluster_zimbra_attributes.rb +38 -0
- data/test/folder.rb +125 -0
- data/test/folder_grant.rb +51 -0
- data/test/mountpoint.rb +49 -0
- data/test/retention_policies.rb +40 -0
- data/test/search_folder.rb +67 -0
- data/test/signature.rb +53 -0
- data/test/tag.rb +65 -0
- data/test/zimbra_attributes.rb +35 -0
- data/zm-ruby-client.gemspec +15 -10
- metadata +53 -26
- data/lib/zm/client/connector/soap_xml_builder.rb +0 -68
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account folder jsns builder
|
|
6
|
+
class FolderJsnsBuilder < Base::BaseJsnsBuilder
|
|
7
|
+
|
|
8
|
+
def to_find
|
|
9
|
+
{ folder: { l: @item.id } }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def to_jsns
|
|
13
|
+
folder = {
|
|
14
|
+
f: @item.f,
|
|
15
|
+
name: @item.name,
|
|
16
|
+
l: @item.l,
|
|
17
|
+
color: @item.color,
|
|
18
|
+
rgb: @item.rgb,
|
|
19
|
+
url: @item.url,
|
|
20
|
+
fb: @item.fb,
|
|
21
|
+
view: @item.view
|
|
22
|
+
}.delete_if { |_, v| v.nil? }
|
|
23
|
+
|
|
24
|
+
{ folder: folder }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
alias to_create to_jsns
|
|
28
|
+
|
|
29
|
+
def to_update
|
|
30
|
+
action = {
|
|
31
|
+
op: :update,
|
|
32
|
+
id: @item.id,
|
|
33
|
+
f: @item.f,
|
|
34
|
+
name: @item.name,
|
|
35
|
+
l: @item.l,
|
|
36
|
+
color: @item.color,
|
|
37
|
+
rgb: @item.rgb,
|
|
38
|
+
url: @item.url,
|
|
39
|
+
fb: @item.fb,
|
|
40
|
+
view: @item.view
|
|
41
|
+
}.delete_if { |_, v| v.nil? }
|
|
42
|
+
|
|
43
|
+
if @item.is_immutable?
|
|
44
|
+
action.delete(:name)
|
|
45
|
+
action.delete(:l)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
{ action: action }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def to_patch(options)
|
|
52
|
+
action = {
|
|
53
|
+
op: :update,
|
|
54
|
+
id: @item.id
|
|
55
|
+
}.merge(options)
|
|
56
|
+
|
|
57
|
+
{ action: action }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def to_rename
|
|
61
|
+
action = {
|
|
62
|
+
op: :rename,
|
|
63
|
+
id: @item.id,
|
|
64
|
+
name: @item.name
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
{ action: action }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def to_move
|
|
71
|
+
action = {
|
|
72
|
+
op: :move,
|
|
73
|
+
id: @item.id,
|
|
74
|
+
l: @item.l
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
{ action: action }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def to_color
|
|
81
|
+
action = {
|
|
82
|
+
op: :color,
|
|
83
|
+
id: @item.id
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
action[:rgb] = @item.rgb if @item.rgb_changed?
|
|
87
|
+
action[:color] = @item.color if @item.color_changed?
|
|
88
|
+
|
|
89
|
+
{ action: action }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def to_empty
|
|
93
|
+
action = {
|
|
94
|
+
op: :empty,
|
|
95
|
+
id: @item.id,
|
|
96
|
+
recursive: false
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
{ action: action }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def to_delete
|
|
103
|
+
{ action: { op: :delete, id: @item.id } }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def to_retentionpolicy
|
|
107
|
+
retentionpolicy = @item.retention_policies.all.map { |rp| retentionpolicy_jsns(rp) }.reduce({}, :merge)
|
|
108
|
+
|
|
109
|
+
{
|
|
110
|
+
action: {
|
|
111
|
+
op: :retentionpolicy,
|
|
112
|
+
id: @item.id,
|
|
113
|
+
retentionPolicy: retentionpolicy
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
def retentionpolicy_jsns(rp)
|
|
121
|
+
{
|
|
122
|
+
rp.policy => {
|
|
123
|
+
policy: {
|
|
124
|
+
lifetime: rp.lifetime,
|
|
125
|
+
type: rp.type
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for initialize account folder
|
|
6
|
+
class FolderJsnsInitializer
|
|
7
|
+
class << self
|
|
8
|
+
def create(parent, json)
|
|
9
|
+
item = Folder.new(parent)
|
|
10
|
+
|
|
11
|
+
item.instance_variable_set(:@id, json[:id])
|
|
12
|
+
item.instance_variable_set(:@name, json[:name])
|
|
13
|
+
|
|
14
|
+
update(item, json)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def update(item, json)
|
|
18
|
+
item.all_instance_variable_keys.reject { |key| json[key].nil? }.each do |key|
|
|
19
|
+
item.instance_variable_set(arrow_name(key), json[key])
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
if !json[:acl].nil? && json[:acl][:grant].is_a?(Array)
|
|
23
|
+
json[:acl][:grant].each do |json|
|
|
24
|
+
item.grants.create(json[:zid], json[:gt], json[:perm], json[:d])
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
if json[:retentionPolicy].is_a?(Array)
|
|
29
|
+
json[:retentionPolicy].first.map do |policy, v|
|
|
30
|
+
next if v.first[:policy].nil?
|
|
31
|
+
|
|
32
|
+
type = v.first[:policy].first[:type]
|
|
33
|
+
lifetime = v.first[:policy].first[:lifetime]
|
|
34
|
+
item.retention_policies.create(policy, lifetime, type)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
item
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def arrow_name(name)
|
|
42
|
+
return name if name.to_s.start_with?('@')
|
|
43
|
+
|
|
44
|
+
"@#{name}"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for folder retention policies collection
|
|
6
|
+
class FolderRetentionPoliciesCollection
|
|
7
|
+
|
|
8
|
+
attr_reader :all
|
|
9
|
+
|
|
10
|
+
def initialize(parent)
|
|
11
|
+
@parent = parent
|
|
12
|
+
@all = []
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def new(policy, lifetime, type)
|
|
16
|
+
FolderRetentionPolicy.new(self, policy, lifetime, type)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def create(policy, lifetime, type)
|
|
20
|
+
frp = new(policy, lifetime, type)
|
|
21
|
+
add(frp)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def add(retention_policy)
|
|
25
|
+
@all << retention_policy
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def save!
|
|
29
|
+
@parent.sacc.folder_action(@parent.parent.token, jsns_builder.to_retentionpolicy)
|
|
30
|
+
true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def jsns_builder
|
|
36
|
+
@jsns_builder ||= FolderJsnsBuilder.new(@parent)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# class for account folder retention policy
|
|
6
|
-
class FolderRetentionPolicy
|
|
7
|
-
|
|
8
|
-
class << self
|
|
9
|
-
def create_by_json(parent, policy, json)
|
|
10
|
-
frp = self.new(parent)
|
|
11
|
-
frp.init_from_json(policy, json)
|
|
12
|
-
frp
|
|
13
|
-
end
|
|
14
|
-
end
|
|
6
|
+
class FolderRetentionPolicy
|
|
15
7
|
|
|
16
8
|
attr_accessor :type, :policy, :lifetime
|
|
17
9
|
|
|
10
|
+
def initialize(parent, policy, lifetime, type)
|
|
11
|
+
@parent = parent
|
|
12
|
+
@policy = policy
|
|
13
|
+
@lifetime = lifetime
|
|
14
|
+
@type = type
|
|
15
|
+
end
|
|
16
|
+
|
|
18
17
|
def keep?
|
|
19
18
|
@policy == :keep
|
|
20
19
|
end
|
|
@@ -22,27 +21,6 @@ module Zm
|
|
|
22
21
|
def purge?
|
|
23
22
|
@policy == :purge
|
|
24
23
|
end
|
|
25
|
-
|
|
26
|
-
def init_from_json(policy, json)
|
|
27
|
-
return if json.empty? || json[:policy].nil?
|
|
28
|
-
|
|
29
|
-
@policy = policy
|
|
30
|
-
@type = json[:policy].first[:type]
|
|
31
|
-
@lifetime = json[:policy].first[:lifetime]
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def to_h
|
|
35
|
-
# :purge=>[{:policy=>[{:lifetime=>"366d", :type=>"user"}]}]
|
|
36
|
-
{
|
|
37
|
-
@policy => {
|
|
38
|
-
policy: {
|
|
39
|
-
lifetime: @lifetime,
|
|
40
|
-
type: @type
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
end
|
|
45
|
-
|
|
46
24
|
end
|
|
47
25
|
end
|
|
48
26
|
end
|
|
@@ -28,7 +28,7 @@ module Zm
|
|
|
28
28
|
def make
|
|
29
29
|
root = @json[:Body][:GetFolderResponse][@key]
|
|
30
30
|
|
|
31
|
-
@root_folder =
|
|
31
|
+
@root_folder = FolderJsnsInitializer.create(@account, root.first)
|
|
32
32
|
|
|
33
33
|
if !root.first[@key].nil? && root.first[@key].any?
|
|
34
34
|
construct_tree(@root_folder, root.first[@key])
|
|
@@ -39,7 +39,7 @@ module Zm
|
|
|
39
39
|
|
|
40
40
|
def construct_tree(parent_folder, json_folders)
|
|
41
41
|
json_folders.each do |json_folder|
|
|
42
|
-
folder =
|
|
42
|
+
folder = FolderJsnsInitializer.create(@account, json_folder)
|
|
43
43
|
parent_folder.folders << folder
|
|
44
44
|
|
|
45
45
|
construct_tree(folder, json_folder[@key]) if !json_folder[@key].nil? && json_folder[@key].any?
|
|
@@ -3,20 +3,25 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# collection of folders
|
|
6
|
-
class FoldersCollection < Base::
|
|
7
|
-
METHODS_MISSING_LIST = %i[select each map length].to_set.freeze
|
|
6
|
+
class FoldersCollection < Base::AccountObjectsCollection
|
|
8
7
|
|
|
9
8
|
attr_reader :root
|
|
10
9
|
|
|
10
|
+
attr_accessor :view, :tr, :visible, :needGranteeName, :depth
|
|
11
|
+
|
|
11
12
|
def initialize(parent)
|
|
12
|
-
@
|
|
13
|
+
@child_class = Folder
|
|
14
|
+
@builder_class = FoldersBuilder
|
|
15
|
+
super(parent)
|
|
13
16
|
@root = nil
|
|
14
17
|
reset_query_params
|
|
15
18
|
end
|
|
16
19
|
|
|
17
|
-
def
|
|
18
|
-
folder =
|
|
19
|
-
|
|
20
|
+
def find(id)
|
|
21
|
+
folder = @child_class.new(@parent) do |f|
|
|
22
|
+
f.id = id
|
|
23
|
+
end
|
|
24
|
+
folder.reload!
|
|
20
25
|
folder
|
|
21
26
|
end
|
|
22
27
|
|
|
@@ -28,16 +33,7 @@ module Zm
|
|
|
28
33
|
end
|
|
29
34
|
|
|
30
35
|
def ids
|
|
31
|
-
|
|
32
|
-
fb.ids
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def all
|
|
36
|
-
@all || all!
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def all!
|
|
40
|
-
build_response
|
|
36
|
+
@builder_class.new(@parent, make_query).ids
|
|
41
37
|
end
|
|
42
38
|
|
|
43
39
|
def clear
|
|
@@ -74,8 +70,7 @@ module Zm
|
|
|
74
70
|
private
|
|
75
71
|
|
|
76
72
|
def build_response
|
|
77
|
-
|
|
78
|
-
fb = FoldersBuilder.new @parent, rep
|
|
73
|
+
fb = @builder_class.new(@parent, make_query)
|
|
79
74
|
@root = fb.make
|
|
80
75
|
@all = fb.flatten
|
|
81
76
|
@all.select! { |folder| folder.view == @view } unless @view.nil?
|
|
@@ -83,12 +78,19 @@ module Zm
|
|
|
83
78
|
end
|
|
84
79
|
|
|
85
80
|
def make_query
|
|
86
|
-
@parent.sacc.
|
|
81
|
+
@parent.sacc.get_folder(@parent.token, jsns_builder.to_jsns)
|
|
87
82
|
end
|
|
88
83
|
|
|
89
84
|
def reset_query_params
|
|
90
85
|
@view = nil
|
|
91
86
|
@tr = nil
|
|
87
|
+
@visible = nil
|
|
88
|
+
@needGranteeName = nil
|
|
89
|
+
@depth = nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def jsns_builder
|
|
93
|
+
@jsns_builder ||= FoldersJsnsBuilder.new(self)
|
|
92
94
|
end
|
|
93
95
|
end
|
|
94
96
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account collection folders jsns builder
|
|
6
|
+
class FoldersJsnsBuilder
|
|
7
|
+
def initialize(item)
|
|
8
|
+
@item = item
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_jsns
|
|
12
|
+
{
|
|
13
|
+
visible: @item.visible,
|
|
14
|
+
needGranteeName: @item.needGranteeName,
|
|
15
|
+
view: @item.view,
|
|
16
|
+
depth: @item.depth,
|
|
17
|
+
tr: @item.tr
|
|
18
|
+
}.delete_if { |_, v| v.nil? }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/zm/client/folder.rb
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'zm/client/folder/folder'
|
|
4
|
+
require 'zm/client/folder/folder_jsns_builder'
|
|
5
|
+
require 'zm/client/folder/folder_jsns_initializer'
|
|
6
|
+
require 'zm/client/folder/folders_jsns_builder'
|
|
4
7
|
require 'zm/client/folder/folder_grant'
|
|
8
|
+
require 'zm/client/folder/folder_grants_collection'
|
|
9
|
+
require 'zm/client/folder/folder_grant_jsns_builder'
|
|
5
10
|
require 'zm/client/folder/folder_retention_policy'
|
|
11
|
+
require 'zm/client/folder/folder_retention_policies_collection'
|
|
6
12
|
require 'zm/client/folder/folders_builder'
|
|
7
13
|
require 'zm/client/folder/folders_collection'
|
|
8
14
|
require 'zm/client/folder/mod_document_folder'
|
|
@@ -2,23 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
# class factory [
|
|
5
|
+
# class factory [identities]
|
|
6
6
|
class IdentitiesBuilder < Base::ObjectsBuilder
|
|
7
7
|
def initialize(parent, json)
|
|
8
|
-
|
|
9
|
-
@
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def make
|
|
13
|
-
root = @json[:Body][:GetIdentitiesResponse][:identity]
|
|
14
|
-
return [] if root.nil?
|
|
15
|
-
|
|
16
|
-
root = [root] unless root.is_a?(Array)
|
|
17
|
-
root.map do |s|
|
|
18
|
-
identity = Identity.new(@parent)
|
|
19
|
-
identity.init_from_json(s)
|
|
20
|
-
identity
|
|
21
|
-
end
|
|
8
|
+
super(parent, json)
|
|
9
|
+
@child_class = Identity
|
|
10
|
+
@json_item_key = :identity
|
|
22
11
|
end
|
|
23
12
|
end
|
|
24
13
|
end
|
|
@@ -2,24 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
# collection account
|
|
6
|
-
class IdentitiesCollection < Base::
|
|
5
|
+
# collection account identities
|
|
6
|
+
class IdentitiesCollection < Base::AccountObjectsCollection
|
|
7
7
|
def initialize(parent)
|
|
8
|
-
@
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def new
|
|
12
|
-
identity = Identity.new(@parent)
|
|
13
|
-
yield(identity) if block_given?
|
|
14
|
-
identity
|
|
8
|
+
@child_class = Identity
|
|
9
|
+
@builder_class = IdentitiesBuilder
|
|
10
|
+
super(parent)
|
|
15
11
|
end
|
|
16
12
|
|
|
17
13
|
private
|
|
18
14
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
ib = IdentitiesBuilder.new @parent, rep
|
|
22
|
-
ib.make
|
|
15
|
+
def make_query
|
|
16
|
+
@parent.sacc.get_all_identities(@parent.token)
|
|
23
17
|
end
|
|
24
18
|
end
|
|
25
19
|
end
|
|
@@ -4,26 +4,26 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
# class account identity
|
|
6
6
|
class Identity < Base::AccountObject
|
|
7
|
-
|
|
8
7
|
INSTANCE_VARIABLE_KEYS = %i[id name zimbraPrefIdentityName zimbraPrefFromDisplay zimbraPrefFromAddress
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
zimbraPrefFromAddressType zimbraPrefReplyToEnabled zimbraPrefReplyToDisplay zimbraPrefReplyToAddress
|
|
9
|
+
zimbraPrefDefaultSignatureId zimbraPrefForwardReplySignatureId zimbraPrefWhenSentToEnabled
|
|
10
|
+
zimbraPrefWhenInFoldersEnabled zimbraPrefWhenSentToAddresses].freeze
|
|
12
11
|
|
|
13
12
|
ATTRS_WRITE = %i[zimbraPrefIdentityName zimbraPrefFromDisplay zimbraPrefFromAddress
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
zimbraPrefFromAddressType zimbraPrefReplyToEnabled zimbraPrefReplyToDisplay zimbraPrefReplyToAddress
|
|
14
|
+
zimbraPrefDefaultSignatureId zimbraPrefForwardReplySignatureId zimbraPrefWhenSentToEnabled
|
|
15
|
+
zimbraPrefWhenInFoldersEnabled zimbraPrefWhenSentToAddresses].freeze
|
|
17
16
|
|
|
18
|
-
attr_accessor
|
|
17
|
+
attr_accessor(*INSTANCE_VARIABLE_KEYS)
|
|
19
18
|
|
|
20
|
-
def
|
|
21
|
-
INSTANCE_VARIABLE_KEYS
|
|
19
|
+
def all_instance_variable_keys
|
|
20
|
+
INSTANCE_VARIABLE_KEYS
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def init_from_json(json)
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
@id = json[:id]
|
|
25
|
+
@name = json[:name]
|
|
26
|
+
all_instance_variable_keys.each do |key|
|
|
27
27
|
value = json[:_attrs][key]
|
|
28
28
|
next if value.nil?
|
|
29
29
|
|
|
@@ -32,7 +32,7 @@ module Zm
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def create!
|
|
35
|
-
rep = @parent.sacc.create_identity(@parent.token, name, instance_variables_array(ATTRS_WRITE))
|
|
35
|
+
rep = @parent.sacc.create_identity(@parent.token, name, Hash[instance_variables_array(ATTRS_WRITE)])
|
|
36
36
|
init_from_json(rep[:Body][:CreateIdentityResponse][:identity].first)
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -43,9 +43,9 @@ module Zm
|
|
|
43
43
|
arrow_attr_sym = "@#{k}".to_sym
|
|
44
44
|
|
|
45
45
|
if v.respond_to?(:empty?) && v.empty?
|
|
46
|
-
|
|
46
|
+
remove_instance_variable(arrow_attr_sym) if instance_variable_get(arrow_attr_sym)
|
|
47
47
|
else
|
|
48
|
-
|
|
48
|
+
instance_variable_set(arrow_attr_sym, v)
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -55,15 +55,15 @@ module Zm
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def delete!
|
|
58
|
-
@parent.sacc.delete_identity(@parent.token, id)
|
|
58
|
+
@parent.sacc.delete_identity(@parent.token, @id)
|
|
59
|
+
super
|
|
59
60
|
end
|
|
60
61
|
|
|
61
|
-
def rename!(new_name)
|
|
62
|
-
end
|
|
62
|
+
def rename!(new_name); end
|
|
63
63
|
|
|
64
64
|
def clone
|
|
65
65
|
new_identity = super do |obj|
|
|
66
|
-
[
|
|
66
|
+
%i[@zimbraPrefDefaultSignatureId @zimbraPrefForwardReplySignatureId].each do |arrow_key|
|
|
67
67
|
obj.remove_instance_variable(arrow_key) if obj.instance_variable_get(arrow_key)
|
|
68
68
|
end
|
|
69
69
|
end
|