Class: CpOraclecloud::SshKey
- Inherits:
-
Object
- Object
- CpOraclecloud::SshKey
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations
- Defined in:
- app/models/cp_oraclecloud/ssh_key.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#key ⇒ Object
Returns the value of attribute key.
-
#name ⇒ Object
Returns the value of attribute name.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
- .all ⇒ Object
- .connection ⇒ Object
- .create(params) ⇒ Object
- .delete(id) ⇒ Object
- .find_by_id(id) ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ SshKey
constructor
A new instance of SshKey.
- #persisted? ⇒ Boolean
- #save ⇒ Object
- #to_model ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ SshKey
Returns a new instance of SshKey.
14 15 16 17 18 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 14 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
7 8 9 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 7 def enabled @enabled end |
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 7 def key @key end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 7 def name @name end |
#uri ⇒ Object
Returns the value of attribute uri.
7 8 9 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 7 def uri @uri end |
Class Method Details
.all ⇒ Object
28 29 30 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 28 def self.all connection.ssh_keys end |
.connection ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 52 def self.connection @connection ||= Fog::Compute.new( :provider => 'OracleCloud', :oracle_username => CpOraclecloud.username, :oracle_password => CpOraclecloud.password, :oracle_domain => CpOraclecloud.domain, :oracle_compute_api => CpOraclecloud.compute_api ) end |
.create(params) ⇒ Object
36 37 38 39 40 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 36 def self.create(params) connection.ssh_keys.create(:name => params[:name], :enabled => params[:enabled], :key => params[:key]) end |
.delete(id) ⇒ Object
48 49 50 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 48 def self.delete(id) connection.ssh_keys.get(id).destroy end |
.find_by_id(id) ⇒ Object
32 33 34 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 32 def self.find_by_id(id) connection.ssh_keys.get(id) end |
Instance Method Details
#persisted? ⇒ Boolean
24 25 26 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 24 def persisted? false end |
#save ⇒ Object
42 43 44 45 46 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 42 def save self.connection.ssh_keys.create(:name => name, :enabled => enabled, :key => key) end |
#to_model ⇒ Object
20 21 22 |
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 20 def to_model self end |