zm-ruby-client 0.14.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +4 -5
  4. data/README.md +6 -0
  5. data/lib/zm/client/account/account.rb +29 -17
  6. data/lib/zm/client/account/account_jsns_initializer.rb +44 -0
  7. data/lib/zm/client/account/accounts_builder.rb +6 -3
  8. data/lib/zm/client/account/accounts_collection.rb +11 -20
  9. data/lib/zm/client/account.rb +1 -0
  10. data/lib/zm/client/ace/ace.rb +22 -9
  11. data/lib/zm/client/ace/ace_jsns_builder.rb +38 -0
  12. data/lib/zm/client/ace/ace_jsns_initializer.rb +26 -0
  13. data/lib/zm/client/ace/aces_builder.rb +6 -9
  14. data/lib/zm/client/ace/aces_collection.rb +23 -9
  15. data/lib/zm/client/ace.rb +2 -0
  16. data/lib/zm/client/appointment/appointment.rb +9 -6
  17. data/lib/zm/client/appointment/appointments_collection.rb +6 -90
  18. data/lib/zm/client/backup/backup.rb +8 -4
  19. data/lib/zm/client/base/account_object.rb +34 -0
  20. data/lib/zm/client/base/account_objects_collection.rb +14 -0
  21. data/lib/zm/client/base/account_search_objects_collection.rb +125 -0
  22. data/lib/zm/client/base/admin_object.rb +6 -0
  23. data/lib/zm/client/base/admin_objects_collection.rb +65 -0
  24. data/lib/zm/client/base/base_jsns_builder.rb +19 -0
  25. data/lib/zm/client/base/base_jsns_initializer.rb +29 -0
  26. data/lib/zm/client/base/folder_object.rb +41 -0
  27. data/lib/zm/client/base/ldap_filter.rb +33 -0
  28. data/lib/zm/client/base/object.rb +19 -0
  29. data/lib/zm/client/base/objects_builder.rb +4 -0
  30. data/lib/zm/client/base/objects_collection.rb +11 -32
  31. data/lib/zm/client/base/zimbra_attribute.rb +119 -0
  32. data/lib/zm/client/base/zimbra_attributes_collection.rb +38 -0
  33. data/lib/zm/client/base.rb +15 -0
  34. data/lib/zm/client/cluster/cluster.rb +43 -7
  35. data/lib/zm/client/cluster/cluster_config.rb +19 -17
  36. data/lib/zm/client/connector/rest_account.rb +0 -3
  37. data/lib/zm/client/connector/soap_account.rb +76 -177
  38. data/lib/zm/client/connector/soap_admin.rb +82 -51
  39. data/lib/zm/client/connector/soap_base.rb +12 -12
  40. data/lib/zm/client/contact/contact.rb +2 -1
  41. data/lib/zm/client/contact/contacts_builder.rb +3 -13
  42. data/lib/zm/client/contact/contacts_collection.rb +6 -12
  43. data/lib/zm/client/cos/cos.rb +11 -6
  44. data/lib/zm/client/cos/coses_builder.rb +1 -16
  45. data/lib/zm/client/cos/coses_collection.rb +6 -9
  46. data/lib/zm/client/distributionlist/distributionlist.rb +44 -6
  47. data/lib/zm/client/distributionlist/distributionlists_builder.rb +2 -17
  48. data/lib/zm/client/distributionlist/distributionlists_collection.rb +4 -11
  49. data/lib/zm/client/distributionlist/dls_membership_collection.rb +24 -0
  50. data/lib/zm/client/distributionlist.rb +1 -0
  51. data/lib/zm/client/document/document.rb +7 -9
  52. data/lib/zm/client/domain/domain.rb +11 -6
  53. data/lib/zm/client/domain/domain_accounts_collection.rb +13 -0
  54. data/lib/zm/client/domain/domains_builder.rb +1 -19
  55. data/lib/zm/client/domain/domains_collection.rb +7 -10
  56. data/lib/zm/client/domain.rb +1 -0
  57. data/lib/zm/client/folder/folder.rb +50 -124
  58. data/lib/zm/client/folder/folder_grant.rb +44 -22
  59. data/lib/zm/client/folder/folder_grant_jsns_builder.rb +43 -0
  60. data/lib/zm/client/folder/folder_grants_collection.rb +35 -0
  61. data/lib/zm/client/folder/folder_jsns_builder.rb +132 -0
  62. data/lib/zm/client/folder/folder_jsns_initializer.rb +49 -0
  63. data/lib/zm/client/folder/folder_retention_policies_collection.rb +40 -0
  64. data/lib/zm/client/folder/folder_retention_policy.rb +8 -30
  65. data/lib/zm/client/folder/folders_builder.rb +2 -2
  66. data/lib/zm/client/folder/folders_collection.rb +21 -19
  67. data/lib/zm/client/folder/folders_jsns_builder.rb +22 -0
  68. data/lib/zm/client/folder.rb +6 -0
  69. data/lib/zm/client/identity/identities_builder.rb +4 -15
  70. data/lib/zm/client/identity/identities_collection.rb +7 -13
  71. data/lib/zm/client/identity/identity.rb +19 -19
  72. data/lib/zm/client/message/message.rb +111 -21
  73. data/lib/zm/client/message/messages_builder.rb +1 -1
  74. data/lib/zm/client/message/messages_collection.rb +10 -92
  75. data/lib/zm/client/mountpoint/mountpoint.rb +15 -68
  76. data/lib/zm/client/mountpoint/mountpoint_jsns_builder.rb +100 -0
  77. data/lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb +33 -0
  78. data/lib/zm/client/mountpoint/mountpoints_builder.rb +1 -1
  79. data/lib/zm/client/mountpoint/mountpoints_collection.rb +14 -23
  80. data/lib/zm/client/mountpoint.rb +2 -0
  81. data/lib/zm/client/resource/resource.rb +5 -5
  82. data/lib/zm/client/resource/resources_builder.rb +1 -16
  83. data/lib/zm/client/resource/resources_collection.rb +5 -13
  84. data/lib/zm/client/search_folder/search_folder.rb +19 -39
  85. data/lib/zm/client/search_folder/search_folder_jsns_builder.rb +86 -0
  86. data/lib/zm/client/search_folder/search_folder_jsns_initializer.rb +33 -0
  87. data/lib/zm/client/search_folder/search_folders_builder.rb +7 -11
  88. data/lib/zm/client/search_folder/search_folders_collection.rb +7 -15
  89. data/lib/zm/client/search_folder.rb +2 -0
  90. data/lib/zm/client/server/server.rb +7 -14
  91. data/lib/zm/client/server/server_accounts_collection.rb +19 -0
  92. data/lib/zm/client/server/servers_builder.rb +4 -16
  93. data/lib/zm/client/server/servers_collection.rb +5 -10
  94. data/lib/zm/client/server.rb +1 -0
  95. data/lib/zm/client/share/share.rb +2 -9
  96. data/lib/zm/client/share/shares_builder.rb +3 -12
  97. data/lib/zm/client/signature/signature.rb +17 -13
  98. data/lib/zm/client/signature/signature_jsns_builder.rb +5 -1
  99. data/lib/zm/client/signature/signature_jsns_initializer.rb +25 -0
  100. data/lib/zm/client/signature/signatures_builder.rb +7 -11
  101. data/lib/zm/client/signature/signatures_collection.rb +6 -14
  102. data/lib/zm/client/signature.rb +1 -0
  103. data/lib/zm/client/tag/tag.rb +27 -20
  104. data/lib/zm/client/tag/tag_jsns_builder.rb +55 -0
  105. data/lib/zm/client/tag/tag_jsns_initializer.rb +26 -0
  106. data/lib/zm/client/tag/tags_builder.rb +6 -9
  107. data/lib/zm/client/tag/tags_collection.rb +6 -12
  108. data/lib/zm/client/tag.rb +2 -0
  109. data/lib/zm/client/task/tasks_collection.rb +6 -90
  110. data/lib/zm/client/upload/upload.rb +1 -1
  111. data/lib/zm/client/version.rb +1 -1
  112. data/lib/zm/modules/common/dl_common.rb +3 -1
  113. data/lib/zm/modules/common/zimbra-attrs.json.bak +1 -0
  114. data/lib/zm/modules/zm_logger.rb +24 -0
  115. data/lib/zm/modules/zm_model.rb +41 -0
  116. data/test/accounts.rb +15 -1
  117. data/test/ace.rb +50 -0
  118. data/test/cluster.rb +41 -0
  119. data/test/cluster_zimbra_attributes.rb +38 -0
  120. data/test/folder.rb +125 -0
  121. data/test/folder_grant.rb +51 -0
  122. data/test/mountpoint.rb +49 -0
  123. data/test/retention_policies.rb +40 -0
  124. data/test/search_folder.rb +67 -0
  125. data/test/signature.rb +53 -0
  126. data/test/tag.rb +65 -0
  127. data/test/zimbra_attributes.rb +35 -0
  128. data/zm-ruby-client.gemspec +15 -10
  129. metadata +53 -26
  130. data/lib/zm/client/connector/soap_xml_builder.rb +0 -68
