Class: Morpheus::SupportBundlesInterface
- Inherits:
-
RestInterface
- Object
- RestInterface
- Morpheus::SupportBundlesInterface
- Defined in:
- lib/morpheus/api/support_bundles_interface.rb
Instance Method Summary collapse
- #base_path ⇒ Object
- #cancel(id, payload = {}, params = {}, headers = {}) ⇒ Object
-
#download(id, outfile, params = {}) ⇒ Object
Download uses chunked streaming to write directly to a file.
Instance Method Details
#base_path ⇒ Object
5 6 7 |
# File 'lib/morpheus/api/support_bundles_interface.rb', line 5 def base_path "/api/support-bundles" end |
#cancel(id, payload = {}, params = {}, headers = {}) ⇒ Object
42 43 44 |
# File 'lib/morpheus/api/support_bundles_interface.rb', line 42 def cancel(id, payload={}, params={}, headers={}) execute(method: :post, url: "#{base_path}/#{CGI::escape(id.to_s)}/cancel", params: params, payload: payload, headers: headers) end |
#download(id, outfile, params = {}) ⇒ Object
Download uses chunked streaming to write directly to a file. Follows the same pattern as file_copy_request_interface.rb#download_file_chunked.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/morpheus/api/support_bundles_interface.rb', line 11 def download(id, outfile, params={}) raise "#{self.class}.download() passed a blank id!" if id.to_s == '' url = "#{base_path}/#{CGI::escape(id.to_s)}/download" headers = { params: params } opts = {method: :get, url: url, headers: headers, parse_json: false} if Dir.exist?(outfile) raise "outfile is invalid. It is the name of an existing directory: #{outfile}" end if @dry_run return execute(opts) end http_response = nil begin File.open(outfile, 'w') {|f| block = proc { |response| response.read_body do |chunk| f.write chunk end } opts[:block_response] = block http_response = execute(opts) } rescue if File.exist?(outfile) && File.file?(outfile) File.delete(outfile) end raise end return http_response end |