class Morpheus::ArchiveFilesInterface

Public Instance Methods

destroy(id, params={}) click to toggle source

def update(id, payload)

url = "#{@base_url}/api/archives/files/#{id}"
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
execute(opts)

end

# File lib/morpheus/api/archive_files_interface.rb, line 166
def destroy(id, params={})
  url = "#{@base_url}/api/archives/files/#{id}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :delete, url: url, headers: headers}
  execute(opts)
end
download_file_by_path(full_file_path, params={}) click to toggle source

full_file_path is $bucketName/$filePath

# File lib/morpheus/api/archive_files_interface.rb, line 13
def download_file_by_path(full_file_path, params={})
  raise "#{self.class}.download_file_by_path() passed a blank file path!" if full_file_path.to_s == ''
  url = "#{@base_url}/api/archives/download" + "/#{full_file_path}".squeeze('/')
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers, timeout: 172800}
  execute(opts, {parse_json: false})
end
download_file_by_path_chunked(full_file_path, outfile, params={}) click to toggle source
# File lib/morpheus/api/archive_files_interface.rb, line 21
def download_file_by_path_chunked(full_file_path, outfile, params={})
  raise "#{self.class}.download_file_by_path_chunked() passed a blank file path!" if full_file_path.to_s == ''
  url = "#{@base_url}/api/archives/download" + "/#{full_file_path}".squeeze('/')
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers, timeout: 172800}
  # execute(opts, {parse_json: false})
  if Dir.exist?(outfile)
    raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
  end
  # if @verify_ssl == false
  #   opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
  # end
  if @dry_run
    return opts
  end
  http_response = nil
  File.open(outfile, 'w') {|f|
    block = proc { |response|
      response.read_body do |chunk|
        # writing to #{outfile} ..."
        f.write chunk
      end
    }
    opts[:block_response] = block
    http_response = Morpheus::RestClient.execute(opts)
  }
  return http_response
end
download_public_file_by_path_chunked(full_file_path, outfile, params={}) click to toggle source
# File lib/morpheus/api/archive_files_interface.rb, line 50
def download_public_file_by_path_chunked(full_file_path, outfile, params={})
  raise "#{self.class}.download_public_file_by_path_chunked() passed a blank file path!" if full_file_path.to_s == ''
  url = "#{@base_url}/public-archives/download" + "/#{full_file_path}".squeeze('/')
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers, timeout: 172800}
  # execute(opts, {parse_json: false})
  if Dir.exist?(outfile)
    raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
  end
  # if @verify_ssl == false
  #   opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
  # end
  if @dry_run
    return opts
  end
  http_response = nil
  File.open(outfile, 'w') {|f|
    block = proc { |response|
      response.read_body do |chunk|
        # writing to #{outfile} ..."
        f.write chunk
      end
    }
    opts[:block_response] = block
    http_response = Morpheus::RestClient.execute(opts)
  }
  return http_response
end
get(file_id, params={}) click to toggle source
# File lib/morpheus/api/archive_files_interface.rb, line 4
def get(file_id, params={})
  raise "#{self.class}.get() passed a blank id!" if file_id.to_s == ''
  url = "#{@base_url}/api/archives/files/#{file_id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end
history(file_id, params={}) click to toggle source
# File lib/morpheus/api/archive_files_interface.rb, line 109
def history(file_id, params={})
  raise "#{self.class}.history() passed a blank id!" if file_id.to_s == ''
  url = "#{@base_url}/api/archives/files/#{file_id}/history"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end