class Morpheus::PackagesInterface
Public Instance Methods
Source
# File lib/morpheus/api/packages_interface.rb, line 70 def destroy(id) url = "#{@base_url}/api/packages/#{id}" headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :delete, url: url, headers: headers} execute(opts) end
Source
# File lib/morpheus/api/packages_interface.rb, line 77 def export(params, outfile) url = "#{@base_url}/api/packages/export" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :post, url: url, headers: headers} # 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 bad_body = nil File.open(outfile, 'w') {|f| block = proc { |response| if response.code.to_i == 200 response.read_body do |chunk| #puts "writing to #{outfile} ..." f.write chunk end else # puts_error (#{response.inspect}) #{chunk} ..." bad_body = response.body.to_s end } opts[:block_response] = block http_response = Morpheus::RestClient.execute(opts) } return http_response, bad_body end
Source
# File lib/morpheus/api/packages_interface.rb, line 29 def info(params={}) url = "#{@base_url}/api/packages/info" headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!(params) opts = {method: :get, url: url, headers: headers} execute(opts) end
Source
# File lib/morpheus/api/packages_interface.rb, line 37 def install(params={}, payload={}) url = "#{@base_url}/api/packages/install" headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end
Source
# File lib/morpheus/api/packages_interface.rb, line 51 def install_file(local_file, params={}) url = "#{@base_url}/api/packages/install-file" headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/octet-stream'} if !local_file.kind_of?(File) local_file = File.new(local_file, 'rb') end payload = local_file headers['Content-Length'] = local_file.size # File.size(local_file) opts = {method: :post, url: url, headers: headers, payload: payload} execute(opts) end
def install_file
(package_file, params={})
url = "#{@base_url}/api/packages/install-file" headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/octet-stream'} payload = package_file execute(method: :post, url: url, headers: headers, payload: payload, timeout: 36000)
end
Source
# File lib/morpheus/api/packages_interface.rb, line 13 def list(params={}) url = "#{@base_url}/api/packages" headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!(params) opts = {method: :get, url: url, headers: headers} execute(opts) end
def get(id)
raise "#{self.class}.get() passed a blank id!" if id.to_s == '' url = "#{@base_url}/api/packages/#{id}" headers = { params: {}, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts)
end
Source
# File lib/morpheus/api/packages_interface.rb, line 21 def search(params={}) url = "#{@base_url}/api/packages/search" headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!(params) opts = {method: :get, url: url, headers: headers} execute(opts) end
Source
# File lib/morpheus/api/packages_interface.rb, line 63 def update(id, payload) url = "#{@base_url}/api/packages/update/#{id}" headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end