@@ -11,6 +11,40 @@ module Zm
11
11
  end
12
12
 
13
13
  alias sacc soap_account_connector
14
+
15
+ def concat
16
+ all_instance_variable_keys.map { |key| instance_variable_get(arrow_name(key)) }
17
+ end
18
+
19
+ def init_from_json(json)
20
+ all_instance_variable_keys.each do |key|
21
+ next if json[key].nil?
22
+ instance_variable_set(arrow_name(key), json[key])
23
+ end
24
+ end
25
+
26
+ def to_h
27
+ hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
28
+ hashmap.delete_if { |_, v| v.nil? }
29
+ hashmap
30
+ end
31
+
32
+ def create!
33
+ @id
34
+ end
35
+
36
+ def modify!
37
+ rename!
38
+ true
39
+ end
40
+
41
+ def rename!
42
+ true
43
+ end
44
+
45
+ def delete!
46
+ remove_instance_variable(:@id)
47
+ end
14
48
  end
15
49
  end
16
50
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module Base
6
+ # Collection AccountObjectsCollection
7
+ class AccountObjectsCollection < ObjectsCollection
8
+ def initialize(parent)
9
+ @parent = parent
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module Base
6
+ # Collection AccountSearchObjectsCollection
7
+ class AccountSearchObjectsCollection < AccountObjectsCollection
8
+ attr_accessor :more
9
+
10
+ def initialize(parent)
11
+ super(parent)
12
+ @more = true
13
+ reset_query_params
14
+ end
15
+
16
+ def find(id)
17
+ rep = @parent.sacc.get_msg(@parent.token, id, { html: 1 })
18
+ entry = rep[:Body][:GetMsgResponse][:m].first
19
+
20
+ msg = @child_class.new(@parent)
21
+ msg.init_from_json(entry)
22
+ msg
23
+ end
24
+
25
+ def start_at(start_at)
26
+ @start_at = start_at
27
+ self
28
+ end
29
+
30
+ def end_at(end_at)
31
+ @end_at = end_at
32
+ self
33
+ end
34
+
35
+ def folders(folders)
36
+ @folders = folders
37
+ @folder_ids = @folders.map(&:id)
38
+ self
39
+ end
40
+
41
+ def folder_ids(folder_ids)
42
+ @folder_ids = folder_ids
43
+ self
44
+ end
45
+
46
+ def where(query)
47
+ @query = query
48
+ self
49
+ end
50
+
51
+ def order(sort_by)
52
+ return self if @sort_by == sort_by
53
+
54
+ @all = nil
55
+ @sort_by = sort_by
56
+ self
57
+ end
58
+
59
+ def ids
60
+ @options = { resultMode: 1 }
61
+ search_builder.ids
62
+ end
63
+
64
+ def reset
65
+ reset_query_params
66
+ end
67
+
68
+ private
69
+
70
+ def make_query
71
+ @parent.sacc.search(@parent.token, @type, @offset, @limit, @sort_by, query, build_options)
72
+ end
73
+
74
+ def search_builder
75
+ @builder_class.new(@parent, search_response)
76
+ end
77
+
78
+ def search_response
79
+ rep = make_query
80
+ @more = rep[:Body][:SearchResponse][:more]
81
+ rep
82
+ end
83
+
84
+ def build_response
85
+ items = search_builder.make
86
+ items.each { |item| item.folder = find_folder(item) } unless @folders.empty?
87
+ items
88
+ end
89
+
90
+ def find_folder(item)
91
+ @folders.find { |folder| folder.id == item.l }
92
+ end
93
+
94
+ def query
95
+ return @query unless @query.nil?
96
+
97
+ return nil if @folder_ids.empty?
98
+
99
+ @folder_ids.map { |id| %Q{inid:"#{id}"} }.join(' OR ')
100
+ end
101
+
102
+ def build_options
103
+ start_at_ts = @start_at.is_a?(Time) ? (@start_at.to_f * 1000).to_i : nil
104
+ end_at_ts = @end_at.is_a?(Time) ? (@end_at.to_f * 1000).to_i : nil
105
+
106
+ {
107
+ resultMode: @resultMode,
108
+ calExpandInstStart: start_at_ts,
109
+ calExpandInstEnd: end_at_ts,
110
+ }.delete_if { |_, v| v.nil? }
111
+ end
112
+
113
+ def reset_query_params
114
+ super
115
+ @resultMode = 'NORMAL'
116
+ @start_at = nil
117
+ @end_at = nil
118
+ @query = nil
119
+ @folder_ids = []
120
+ @folders = []
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -20,6 +20,12 @@ module Zm
20
20
 
