zm-ruby-client 0.18.3 → 0.18.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4291a3894ee2caa740aff649e8fdbaa57a55e4091a151ef7695c6d95ee14057d
4
- data.tar.gz: 7f3a2333df68c482e0f45fc32c10c60eba17f3c979b6cca9cd59528da1453826
3
+ metadata.gz: b9fad2347a2f7fa88c1da39a1e3dfdc85598e3dac8e7a060866b58da8fb1aa39
4
+ data.tar.gz: 30b9161ed034e763748918c47675bd4440eea099bfab0a70d4089691020b7860
5
5
  SHA512:
6
- metadata.gz: e6a4bc55cffe7887b6cfba72a9185930ab4adb1a654d35b849296189aed6a6a18be49c2b0fdf1a3a238f31afbc63f64679c5b38ac0a2fb9073791df3ee1a80ef
7
- data.tar.gz: 3b79c94a2572c6b4ca9939df062a0fd427666aed491f3322372b1d291e47d0d0bd1d178ebb8673fbbf4ed19240ea07cb599a3be25885a916d38c99277028954d
6
+ metadata.gz: e6cd34015b3ebda5f628f27722d894ef30dc1b7e7cc9500fd91cbb63cf5d138f4aa1197b5681638945cf9c8b63bec5c7e4dbb426b7f3cee2cc11921581693a6f
7
+ data.tar.gz: 2da81cb383c52918038f3e586e781b6d917ecd356a8414ca0e5aa5616b6d9023689c7dc294fd9194471c474b117cd8f016aef293b1e8ff5433a4d0469bbc9b91
@@ -25,10 +25,7 @@ module Zm
25
25
  module Client
26
26
  # objectClass: zimbraAccount
27
27
  class Account < Base::AdminObject
28
- # attr_reader :name, :id, :token
29
- # attr_writer :home_url
30
- # attr_accessor :password, :domainkey, :company, :zimbraCOSId, :zimbraMailHost, :zimbraMailTransport, :carLicense
31
- attr_accessor :name, :id, :token, :home_url, :password, :domainkey, :carLicense
28
+ attr_accessor :name, :id, :token, :home_url, :public_url, :password, :domainkey, :carLicense
32
29
 
33
30
  def initialize(parent)
34
31
  extend(AccountCommon)
@@ -36,18 +33,6 @@ module Zm
36
33
  @grantee_type = 'usr'.freeze
37
34
  end
38
35
 
39
- # def init_by_hash(attrs)
40
- # attrs.each do |k, v|
41
- # self.instance_variable_set(arrow_name(k), v)
42
- # end
43
- # end
44
-
45
- # def to_h
46
- # hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
47
- # hashmap.delete_if { |_, v| v.nil? }
48
- # hashmap
49
- # end
50
-
51
36
  def all_instance_variable_keys
52
37
  AccountCommon::ZM_ACCOUNT_ATTRS
53
38
  end
@@ -107,6 +92,10 @@ module Zm
107
92
  @domainkey ||= @parent.domain_key(domain_name)
108
93
  end
109
94
 
95
+ def domain_key=(key)
96
+ @domainkey = key
97
+ end
98
+
110
99
  def infos
111
100
  @infos || read_infos
112
101
  end
@@ -7,49 +7,70 @@ module Zm
7
7
 
8
8
  def initialize
9
9
  @verbose = false
10
+ @cookies = nil
10
11
  @follow_location = true
11
- @curl = easy_curl
12
12
  end
13
13
 
14
14
  def verbose!
15
15
  @verbose = true
16
- @curl.verbose = @verbose
17
16
  end
18
17
 
19
- def cookie(cookie)
20
- @curl.headers['Cookie'] = cookie
18
+ def cookies(cookies)
19
+ @cookies = cookies
21
20
  end
22
21
 
23
22
  def download(url, dest_file_path)
24
- @curl.url = URI.escape(url)
23
+ curl = init_curl_client(url)
24
+
25
25
  File.open(dest_file_path, 'wb') do |f|
