itrp-client 1.0.1 → 1.0.2
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 +8 -8
- data/itrp-client.gemspec +7 -7
- data/lib/itrp/client.rb +7 -1
- data/lib/itrp/client/attachments.rb +13 -2
- data/lib/itrp/client/response.rb +7 -2
- data/lib/itrp/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDBlZmJiM2E5MjRkOGE4NWQ1YmQ3YTM0Njg1Nzk1ZmI4ZGI4YWY2YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDEyYThlYjgyZDkxZTAxZTA3Y2ExMTc5ZWYyZWM2YzQyNmQ1MThkMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjllNDM3ODZkODU5OWI4NTliZDQxNzg4N2QwODM1MDJhN2I2MTNkY2EzM2Y0
|
10
|
+
ODZkMDVhYjhmYTMzMDkyNTJlMGViMzM1MDE1M2Y2ZDFkNTQyYzBlMjJlNzdi
|
11
|
+
MDUzYjc4ZTdkNTMzZGI2OTIyMzM5NTU3N2YzOWEzYjZmZmVkYWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzFkYzY5OTEzMzJlNzE3MGYwOTdlYjAyMWMxMTE3M2YwYjMxN2IyNGJmMDBj
|
14
|
+
MzYyYjgxMDhkYjI0ZjQyMTBjNTllNWFlNjY0YTY5OWIxZWZjZTIwODhiNWJl
|
15
|
+
N2RjMjExZTJkMjJmOTI0MjA2ZjRjMzllMDljYzY4OGJmYmEzYTk=
|
data/itrp-client.gemspec
CHANGED
@@ -15,13 +15,13 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = %q{http://github.com/itrp/itrp-client}
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
18
|
-
spec.files = Dir.glob("lib/**/*") +
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
spec.files = Dir.glob("lib/**/*") + %w(
|
19
|
+
LICENSE.txt
|
20
|
+
README.md
|
21
|
+
Gemfile
|
22
|
+
Gemfile.lock
|
23
|
+
itrp-client.gemspec
|
24
|
+
)
|
25
25
|
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
26
|
spec.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
27
27
|
spec.require_paths = ["lib"]
|
data/lib/itrp/client.rb
CHANGED
@@ -146,7 +146,13 @@ module Itrp
|
|
146
146
|
data = {type: [types].flatten.join(',')}
|
147
147
|
data[:from] = from unless from.blank?
|
148
148
|
response = post('/export', data)
|
149
|
-
|
149
|
+
if response.valid?
|
150
|
+
if response.raw.code.to_s == '204'
|
151
|
+
@logger.info { "No changed records for '#{data[:type]}' since #{data[:from]}." }
|
152
|
+
return response
|
153
|
+
end
|
154
|
+
@logger.info { "Export for '#{data[:type]}' successfully queued with token '#{response[:token]}'." }
|
155
|
+
end
|
150
156
|
|
151
157
|
if block_until_completed
|
152
158
|
raise ::Itrp::UploadFailed.new("Failed to queue '#{data[:type]}' export. #{response.message}") unless response.valid?
|
@@ -19,11 +19,22 @@ module Itrp
|
|
19
19
|
report_error("Attachments not allowed for #{path}", raise_exceptions) and return unless storage
|
20
20
|
|
21
21
|
# upload each attachment and store the {key, filesize} has in the note_attachments parameter
|
22
|
-
data[
|
22
|
+
data[attachments_field(path)] = attachments.map {|attachment| upload_attachment(storage, attachment, raise_exceptions) }.compact.to_json
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
+
def attachments_field(path)
|
28
|
+
case path
|
29
|
+
when /cis/, /contracts/, /flsas/, /service_instances/, /slas/
|
30
|
+
:remarks_attachments
|
31
|
+
when /service_offerings/
|
32
|
+
:summary_attachments
|
33
|
+
else
|
34
|
+
:note_attachments
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
27
38
|
def report_error(message, raise_exceptions)
|
28
39
|
if raise_exceptions
|
29
40
|
raise Itrp::UploadFailed.new(message)
|
@@ -96,4 +107,4 @@ module Itrp
|
|
96
107
|
end
|
97
108
|
|
98
109
|
end
|
99
|
-
end
|
110
|
+
end
|
data/lib/itrp/client/response.rb
CHANGED
@@ -22,8 +22,13 @@ module Itrp
|
|
22
22
|
# If the response is not +valid?+ it is a Hash with 'message' and optionally 'errors'
|
23
23
|
def json
|
24
24
|
return @json if defined?(@json)
|
25
|
-
# no
|
26
|
-
|
25
|
+
# no content, no JSON
|
26
|
+
if @response.code.to_s == '204'
|
27
|
+
data = {}
|
28
|
+
elsif @response.body.blank?
|
29
|
+
# no body, no json
|
30
|
+
data = {message: @response.message.blank? ? 'empty body' : @response.message.strip}
|
31
|
+
end
|
27
32
|
begin
|
28
33
|
data ||= JSON.parse(@response.body)
|
29
34
|
rescue ::Exception => e
|
data/lib/itrp/client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itrp-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ITRP
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_config
|