21
21
  alias sacc soap_account_connector
22
22
 
23
+ def to_h
24
+ hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
25
+ hashmap.delete_if { |_, v| v.nil? }
26
+ hashmap
27
+ end
28
+
23
29
  def init_from_json(json)
24
30
  # TODO : know in advance the typing of variables
25
31
  super(json)
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module Base
6
+ # Collection AdminObjectsCollection
7
+ class AdminObjectsCollection < ObjectsCollection
8
+ def initialize(parent)
9
+ @parent = parent
10
+ reset_query_params
11
+ end
12
+
13
+ def ldap
14
+ @apply_cos = 0
15
+ self
16
+ end
17
+
18
+ def where(ldap_query)
19
+ @all = nil
20
+ ldap_filter.add(ldap_query)
21
+
22
+ self
23
+ end
24
+
25
+ def attrs(*attrs)
26
+ return self if @attrs == attrs
27
+
28
+ @all = nil
29
+ @attrs = attrs
30
+ self
31
+ end
32
+
33
+ def count
34
+ @count_only = SoapUtils::ON
35
+ make_query[:Body][:SearchDirectoryResponse][:num]
36
+ end
37
+
38
+ private
39
+
40
+ def make_query
41
+ json = sac.search_directory(
42
+ ldap_filter.join, @max_result, @limit, @offset,
43
+ @domain_name, @apply_cos, @apply_config, @sort_by, @search_type,
44
+ @sort_ascending, @count_only, attrs_comma
45
+ )
46
+ reset_query_params
47
+ json
48
+ end
49
+
50
+ def ldap_filter
51
+ @ldap_filter ||= LdapFilter.new
52
+ end
53
+
54
+ # def build_response
55
+ # @builder_class.new(@parent, make_query).make
56
+ # end
57
+
58
+ def reset_query_params
59
+ super
60
+ ldap_filter.clear
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module Base
6
+ # class for account object jsns builder
7
+ class BaseJsnsBuilder
8
+
9
+ def initialize(item)
10
+ @item = item
11
+ end
12
+
13
+ def to_delete
14
+ { id: @item.id }
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module Base
6
+ # class for account object jsns initializer
7
+ class BaseJsnsInitializer
8
+
9
+ def initialize(parent, json)
10
+ @parent = parent
11
+ @json = json
12
+ end
13
+
14
+ def create
15
+ @item ||= @child_class.new(@parent)
16
+
17
+ @item.instance_variable_set(:@id, @json[:id])
18
+ @item.instance_variable_set(:@name, @json[:name])
19
+ end
20
+
21
+ def arrow_name(name)
22
+ return name if name.to_s.start_with?('@')
23
+
24
+ "@#{name}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ module Base
6
+ # Abstract Class FolderObject
7
+ class FolderObject < AccountObject
8
+
9
+ def initialize(parent)
10
+ @l = FolderDefault::ROOT[:id]
11
+ super(parent)
12
+ end
13
+
14
+ def color!
15
+ @parent.sacc.folder_action(@parent.token, jsns_builder.to_color) if color_changed? || rgb_changed?
16
+ true
17
+ end
18
+
19
+ def delete!
20
+ @parent.sacc.folder_action(@parent.token, jsns_builder.to_delete)
21
+ super
22
+ end
23
+
24
+ def modify!
25
+ @parent.sacc.folder_action(@parent.token, jsns_builder.to_update)
26
+ true
27
+ end
28
+
29
+ def move!
30
+ @parent.sacc.folder_action(@parent.token, jsns_builder.to_move) if l_changed?
31
+ true
32
+ end
33
+
34
+ def rename!
35
+ @parent.sacc.folder_action(@parent.token, jsns_builder.to_rename) if name_changed?
36
+ super
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zm
4
+ module Client
5
+ class LdapFilter
6
+ def initialize(base_filter = nil)
7
+ @base_filter = base_filter
8
+ @parts = []
9
+ end
10
+
11
+ def add(filter)
12
+ if filter.is_a?(String) && !filter.empty?
13
+ @parts << filter
14
+ elsif filter.is_a?(Hash)
15
+ @parts += filter.map { |k, v| "(#{k}=#{v})" }
16
+ end
17
+ end
18
+
19
+ def clear
20
+ @parts.clear
21
+ end
22
+
23
+ def join
24
+ arr = @parts.dup
25
+ arr.unshift(@base_filter) unless @base_filter.nil?
26
+
27
+ return arr.first if arr.length <= 1
28
+
29
+ "(&#{arr.join})"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -10,9 +10,24 @@ module Zm
10
10
 
