zm-ruby-client 2.0.4 → 2.0.6
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/connector/rest_account.rb +28 -15
- data/lib/zm/client/connector/soap_base.rb +19 -7
- data/lib/zm/client/contact/group_contact_jsns_builder.rb +7 -1
- 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 +7 -1
- 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: 13a8f6a25daf14d60d491a527f7b9b71920afe9e5df79cbb60bceeacdbdcd606
|
4
|
+
data.tar.gz: f3e41e0e600c97ab87a0198bb69e305ba7e12e07d9235ae57ff2e5f6d8457e21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38457fc1f124a1970240edbe7ee900ba02b1c9a864306c03335318eff0c106b27a16cf6598bcc3b1f931904eff7f6de31834f125a69a4177cba07aef86ca6ea7
|
7
|
+
data.tar.gz: 2d4491d26f0c59c8b2bc36c9f7f1ac183a3d00b06abf749005442dd67ef5fa17674f1fcd36a7bb4ae23c73a23a157f1f3a063427b938ddc7a9decda724967653
|
@@ -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,
|
@@ -14,16 +14,20 @@ module Zm
|
|
14
14
|
m: members_node
|
15
15
|
}
|
16
16
|
}
|
17
|
+
|
18
|
+
SoapElement.mail(SoapMailConstants::CREATE_CONTACT_REQUEST).add_attributes(jsns)
|
17
19
|
end
|
18
20
|
|
19
21
|
def to_update
|
20
|
-
{
|
22
|
+
jsns = {
|
21
23
|
cn: {
|
22
24
|
a: instance_variables_array.map(&Utils::A_NODE_PROC),
|
23
25
|
id: @item.id,
|
24
26
|
m: members_node
|
25
27
|
}
|
26
28
|
}
|
29
|
+
|
30
|
+
SoapElement.mail(SoapMailConstants::MODIFY_CONTACT_REQUEST).add_attributes(jsns)
|
27
31
|
end
|
28
32
|
|
29
33
|
def to_patch(hash)
|
@@ -33,6 +37,8 @@ module Zm
|
|
33
37
|
a: hash.map(&Utils::A_ARRAY_PROC).flatten(1).map(&Utils::A_NODE_PROC)
|
34
38
|
}
|
35
39
|
}
|
40
|
+
|
41
|
+
SoapElement.mail(SoapMailConstants::MODIFY_CONTACT_REQUEST).add_attributes(jsns)
|
36
42
|
end
|
37
43
|
|
38
44
|
alias to_create to_jsns
|
@@ -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)
|
data/lib/zm/client/version.rb
CHANGED
@@ -30,4 +30,10 @@
|
|
30
30
|
{"id":"MD060","name":"zimbraWebClientMaxInputBufferLength","type":"cstring","cardinality":"single","requiredIn":"domain"},
|
31
31
|
{"id":"MD061","name":"zimbraWebClientStaySignedInDisabled","type":"cstring","cardinality":"single","requiredIn":"domain"},
|
32
32
|
{"id":"MD062","name":"zimbraWebClientSupportedHelps","type":"cstring","cardinality":"single","requiredIn":"domain"},
|
33
|
-
{"id":"MD063","name":"zimbraZimletDataSensitiveInMixedModeDisabled","type":"cstring","cardinality":"single","requiredIn":"domain"}
|
33
|
+
{"id":"MD063","name":"zimbraZimletDataSensitiveInMixedModeDisabled","type":"cstring","cardinality":"single","requiredIn":"domain"},
|
34
|
+
{"id":"MD064","name":"DKIMDomain","type":"cstring","cardinality":"single","requiredIn":"domain"},
|
35
|
+
{"id":"MD065","name":"DKIMIdentity","type":"cstring","cardinality":"single","requiredIn":"domain"},
|
36
|
+
{"id":"MD066","name":"DKIMKey","type":"cstring","cardinality":"single","requiredIn":"domain"},
|
37
|
+
{"id":"MD067","name":"DKIMPublicKey","type":"cstring","cardinality":"single","requiredIn":"domain"},
|
38
|
+
{"id":"MD068","name":"DKIMSelector","type":"cstring","cardinality":"single","requiredIn":"domain"}
|
39
|
+
]
|
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: 2.0.
|
4
|
+
version: 2.0.6
|
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:
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -323,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
323
323
|
- !ruby/object:Gem::Version
|
324
324
|
version: 1.8.11
|
325
325
|
requirements: []
|
326
|
-
rubygems_version: 3.
|
326
|
+
rubygems_version: 3.4.19
|
327
327
|
signing_key:
|
328
328
|
specification_version: 4
|
329
329
|
summary: zm-ruby-client
|