zm-ruby-client 0.14.0 → 0.17.1
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 +1 -0
- 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 +66 -123
- data/lib/zm/client/connector/soap_admin.rb +28 -16
- data/lib/zm/client/connector/soap_base.rb +11 -3
- 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 +9 -5
- 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 +7 -5
- 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 +2 -2
- 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 +1 -0
- metadata +59 -3
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account folder
|
|
6
|
+
class MountpointJsnsBuilder < Base::BaseJsnsBuilder
|
|
7
|
+
|
|
8
|
+
def to_find
|
|
9
|
+
{ link: { l: @item.id } }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def to_jsns
|
|
13
|
+
link = {
|
|
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
|
+
zid: @item.zid,
|
|
23
|
+
rid: @item.rid
|
|
24
|
+
}.delete_if { |_, v| v.nil? }
|
|
25
|
+
|
|
26
|
+
{ link: link }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
alias to_create to_jsns
|
|
30
|
+
|
|
31
|
+
def to_update
|
|
32
|
+
action = {
|
|
33
|
+
op: :update,
|
|
34
|
+
id: @item.id,
|
|
35
|
+
f: @item.f,
|
|
36
|
+
name: @item.name,
|
|
37
|
+
l: @item.l,
|
|
38
|
+
color: @item.color,
|
|
39
|
+
rgb: @item.rgb,
|
|
40
|
+
url: @item.url,
|
|
41
|
+
fb: @item.fb,
|
|
42
|
+
view: @item.view
|
|
43
|
+
}.delete_if { |_, v| v.nil? }
|
|
44
|
+
|
|
45
|
+
if @item.is_immutable?
|
|
46
|
+
action.delete(:name)
|
|
47
|
+
action.delete(:l)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
{ action: action }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def to_rename
|
|
54
|
+
action = {
|
|
55
|
+
op: :rename,
|
|
56
|
+
id: @item.id,
|
|
57
|
+
name: @item.name
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
{ action: action }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def to_move
|
|
64
|
+
action = {
|
|
65
|
+
op: :move,
|
|
66
|
+
id: @item.id,
|
|
67
|
+
l: @item.l
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
{ action: action }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def to_color
|
|
74
|
+
action = {
|
|
75
|
+
op: :color,
|
|
76
|
+
id: @item.id
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
action[:rgb] = @item.rgb if @item.rgb_changed?
|
|
80
|
+
action[:color] = @item.color if @item.color_changed?
|
|
81
|
+
|
|
82
|
+
{ action: action }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def to_empty
|
|
86
|
+
action = {
|
|
87
|
+
op: :empty,
|
|
88
|
+
id: @item.id,
|
|
89
|
+
recursive: false
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
{ action: action }
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def to_delete
|
|
96
|
+
{ action: { op: :delete, id: @item.id } }
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for initialize account mountpoint
|
|
6
|
+
class MountpointJsnsInitializer
|
|
7
|
+
class << self
|
|
8
|
+
def create(parent, json)
|
|
9
|
+
item = MountPoint.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
|
+
item
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def arrow_name(name)
|
|
26
|
+
return name if name.to_s.start_with?('@')
|
|
27
|
+
|
|
28
|
+
"@#{name}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -3,23 +3,20 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# collection of mountpoints
|
|
6
|
-
class MountPointsCollection < Base::
|
|
7
|
-
METHODS_MISSING_LIST = %i[select each map length].to_set.freeze
|
|
6
|
+
class MountPointsCollection < 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 = MountPoint
|
|
14
|
+
@builder_class = MountPointsBuilder
|
|
15
|
+
super(parent)
|
|
13
16
|
@root = nil
|
|
14
17
|
reset_query_params
|
|
15
18
|
end
|
|
16
19
|
|
|
17
|
-
def new
|
|
18
|
-
mountpoint = MountPoint.new(@parent)
|
|
19
|
-
yield(mountpoint) if block_given?
|
|
20
|
-
mountpoint
|
|
21
|
-
end
|
|
22
|
-
|
|
23
20
|
def where(view: nil, tr: nil)
|
|
24
21
|
@view = view
|
|
25
22
|
@tr = tr
|
|
@@ -27,14 +24,6 @@ module Zm
|
|
|
27
24
|
self
|
|
28
25
|
end
|
|
29
26
|
|
|
30
|
-
def all
|
|
31
|
-
@all || all!
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def all!
|
|
35
|
-
build_response
|
|
36
|
-
end
|
|
37
|
-
|
|
38
27
|
def clear
|
|
39
28
|
@all = nil
|
|
40
29
|
@root = nil
|
|
@@ -43,18 +32,20 @@ module Zm
|
|
|
43
32
|
|
|
44
33
|
private
|
|
45
34
|
|
|
46
|
-
def build_response
|
|
47
|
-
@all = MountPointsBuilder.new(@parent, make_query).make
|
|
48
|
-
@all
|
|
49
|
-
end
|
|
50
|
-
|
|
51
35
|
def make_query
|
|
52
|
-
@parent.sacc.
|
|
36
|
+
@parent.sacc.get_folder(@parent.token, jsns_builder.to_jsns)
|
|
53
37
|
end
|
|
54
38
|
|
|
55
39
|
def reset_query_params
|
|
56
40
|
@view = nil
|
|
57
41
|
@tr = nil
|
|
42
|
+
@visible = nil
|
|
43
|
+
@needGranteeName = nil
|
|
44
|
+
@depth = nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def jsns_builder
|
|
48
|
+
@jsns_builder ||= FoldersJsnsBuilder.new(self)
|
|
58
49
|
end
|
|
59
50
|
end
|
|
60
51
|
end
|
data/lib/zm/client/mountpoint.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'zm/client/mountpoint/mountpoint'
|
|
4
|
+
require 'zm/client/mountpoint/mountpoint_jsns_builder'
|
|
5
|
+
require 'zm/client/mountpoint/mountpoint_jsns_initializer'
|
|
4
6
|
require 'zm/client/mountpoint/mountpoints_builder'
|
|
5
7
|
require 'zm/client/mountpoint/mountpoints_collection'
|
|
@@ -15,11 +15,11 @@ module Zm
|
|
|
15
15
|
@grantee_type = 'usr'.freeze
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def to_h
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
end
|
|
18
|
+
# def to_h
|
|
19
|
+
# hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
|
|
20
|
+
# hashmap.delete_if { |_, v| v.nil? }
|
|
21
|
+
# hashmap
|
|
22
|
+
# end
|
|
23
23
|
|
|
24
24
|
def all_instance_variable_keys
|
|
25
25
|
ResourceCommon::ALL_ATTRS
|
|
@@ -7,22 +7,7 @@ module Zm
|
|
|
7
7
|
def initialize(parent, json)
|
|
8
8
|
super(parent, json)
|
|
9
9
|
@child_class = Resource
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# def make
|
|
13
|
-
# return [] if json_items.nil?
|
|
14
|
-
#
|
|
15
|
-
# json_items.map do |entry|
|
|
16
|
-
# resource = Resource.new(@parent)
|
|
17
|
-
# resource.init_from_json(entry)
|
|
18
|
-
# resource
|
|
19
|
-
# end
|
|
20
|
-
# end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def json_items
|
|
25
|
-
@json_items ||= @json[:Body][json_key][:calresource]
|
|
10
|
+
@json_item_key = :calresource
|
|
26
11
|
end
|
|
27
12
|
end
|
|
28
13
|
end
|
|
@@ -3,34 +3,26 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# Collection Resources
|
|
6
|
-
class ResourcesCollection < Base::
|
|
6
|
+
class ResourcesCollection < Base::AdminObjectsCollection
|
|
7
7
|
def initialize(parent)
|
|
8
8
|
@child_class = Resource
|
|
9
|
-
@
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def ldap
|
|
14
|
-
@apply_cos = 0
|
|
15
|
-
self
|
|
9
|
+
@builder_class = ResourcesBuilder
|
|
10
|
+
@search_type = SearchType::RESOURCE
|
|
11
|
+
super(parent)
|
|
16
12
|
end
|
|
17
13
|
|
|
18
14
|
def find_by(hash)
|
|
19
15
|
rep = sac.get_resource(hash.values.first, hash.keys.first, attrs_comma)
|
|
20
16
|
entry = rep[:Body][:GetCalendarResourceResponse][:calresource].first
|
|
21
17
|
|
|
18
|
+
reset_query_params
|
|
22
19
|
build_from_entry(entry)
|
|
23
20
|
end
|
|
24
21
|
|
|
25
22
|
private
|
|
26
23
|
|
|
27
|
-
def build_response
|
|
28
|
-
ResourcesBuilder.new(@parent, make_query).make
|
|
29
|
-
end
|
|
30
|
-
|
|
31
24
|
def reset_query_params
|
|
32
25
|
super
|
|
33
|
-
@search_type = SearchType::RESOURCE
|
|
34
26
|
@attrs = SearchType::Attributes::RESOURCE.dup
|
|
35
27
|
@all_servers = 1
|
|
36
28
|
@refresh = 0
|
|
@@ -3,60 +3,40 @@
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
5
|
# class account SearchFolder
|
|
6
|
-
class SearchFolder < Base::
|
|
6
|
+
class SearchFolder < Base::FolderObject
|
|
7
|
+
include Zm::Model::AttributeChangeObserver
|
|
7
8
|
|
|
8
9
|
INSTANCE_VARIABLE_KEYS = %i[id uuid deletable name absFolderPath l luuid color rgb rev ms webOfflineSyncDays activesyncdisabled query sortBy types]
|
|
9
10
|
|
|
10
|
-
attr_accessor *INSTANCE_VARIABLE_KEYS
|
|
11
|
+
# attr_accessor *INSTANCE_VARIABLE_KEYS
|
|
12
|
+
attr_reader :id, :absFolderPath, :types
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
define_changed_attributes :name, :color, :rgb, :l, :query, :sortBy
|
|
15
|
+
|
|
16
|
+
def initialize(parent)
|
|
17
|
+
super(parent)
|
|
18
|
+
@types = 'messages'
|
|
14
19
|
end
|
|
15
20
|
|
|
16
|
-
def
|
|
17
|
-
INSTANCE_VARIABLE_KEYS
|
|
18
|
-
var_name = "@#{key}"
|
|
19
|
-
instance_variable_set(var_name, json[key])
|
|
20
|
-
end
|
|
21
|
+
def all_instance_variable_keys
|
|
22
|
+
INSTANCE_VARIABLE_KEYS
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def create!
|
|
24
|
-
rep = @parent.sacc.create_search_folder(@parent.token,
|
|
25
|
-
|
|
26
|
+
rep = @parent.sacc.create_search_folder(@parent.token, jsns_builder.to_jsns)
|
|
27
|
+
json = rep[:Body][:CreateSearchFolderResponse][:search].first
|
|
28
|
+
SearchFolderJsnsInitializer.update(self, json)
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
def modify!
|
|
29
|
-
@parent.sacc.modify_search_folder(@parent.token,
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def query!(new_query)
|
|
34
|
-
@parent.sacc.modify_search_folder(@parent.token, id, new_query, types)
|
|
35
|
-
instance_variable_set("@query", new_query)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def color!(new_color)
|
|
39
|
-
key = new_color.to_i.zero? ? :rgb : :color
|
|
40
|
-
options = {}
|
|
41
|
-
options[key] = new_color
|
|
42
|
-
@parent.sacc.folder_action(@parent.token, :color, @id, options)
|
|
43
|
-
instance_variable_set("@#{key}", new_color)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def build_update_options
|
|
47
|
-
{
|
|
48
|
-
name: @name,
|
|
49
|
-
color: @color,
|
|
50
|
-
rgb: @rgb
|
|
51
|
-
}.delete_if { |_, v| v.nil? }
|
|
32
|
+
@parent.sacc.modify_search_folder(@parent.token, jsns_builder.to_modify)
|
|
33
|
+
super
|
|
52
34
|
end
|
|
53
35
|
|
|
54
|
-
|
|
55
|
-
@parent.sacc.folder_action(@parent.token, :delete, id)
|
|
56
|
-
end
|
|
36
|
+
private
|
|
57
37
|
|
|
58
|
-
def
|
|
59
|
-
|
|
38
|
+
def jsns_builder
|
|
39
|
+
@jsns_builder ||= SearchFolderJsnsBuilder.new(self)
|
|
60
40
|
end
|
|
61
41
|
end
|
|
62
42
|
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for account search folder jsns builder
|
|
6
|
+
class SearchFolderJsnsBuilder
|
|
7
|
+
|
|
8
|
+
def initialize(search_folder)
|
|
9
|
+
@item = search_folder
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def to_jsns
|
|
13
|
+
search = {
|
|
14
|
+
name: @item.name,
|
|
15
|
+
query: @item.query,
|
|
16
|
+
types: @item.types,
|
|
17
|
+
l: @item.l,
|
|
18
|
+
color: @item.color,
|
|
19
|
+
sortBy: @item.sortBy
|
|
20
|
+
}.delete_if { |_, v| v.nil? }
|
|
21
|
+
|
|
22
|
+
{ search: search }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
alias to_create to_jsns
|
|
26
|
+
|
|
27
|
+
def to_modify
|
|
28
|
+
search = {
|
|
29
|
+
id: @item.id,
|
|
30
|
+
query: @item.query,
|
|
31
|
+
types: @item.types
|
|
32
|
+
}.reject { |_, v| v.nil? }
|
|
33
|
+
|
|
34
|
+
{ search: search }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_update
|
|
38
|
+
action = {
|
|
39
|
+
op: :update,
|
|
40
|
+
id: @item.id,
|
|
41
|
+
name: @item.name,
|
|
42
|
+
color: @item.color,
|
|
43
|
+
rgb: @item.rgb
|
|
44
|
+
}.reject { |_, v| v.nil? }
|
|
45
|
+
|
|
46
|
+
{ action: action }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def to_rename
|
|
50
|
+
action = {
|
|
51
|
+
op: :rename,
|
|
52
|
+
id: @item.id,
|
|
53
|
+
name: @item.name
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
{ action: action }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def to_move
|
|
60
|
+
action = {
|
|
61
|
+
op: :move,
|
|
62
|
+
id: @item.id,
|
|
63
|
+
l: @item.l
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
{ action: action }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def to_color
|
|
70
|
+
action = {
|
|
71
|
+
op: :color,
|
|
72
|
+
id: @item.id
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
action[:rgb] = @item.rgb if @item.rgb_changed?
|
|
76
|
+
action[:color] = @item.color if @item.color_changed?
|
|
77
|
+
|
|
78
|
+
{ action: action }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def to_delete
|
|
82
|
+
{ action: { op: :delete, id: @item.id } }
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# class for initialize account search folder
|
|
6
|
+
class SearchFolderJsnsInitializer
|
|
7
|
+
class << self
|
|
8
|
+
def create(parent, json)
|
|
9
|
+
item = SearchFolder.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
|
+
item
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def arrow_name(name)
|
|
26
|
+
return name if name.to_s.start_with?('@')
|
|
27
|
+
|
|
28
|
+
"@#{name}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -2,23 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
# class factory [folders]
|
|
5
|
+
# class factory [Search folders]
|
|
6
6
|
class SearchFoldersBuilder < Base::ObjectsBuilder
|
|
7
7
|
def initialize(parent, json)
|
|
8
|
-
|
|
9
|
-
@
|
|
8
|
+
super(parent, json)
|
|
9
|
+
@child_class = SearchFolder
|
|
10
|
+
@json_item_key = :search
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def make
|
|
13
|
-
|
|
14
|
-
return [] if root.nil?
|
|
14
|
+
return [] if json_items.nil?
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
root.map do |s|
|
|
19
|
-
f = SearchFolder.new(@parent)
|
|
20
|
-
f.init_from_json(s)
|
|
21
|
-
f
|
|
16
|
+
json_items.map do |entry|
|
|
17
|
+
SearchFolderJsnsInitializer.create(@parent, entry)
|
|
22
18
|
end
|
|
23
19
|
end
|
|
24
20
|
end
|
|
@@ -2,26 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
module Zm
|
|
4
4
|
module Client
|
|
5
|
-
# collection of folders
|
|
6
|
-
class SearchFoldersCollection < Base::
|
|
7
|
-
METHODS_MISSING_LIST = %i[select each map length].to_set.freeze
|
|
8
|
-
|
|
5
|
+
# collection of search folders
|
|
6
|
+
class SearchFoldersCollection < Base::AccountObjectsCollection
|
|
9
7
|
def initialize(parent)
|
|
10
|
-
@
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def new
|
|
14
|
-
folder = SearchFolder.new(@parent)
|
|
15
|
-
yield(folder) if block_given?
|
|
16
|
-
folder
|
|
8
|
+
@child_class = SearchFolder
|
|
9
|
+
@builder_class = SearchFoldersBuilder
|
|
10
|
+
super(parent)
|
|
17
11
|
end
|
|
18
12
|
|
|
19
13
|
private
|
|
20
14
|
|
|
21
|
-
def
|
|
22
|
-
|
|
23
|
-
fb = SearchFoldersBuilder.new @parent, rep
|
|
24
|
-
fb.make
|
|
15
|
+
def make_query
|
|
16
|
+
@parent.sacc.get_all_search_folders(@parent.token)
|
|
25
17
|
end
|
|
26
18
|
end
|
|
27
19
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'zm/client/search_folder/search_folder'
|
|
4
|
+
require 'zm/client/search_folder/search_folder_jsns_builder'
|
|
5
|
+
require 'zm/client/search_folder/search_folder_jsns_initializer'
|
|
4
6
|
require 'zm/client/search_folder/search_folders_builder'
|
|
5
7
|
require 'zm/client/search_folder/search_folders_collection'
|
|
@@ -481,6 +481,10 @@ module Zm
|
|
|
481
481
|
attr_accessor *INSTANCE_VARIABLE_KEYS
|
|
482
482
|
attr_accessor :name, :id
|
|
483
483
|
|
|
484
|
+
def all_instance_variable_keys
|
|
485
|
+
INSTANCE_VARIABLE_KEYS
|
|
486
|
+
end
|
|
487
|
+
|
|
484
488
|
def mta_queues
|
|
485
489
|
@mta_queues ||= mta_queues!
|
|
486
490
|
end
|
|
@@ -497,20 +501,9 @@ module Zm
|
|
|
497
501
|
BackupsCollection.new self
|
|
498
502
|
end
|
|
499
503
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
# def quotas
|
|
505
|
-
# # todo
|
|
506
|
-
# rep = @soap_admin_connector.get_quota_usage(name, 1)
|
|
507
|
-
# AccountsBuilder.new(@soap_admin_connector, rep).make
|
|
508
|
-
# end
|
|
509
|
-
|
|
510
|
-
# def quotas!
|
|
511
|
-
# @accounts = quotas
|
|
512
|
-
# # todo il faudrait merger quotas dans @accounts
|
|
513
|
-
# end
|
|
504
|
+
def accounts
|
|
505
|
+
@accounts ||= ServerAccountsCollection.new(self)
|
|
506
|
+
end
|
|
514
507
|
end
|
|
515
508
|
end
|
|
516
509
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zm
|
|
4
|
+
module Client
|
|
5
|
+
# Collection Accounts from server
|
|
6
|
+
class ServerAccountsCollection < AccountsCollection
|
|
7
|
+
def initialize(parent)
|
|
8
|
+
@target_server_id = parent.id
|
|
9
|
+
super(parent)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def ldap_filter
|
|
15
|
+
@ldap_filter ||= LdapFilter.new("(zimbraMailHost=#{@parent.name})")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -4,22 +4,10 @@ module Zm
|
|
|
4
4
|
module Client
|
|
5
5
|
# class factory [servers]
|
|
6
6
|
class ServersBuilder < Base::ObjectsBuilder
|
|
7
|
-
def
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
server = Server.new(@parent)
|
|
12
|
-
server.init_from_json(entry)
|
|
13
|
-
server
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
servers
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def json_items
|
|
22
|
-
@json_items ||= @json[:Body][json_key][:server]
|
|
7
|
+
def initialize(parent, json)
|
|
8
|
+
super(parent, json)
|
|
9
|
+
@child_class = Server
|
|
10
|
+
@json_item_key = :server
|
|
23
11
|
end
|
|
24
12
|
end
|
|
25
13
|
end
|