11
11
  def initialize(parent)
12
12
  @parent = parent
13
+ @use_builder = true
13
14
  yield(self) if block_given?
14
15
  end
15
16
 
17
+ def disable_builder
18
+ @use_builder = false
19
+ self
20
+ end
21
+
22
+ def enable_builder
23
+ @use_builder = true
24
+ self
25
+ end
26
+
27
+ def use_builder?
28
+ @use_builder
29
+ end
30
+
16
31
  def init_from_json(json)
17
32
  @id = json[:id]
18
33
  @name = json[:name]
@@ -74,6 +89,10 @@ module Zm
74
89
  yield(obj) if block_given?
75
90
  obj
76
91
  end
92
+
93
+ def logger
94
+ @parent.logger
95
+ end
77
96
  end
78
97
  end
79
98
  end
@@ -22,6 +22,10 @@ module Zm
22
22
 
23
23
  private
24
24
 
25
+ def json_items
26
+ @json_items ||= @json[:Body][json_key][@json_item_key]
27
+ end
28
+
25
29
  def json_key
26
30
  @json_key ||= @json[:Body].keys.first
27
31
  end
@@ -38,14 +38,6 @@ module Zm
38
38
  @all = build_response
39
39
  end
40
40
 
41
- def where(ldap_query)
42
- return self if @ldap_query == ldap_query
43
-
44
- @all = nil
45
- @ldap_query = ldap_query
46
- self
47
- end
48
-
49
41
  def per_page(limit)
