Class: Fog::AWS::RDS::Server

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/rds/server.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #to_json, #wait_for

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

#initialize(attributes = {}) ⇒ Server

Returns a new instance of Server.



34
35
36
37
# File 'lib/fog/aws/models/rds/server.rb', line 34

def initialize(attributes={})
  self.flavor_id ||= 'db.m1.small'
  super
end

Instance Attribute Details

#parameter_group_nameObject

Returns the value of attribute parameter_group_name.



32
33
34
# File 'lib/fog/aws/models/rds/server.rb', line 32

def parameter_group_name
  @parameter_group_name
end

#passwordObject

Returns the value of attribute password.



32
33
34
# File 'lib/fog/aws/models/rds/server.rb', line 32

def password
  @password
end

#portObject

Returns the value of attribute port.



32
33
34
# File 'lib/fog/aws/models/rds/server.rb', line 32

def port
  @port
end

#security_group_namesObject

Returns the value of attribute security_group_names.



32
33
34
# File 'lib/fog/aws/models/rds/server.rb', line 32

def security_group_names
  @security_group_names
end

Instance Method Details

#create_read_replica(replica_id, options = {}) ⇒ Object



39
40
41
42
# File 'lib/fog/aws/models/rds/server.rb', line 39

def create_read_replica(replica_id, options={})
  connection.create_db_instance_read_replica(replica_id, id, options)
  connection.servers.get(replica_id)
end

#destroy(snapshot_identifier = nil) ⇒ Object



48
49
50
51
52
# File 'lib/fog/aws/models/rds/server.rb', line 48

def destroy(snapshot_identifier=nil)
  requires :id
  connection.delete_db_instance(id, snapshot_identifier, snapshot_identifier.nil?)
  true
end

#modify(immediately, options) ⇒ Object



64
65
66
67
68
# File 'lib/fog/aws/models/rds/server.rb', line 64

def modify(immediately, options)
  data = connection.modify_db_instance(id, immediately, options)
  merge_attributes(data.body['ModifyDBInstanceResult']['DBInstance'])
  true  
end

#ready?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/fog/aws/models/rds/server.rb', line 44

def ready?
  state == 'available'
end

#rebootObject



54
55
56
57
# File 'lib/fog/aws/models/rds/server.rb', line 54

def reboot
  connection.reboot_db_instance(id)
  true
end

#saveObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/fog/aws/models/rds/server.rb', line 70

def save
  requires :engine
  requires :allocated_storage
  requires :master_username
  requires :password
  options = {
    'AllocatedStorage'              => allocated_storage,
    'AutoMinorVersionUpgrade'       => auto_minor_version_upgrade,
    'BackupRetentionPeriod'         => backup_retention_period,
    'DBName'                        => db_name,
    'DBParameterGroupName'          => parameter_group_name,
    'DBSecurityGroups'              => security_group_names,
    'DBInstanceIdentifier'          => id,
    'AvailabilityZone'              => availability_zone,
    'DBInstanceClass'               => flavor_id,
    'Port'                          => port,
    'Engine'                        => engine,
    'EngineVersion'                 => engine_version,
    'MasterUsername'                => master_username,
    'MasterUserPassword'            => password,
    'PreferredMaintenanceWindow'    => preferred_maintenance_window,
    'PreferredBackupWindow'         => preferred_backup_window,
    'MultiAZ'                       => multi_az
  }
  options.delete_if {|key, value| value.nil?}


  data = connection.create_db_instance(id, options)
  merge_attributes(data.body['CreateDBInstanceResult']['DBInstance'])
  true
end

#snapshotsObject



59
60
61
62
# File 'lib/fog/aws/models/rds/server.rb', line 59

def snapshots
  requires :id
  connection.snapshots(:server => self)
end