Class: CpOraclecloud::SshKey

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations
Defined in:
app/models/cp_oraclecloud/ssh_key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#enabledObject

Returns the value of attribute enabled.



7
8
9
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 7

def enabled
  @enabled
end

#keyObject

Returns the value of attribute key.



7
8
9
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 7

def key
  @key
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 7

def name
  @name
end

#uriObject

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

.allObject



28
29
30
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 28

def self.all
  connection.ssh_keys
end

.connectionObject



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

Returns:

  • (Boolean)


24
25
26
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 24

def persisted?
  false
end

#saveObject



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_modelObject



20
21
22
# File 'app/models/cp_oraclecloud/ssh_key.rb', line 20

def to_model
  self
end