50
42
  return self if @limit == limit
51
43
 
@@ -71,19 +63,6 @@ module Zm
71
63
  self
72
64
  end
73
65
 
74
- def count
75
- @count_only = SoapUtils::ON
76
- make_query[:Body][:SearchDirectoryResponse][:num]
77
- end
78
-
79
- def attrs(*attrs)
80
- return self if @attrs == attrs
81
-
82
- @all = nil
83
- @attrs = attrs
84
- self
85
- end
86
-
87
66
  def method_missing(method, *args, &block)
88
67
  if METHODS_MISSING_LIST.include?(method)
89
68
  build_response.send(method, *args, &block)
@@ -96,24 +75,21 @@ module Zm
96
75
  METHODS_MISSING_LIST.include?(method) || super
97
76
  end
98
77
 
78
+ def logger
79
+ @parent.logger
80
+ end
81
+
99
82
  private
100
83
 
84
+ def build_response
85
+ @builder_class.new(@parent, make_query).make
86
+ end
87
+
101
88
  def soap_admin_connector
102
89
  @parent.soap_admin_connector
103
90
  end
104
-
105
91
  alias sac soap_admin_connector
106
92
 
107
- def make_query
108
- json = sac.search_directory(
109
- @ldap_query, @max_result, @limit, @offset,
110
- @domain_name, @apply_cos, nil, @sort_by, @search_type,
111
- @sort_ascending, @count_only, attrs_comma
112
- )
113
- reset_query_params
114
- json
115
- end
116
-
117
93
  def attrs_comma