26
- @curl.on_body do |data|
26
+ curl.on_body do |data|
27
27
  f << data
28
28
  data.size
29
29
  end
30
- @curl.perform
30
+
31
+ curl.perform
32
+ end
33
+
34
+ if curl.status.to_i >= 400
35
+ File.unlink(dest_file_path) if File.exist?(dest_file_path)
36
+
37
+ message = "Download failure: #{curl.body_str} (status=#{curl.status})"
38
+ close_curl(curl)
39
+ raise RestError, message
31
40
  end
41
+
42
+ dest_file_path
32
43
  end
33
44
 
34
45
  def upload(url, src_file_path)
35
- @curl.url = URI.escape(url)
36
- @curl.http_post(Curl::PostField.file('file', src_file_path))
46
+ curl = init_curl_client(url)
47
+
48
+ curl.http_post(Curl::PostField.file('file', src_file_path))
37
49
 
38
- if @curl.status.to_i >= 400
50
+ if curl.status.to_i >= 400
39
51
  messages = [
40
52
  "Upload failure ! #{src_file_path}",
41
- extract_title(@curl.body_str)
53
+ extract_title(curl.body_str)
42
54
  ].compact
55
+ close_curl(curl)
43
56
  raise RestError, messages.join("\n")
44
57
  end
45
58
 
46
- @curl.body_str
59
+ str = curl.body_str
60
+ close_curl(curl)
61
+ str
47
62
  end
48
63
 
49
64
  private
50
65
 
51
- def easy_curl
52
- Curl::Easy.new do |curl|
66
+ def close_curl(curl)
67
+ curl.close
68
+ # force process to kill socket
69
+ GC.start
70
+ end
71
+
72
+ def init_curl_client(url)
73
+ ::Curl::Easy.new(url) do |curl|
53
74
  curl.timeout = 300
54
75
  curl.enable_cookies = false
55
76
  curl.encoding = ''
@@ -58,6 +79,8 @@ module Zm
58
79
  curl.multipart_form_post = true
59
80
  curl.verbose = verbose
60
81
  curl.follow_location = follow_location
82
+ curl.verbose = @verbose
83
+ curl.cookies = @cookies
61
84
  end
62
85
  end
63
86
 
@@ -20,40 +20,51 @@ module Zm
20
20
  extend(ZmLogger)
21
21
  @verbose = false
22
22
  @uri = URI::HTTP.new(scheme, nil, host, port, nil, soap_path, nil, nil, nil)
23
- init_curl_client
24
23
  end
25
24
 
26
25
  def verbose!
27
26
  @verbose = true
28
- @curl.verbose = @verbose
29
27
  end
30
28
 
31
29
  private
32
30
 
33
31
  def init_curl_client
34
- @curl = ::Curl::Easy.new(@uri.to_s) do |curl|
32
+ ::Curl::Easy.new(@uri.to_s) do |curl|
35
33
  curl.timeout = 300
36
34
  curl.enable_cookies = false
37
35
  curl.encoding = ''
38
36
  curl.headers = HTTP_HEADERS
39
37
  curl.ssl_verify_peer = false
40
38
  curl.ssl_verify_host = 0
41
- # curl.verbose = @verbose
39
+ curl.verbose = @verbose
42
40
  end
43
41
  end
44
42
 
45
43
  def curl_request(body, error_handler = SoapError)
44
+ curl = init_curl_client
46
45
  logger.debug body.to_json
47
- @curl.http_post(body.to_json)
46
+ curl.http_post(body.to_json)
48
47
 
49
- logger.debug @curl.body_str
48
+ logger.debug curl.body_str
50
49
 
51
- soapbody = JSON.parse(@curl.body_str, symbolize_names: true)
52
- raise(error_handler, soapbody) if @curl.status.to_i >= 400
50
+ soapbody = JSON.parse(curl.body_str, symbolize_names: true)
51
+
52
+ if curl.status.to_i >= 400
53
+ close_curl(curl)
54
+ raise(error_handler, soapbody)
55
+ end
56
+
57
+ close_curl(curl)
53
58
 
