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
121 def self.create (appliance_id, name, key, options={})
122   options[:target] ||= "rpm"
123   data = {}
124   if key.is_a?(IO) && key.respond_to?(:path) #if key is string, that pass it in request, if not pack it in body
125     data[:file] = key
126   else
127     options[:key] = key.to_s
128   end
129   request_str = "/appliances/#{appliance_id.to_i}/gpg_keys?name=#{name}"
130   request_str = Util.add_options request_str, options, false
131   response = GenericRequest.new(studio_connection).post request_str, data
132   self.new Hash.from_xml(response)["gpg_key"]
133 end