118
94
  return @attrs unless @attrs.is_a?(Array)
119
95
 
@@ -128,6 +104,9 @@ module Zm
128
104
  @sort_by = nil
129
105
  @sort_ascending = SoapUtils::ON
130
106
  @count_only = SoapUtils::OFF
107
+ @all_servers = 0
108
+ @refresh = 0
109
+ @apply_cos = 1
131
110
  end
132
111
  end
133
112
  end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ostruct'
4
+ require 'version_sorter'
5
+
6
+ module Zm
7
+ module Client
8
+ module Base
9
+ class ZimbraAttribute < OpenStruct
10
+
11
+ # attr_accessor :flags, :id, :immutable, :max, :min, :name, :optionalIn, :order, :requiredIn, :since, :type, :value
12
+
13
+ def version_start
14
+ return @version_start unless @version_start.nil?
15
+
16
+ if since.nil?
17
+ @version_start = '0.0.0'
18
+ else
19
+ @version_start = VersionSorter.sort(since.split(',')).first
20
+ end
21
+
22
+ @version_start
23
+ end
24
+
25
+ def objects_scope
26
+ @objects_scope ||= (optionalIn.to_s.split(',') + requiredIn.to_s.split(',')).freeze
27
+ end
28
+
29
+ def is_account_scoped?
30
+ @is_account_scoped ||= objects_scope.include?('account')
31
+ end
32
+
33
+ def is_aclTarget_scoped?
34
+ @is_aclTarget_scoped ||= objects_scope.include?('aclTarget')
35
+ end
36
+
37
+ def is_alias_scoped?
38
+ @is_alias_scoped ||= objects_scope.include?('alias')
39
+ end
40
+
41
+ def is_alwaysOnCluster_scoped?
42
+ @is_alwaysOnCluster_scoped ||= objects_scope.include?('alwaysOnCluster')
43
+ end
44
+
45
+ def is_calendarResource_scoped?
46
+ @is_calendarResource_scoped ||= objects_scope.include?('calendarResource')
47
+ end
48
+
49
+ def is_cos_scoped?
50
+ @is_cos_scoped ||= objects_scope.include?('cos')
51
+ end
52
+
53
+ def is_dataSource_scoped?
54
+ @is_dataSource_scoped ||= objects_scope.include?('dataSource')
55
+ end
56
+
57
+ def is_distributionList_scoped?
58
+ @is_distributionList_scoped ||= objects_scope.include?('distributionList')
59
+ end
60
+
61
+ def is_domain_scoped?
62
+ @is_domain_scoped ||= objects_scope.include?('domain')
63
+ end
64
+
65
+ def is_globalConfig_scoped?
66
+ @is_globalConfig_scoped ||= objects_scope.include?('globalConfig')
67
+ end
68
+
69
+ def is_group_scoped?
70
+ @is_group_scoped ||= objects_scope.include?('group')
71
+ end
72
+
73
+ def is_groupDynamicUnit_scoped?
74
+ @is_groupDynamicUnit_scoped ||= objects_scope.include?('groupDynamicUnit')
75
+ end
76
+
77
+ def is_groupStaticUnit_scoped?
78
+ @is_groupStaticUnit_scoped ||= objects_scope.include?('groupStaticUnit')
79
+ end
80
+
81
+ def is_identity_scoped?
82
+ @is_identity_scoped ||= objects_scope.include?('identity')
83
+ end
84
+
85
+ def is_mailRecipient_scoped?
86
+ @is_mailRecipient_scoped ||= objects_scope.include?('mailRecipient')
87
+ end
88
+
89
+ def is_mimeEntry_scoped?
90
+ @is_mimeEntry_scoped ||= objects_scope.include?('mimeEntry')
91
+ end
92
+
93
+ def is_objectEntry_scoped?
94
+ @is_objectEntry_scoped ||= objects_scope.include?('objectEntry')
95
+ end
96
+
97
+ def is_server_scoped?
98
+ @is_server_scoped ||= objects_scope.include?('server')
99
+ end
100
+
101
+ def is_signature_scoped?
102
+ @is_signature_scoped ||= objects_scope.include?('signature')
103
+ end
104
+
105
+ def is_ucService_scoped?
106
+ @is_ucService_scoped ||= objects_scope.include?('ucService')
107
+ end
108
+
109
+ def is_xmppComponent_scoped?
110
+ @is_xmppComponent_scoped ||= objects_scope.include?('xmppComponent')
111
+ end
112
+
113
+ def is_zimletEntry_scoped?
114
+ @is_zimletEntry_scoped ||= objects_scope.include?('zimletEntry')
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'zm/client/base/zimbra_attribute'
4
+
5
+ module Zm
6
+ module Client
7
+ module Base
8
+ class ZimbraAttributesCollection
9
+ attr_reader :all
10
+
11
+ def initialize(parent)
12
+ @parent = parent
13
+ @all = JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + '../../../modules/common/zimbra-attrs.json')), object_class: ZimbraAttribute).freeze
14
+ end
15
+
16
+ def set_methods
17
+ all_account_attrs = all_account_attrs_version(@parent.version)
18
+ Account.attr_reader *all_account_attrs.select { |attr| attr.immutable }.map { |attr| attr.name.to_sym }
19
+ Account.attr_accessor *all_account_attrs.reject { |attr| attr.immutable }.map { |attr| attr.name.to_sym }
20
+ end
21
+
22
+ def all_account_attrs
23
+ @all_account_attrs ||= @all.select { |attr| attr.is_account_scoped? }.freeze
24
+ end
25
+
26
+ def all_account_attr_types_h
27
+ @all_account_attr_types_h ||= Hash[all_account_attrs.map { |attr| [attr.name, attr.type] }].freeze
28
+ end
29
+
30
+ # retourne tous les attributs qui ont une version
31
+ # inférieure ou égale à la version données en paramètre
32
+ def all_account_attrs_version(version)
33
+ all_account_attrs.select { |attr| attr.version_start == version || VersionSorter.sort([version, attr.version_start]).first != version }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,7 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'curb'
4
+ require 'logger'
5
+ require 'openssl'
6
+
7
+ require 'zm/modules/zm_logger'
8
+ require 'zm/modules/zm_model'
9
+
10
+ require 'zm/client/base/zimbra_attributes_collection'
3
11
  require 'zm/client/base/object'
4
12
  require 'zm/client/base/account_object'
13
+ require 'zm/client/base/folder_object'
14
+ require 'zm/client/base/base_jsns_builder'
15
+ require 'zm/client/base/base_jsns_initializer'
5
16
  require 'zm/client/base/admin_object'
6
17
  require 'zm/client/base/objects_builder'
7
18
  require 'zm/client/base/objects_collection'
19
+ require 'zm/client/base/admin_objects_collection'
20
+ require 'zm/client/base/account_objects_collection'
21
+ require 'zm/client/base/account_search_objects_collection'
22
+ require 'zm/client/base/ldap_filter'