class StudioApi::Appliance::GpgKey

Represents GPGKey assigned to appliance

Public Class Methods

create(appliance_id, name, key, options={}) click to toggle source

upload new GPG key to appliance @param (to_i) appliance_id id of appliance to which load gpg key @param (to_s) name of gpg key @param (File, String) opened file containing key or key in string @param (Hash) options additional options keys as it allow studio API @example Load from file

File.open ("/etc/my.cert") do |file|
  StudioApi::Appliance::GpgKey.create 1234, "my new cool key", file, :target => "rpm"
end
# File lib/studio_api/appliance.rb, line 121
def self.create (appliance_id, name, key, options={})
  options[:target] ||= "rpm"
  data = {}
  if key.is_a?(IO) && key.respond_to?(:path) #if key is string, that pass it in request, if not pack it in body
    data[:file] = key
  else
    options[:key] = key.to_s
  end
  request_str = "/appliances/#{appliance_id.to_i}/gpg_keys?name=#{name}"
  request_str = Util.add_options request_str, options, false
  response = GenericRequest.new(studio_connection).post request_str, data
  self.new Hash.from_xml(response)["gpg_key"]
end