54
59
  soapbody
55
60
  end
56
61
 
62
+ def close_curl(curl)
63
+ curl.close
64
+ # force process to kill socket
65
+ GC.start
66
+ end
67
+
57
68
  def hash_header(token, target_server = nil)
58
69
  context = { authToken: token, userAgent: { name: :zmsoap }, targetServer: target_server }.delete_if do |_, v|
59
70
  v.nil?
@@ -7,7 +7,7 @@ module Zm
7
7
  INSTANCE_VARIABLE_KEYS = %i[name description zimbraDomainName zimbraDomainStatus zimbraId zimbraDomainType
8
8
  zimbraDomainDefaultCOSId zimbraGalAccountId zimbraPreAuthKey zimbraGalLdapBindDn zimbraGalLdapBindPassword
9
9
  zimbraGalLdapFilter zimbraGalLdapSearchBase zimbraGalLdapURL zimbraGalMode zimbraMailTransport
10
- zimbraPublicServiceHostname zimbraPublicServiceProtocol]
10
+ zimbraPublicServiceHostname zimbraPublicServiceProtocol zimbraVirtualHostname]
11
11
 
12
12
  attr_accessor *INSTANCE_VARIABLE_KEYS
13
13
 
@@ -16,12 +16,6 @@ module Zm
16
16
  @grantee_type = 'dom'.freeze
17
17
  end
18
18
 
19
- # def to_h
20
- # hashmap = Hash[all_instance_variable_keys.map { |key| [key, instance_variable_get(arrow_name(key))] }]
21
- # hashmap.delete_if { |_, v| v.nil? }
22
- # hashmap
23
- # end
24
-
25
19
  def all_instance_variable_keys
26
20
  INSTANCE_VARIABLE_KEYS
27
21
  end
@@ -51,6 +45,10 @@ module Zm
51
45
  end
52
46
  end
53
47
 
48
+ def modify!
49
+ false
50
+ end
51
+
54
52
  def accounts
55
53
  @accounts ||= DomainAccountsCollection.new(self)
56
54
  end
@@ -59,11 +57,6 @@ module Zm
59
57
  sac.generic_delete(:DeleteDomainRequest, id)
60
58
  end
61
59
 
62
- # def account_quotas(server_id)
63
- # rep = sac.get_quota_usage(name, nil, nil, nil, nil, nil, nil, server_id)
64
- # AccountsBuilder.new(@parent, rep).make
65
- # end
66
-
67
60
  def init_from_json(json)
68
61
  super(json)
69
62
  return unless json[:a].is_a? Array
@@ -12,8 +12,7 @@ module Zm
12
12
  webOfflineSyncDays color rgb
13
13
  ].freeze
14
14
 
15
- attr_reader :owner, :rev, :reminder, :ms, :deletable, :rid, :uuid, :url, :f, :broken, :luuid, :ruuid, :activesyncdisabled, :absFolderPath, :zid, :id, :webOfflineSyncDays
16
- attr_writer :view, :zid, :rid
15
+ attr_accessor :owner, :rev, :reminder, :ms, :deletable, :rid, :uuid, :url, :f, :broken, :luuid, :ruuid, :activesyncdisabled, :absFolderPath, :zid, :id, :webOfflineSyncDays, :view, :zid, :rid
17
16
 
18
17
  define_changed_attributes :name, :color, :rgb, :l
19
18
 
@@ -10,7 +10,7 @@ module Zm
10
10
  module VERSION
11
11
  MAJOR = 0
12
12
  MINOR = 18
13
- TINY = 3
13
+ TINY = 5
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zm-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.3
4
+ version: 0.18.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Désécot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-31 00:00:00.000000000 Z
11
+ date: 2024-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -264,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  - !ruby/object:Gem::Version
265
265
  version: '0'
266
266
  requirements: []
267
- rubygems_version: 3.1.6
267
+ rubygems_version: 3.4.19
268
268
  signing_key:
269
269
  specification_version: 4
270
270
  summary: zm-ruby-client