zm-ruby-client 2.0.5 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zm/client/base/zimbra_attribute.rb +1 -1
- data/lib/zm/client/connector/rest_account.rb +28 -15
- data/lib/zm/client/connector/soap_base.rb +19 -7
- data/lib/zm/client/domain/domain.rb +16 -0
- data/lib/zm/client/version.rb +1 -1
- data/lib/zm/modules/common/zimbra-attrs.json +25 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d742737b6d4f0eee51242127553458ed1a605d45971dc1486b02d93f467e984b
|
4
|
+
data.tar.gz: 17588c912b95778bc6b7049b765a88fb81e2e24f4926d74ad0fb444c30d5a7dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9afa511f00a2193b69470ac8cbc6c3ff85e3d6b27aa167cf50623be1942c9a6ab3691dc1ed860debbc07237d60fc5adb52f49ef01e1d4b69462e3ce1096be001
|
7
|
+
data.tar.gz: b37f5333137c31c2eccec348ff8939e54cc53dd57eac3770a47cb1f188ed683853bfd0fa54301c510a35a35783033bd453f60bf278c43f05df5208595fb24501
|
@@ -45,7 +45,7 @@ module Zm
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def is_calendarResource_scoped?
|
48
|
-
@is_calendarResource_scoped ||= objects_scope.include?('calendarResource')
|
48
|
+
@is_calendarResource_scoped ||= objects_scope.include?('calendarResource') || objects_scope.include?('account')
|
49
49
|
end
|
50
50
|
|
51
51
|
def is_cos_scoped?
|
@@ -7,34 +7,35 @@ 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
18
|
def cookies(cookies)
|
20
|
-
@
|
19
|
+
@cookies = cookies
|
21
20
|
end
|
22
21
|
|
23
22
|
def download(url, dest_file_path)
|
24
|
-
|
23
|
+
curl = init_curl_client(url)
|
24
|
+
|
25
25
|
File.open(dest_file_path, 'wb') do |f|
|
26
|
-
|
26
|
+
curl.on_body do |data|
|
27
27
|
f << data
|
28
28
|
data.size
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
curl.perform
|
32
32
|
end
|
33
33
|
|
34
|
-
if
|
34
|
+
if curl.status.to_i >= 400
|
35
35
|
File.unlink(dest_file_path) if File.exist?(dest_file_path)
|
36
36
|
|
37
|
-
message = "Download failure: #{
|
37
|
+
message = "Download failure: #{curl.body_str} (status=#{curl.status})"
|
38
|
+
close_curl(curl)
|
38
39
|
raise RestError, message
|
39
40
|
end
|
40
41
|
|
@@ -42,24 +43,34 @@ module Zm
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def upload(url, src_file_path)
|
45
|
-
|
46
|
-
|
46
|
+
curl = init_curl_client(url)
|
47
|
+
|
48
|
+
curl.http_post(Curl::PostField.file('file', src_file_path))
|
47
49
|
|
48
|
-
if
|
50
|
+
if curl.status.to_i >= 400
|
49
51
|
messages = [
|
50
52
|
"Upload failure ! #{src_file_path}",
|
51
|
-
extract_title(
|
53
|
+
extract_title(curl.body_str)
|
52
54
|
].compact
|
55
|
+
close_curl(curl)
|
53
56
|
raise RestError, messages.join("\n")
|
54
57
|
end
|
55
58
|
|
56
|
-
|
59
|
+
str = curl.body_str
|
60
|
+
close_curl(curl)
|
61
|
+
str
|
57
62
|
end
|
58
63
|
|
59
64
|
private
|
60
65
|
|
61
|
-
def
|
62
|
-
|
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|
|
63
74
|
curl.timeout = 300
|
64
75
|
curl.enable_cookies = false
|
65
76
|
curl.encoding = ''
|
@@ -68,6 +79,8 @@ module Zm
|
|
68
79
|
curl.multipart_form_post = true
|
69
80
|
curl.verbose = verbose
|
70
81
|
curl.follow_location = follow_location
|
82
|
+
curl.verbose = @verbose
|
83
|
+
curl.cookies = @cookies
|
71
84
|
end
|
72
85
|
end
|
73
86
|
|
@@ -23,12 +23,10 @@ module Zm
|
|
23
23
|
@verbose = false
|
24
24
|
@uri = URI::HTTP.new(scheme, nil, host, port, nil, soap_path, nil, nil, nil)
|
25
25
|
@context = SoapContext.new
|
26
|
-
init_curl_client
|
27
26
|
end
|
28
27
|
|
29
28
|
def verbose!
|
30
29
|
@verbose = true
|
31
|
-
@curl.verbose = @verbose
|
32
30
|
end
|
33
31
|
|
34
32
|
def invoke(soap_element, error_handler = SoapError)
|
@@ -45,28 +43,42 @@ module Zm
|
|
45
43
|
private
|
46
44
|
|
47
45
|
def init_curl_client
|
48
|
-
|
46
|
+
::Curl::Easy.new(@uri.to_s) do |curl|
|
49
47
|
curl.timeout = 300
|
50
48
|
curl.enable_cookies = false
|
51
49
|
curl.encoding = ''
|
52
50
|
curl.headers = HTTP_HEADERS
|
53
51
|
curl.ssl_verify_peer = false
|
54
52
|
curl.ssl_verify_host = 0
|
53
|
+
curl.verbose = @verbose
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
57
|
def curl_request(body, error_handler = SoapError)
|
58
|
+
curl = init_curl_client
|
59
59
|
logger.debug body.to_json
|
60
|
-
|
60
|
+
curl.http_post(body.to_json)
|
61
61
|
|
62
|
-
logger.debug
|
62
|
+
logger.debug curl.body_str
|
63
63
|
|
64
|
-
soapbody = JSON.parse(
|
65
|
-
|
64
|
+
soapbody = JSON.parse(curl.body_str, symbolize_names: true)
|
65
|
+
|
66
|
+
if curl.status.to_i >= 400
|
67
|
+
close_curl(curl)
|
68
|
+
raise(error_handler, soapbody)
|
69
|
+
end
|
70
|
+
|
71
|
+
close_curl(curl)
|
66
72
|
|
67
73
|
soapbody
|
68
74
|
end
|
69
75
|
|
76
|
+
def close_curl(curl)
|
77
|
+
curl.close
|
78
|
+
# force process to kill socket
|
79
|
+
GC.start
|
80
|
+
end
|
81
|
+
|
70
82
|
def envelope(soap_element)
|
71
83
|
{
|
72
84
|
Body: soap_element.to_hash,
|
@@ -58,6 +58,22 @@ module Zm
|
|
58
58
|
@parent.zimbra_attributes.all_domain_attrs_writable_names
|
59
59
|
end
|
60
60
|
|
61
|
+
def DKIMPublicTxt
|
62
|
+
return if self.DKIMPublicKey.nil?
|
63
|
+
return @DKIMPublicTxt if @DKIMPublicTxt
|
64
|
+
|
65
|
+
txt = self.DKIMPublicKey.each_line.map do |line|
|
66
|
+
line.chomp!
|
67
|
+
line.gsub!('"', '')
|
68
|
+
line.strip!
|
69
|
+
end.join
|
70
|
+
|
71
|
+
matches = txt.scan(/\((.*)\)/)
|
72
|
+
return if matches.first.nil?
|
73
|
+
|
74
|
+
@DKIMPublicTxt = matches.first.first.strip
|
75
|
+
end
|
76
|
+
|
61
77
|
private
|
62
78
|
|
63
79
|
def do_update!(hash)
|