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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parameter_group_nameObject

Returns the value of attribute parameter_group_name.



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

def parameter_group_name
  @parameter_group_name
end

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#portObject

Returns the value of attribute port.



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

def port
  @port
end

#security_group_namesObject

Returns the value of attribute security_group_names.



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

def security_group_names
  @security_group_names
end

Instance Method Details

#add_tags(new_tags) ⇒ Object



76
77
78
79
80
# File 'lib/fog/aws/models/rds/server.rb', line 76

def add_tags(new_tags)
  requires :id
  service.add_tags_to_resource(id, new_tags)
  tags
end

#attributes_to_paramsObject

Converts attributes to a parameter hash suitable for requests



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/fog/aws/models/rds/server.rb', line 120

def attributes_to_params
  options = {
    'AllocatedStorage'              => allocated_storage,
    'AutoMinorVersionUpgrade'       => auto_minor_version_upgrade,
    'AvailabilityZone'              => availability_zone,
    'BackupRetentionPeriod'         => backup_retention_period,
    'DBInstanceClass'               => flavor_id,
    'DBInstanceIdentifier'          => id,
    'DBName'                        => db_name,
    'DBParameterGroupName'          => parameter_group_name || attributes['DBParameterGroupName'],
    'DBSecurityGroups'              => security_group_names,
    'DBSubnetGroupName'             => db_subnet_group_name,
    'Engine'                        => engine,
    'EngineVersion'                 => engine_version,
    'StorageEncrypted'              => storage_encrypted,
    'Iops'                          => iops,
    'LicenseModel'                  => license_model,
    'MasterUserPassword'            => password || attributes['MasterUserPassword'],
    'MasterUsername'                => master_username,
    'MultiAZ'                       => multi_az,
    'Port'                          => port || attributes['Port'],
    'PreferredBackupWindow'         => preferred_backup_window,
    'PreferredMaintenanceWindow'    => preferred_maintenance_window,
    'PubliclyAccessible'            => publicly_accessible,
    'StorageType'                   => storage_type,
    'VpcSecurityGroups'             => vpc_security_groups,
  }

  options.delete_if {|key, value| value.nil?}
end

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



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

def create_read_replica(replica_id, options={})
  options[:security_group_names] ||= options['DBSecurityGroups']
  params = self.class.new(options).attributes_to_params
  service.create_db_instance_read_replica(replica_id, id, params)
  service.servers.get(replica_id)
end

#destroy(snapshot_identifier = nil) ⇒ Object



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

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

#modify(immediately, options) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/fog/aws/models/rds/server.rb', line 98

def modify(immediately, options)
  options[:security_group_names] ||= options['DBSecurityGroups']
  params = self.class.new(options).attributes_to_params
  data = service.modify_db_instance(id, immediately, params)
  merge_attributes(data.body['ModifyDBInstanceResult']['DBInstance'])
  true
end

#promote_read_replicaObject Also known as: promote



88
89
90
91
92
93
94
# File 'lib/fog/aws/models/rds/server.rb', line 88

def promote_read_replica
  requires :id

  data = service.promote_read_replica(id).body["PromoteReadReplicaResult"]["DBInstance"]

  merge_attributes(data)
end

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
  state == 'available'
end

#rebootObject



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

def reboot
  service.reboot_db_instance(id)
  true
end

#remove_tags(tag_keys) ⇒ Object



82
83
84
85
86
# File 'lib/fog/aws/models/rds/server.rb', line 82

def remove_tags(tag_keys)
  requires :id
  service.remove_tags_from_resource(id, tag_keys)
  tags
end

#saveObject



106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fog/aws/models/rds/server.rb', line 106

def save
  requires :engine
  requires :allocated_storage
  requires :master_username
  requires :password

  self.flavor_id ||= 'db.m1.small'

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

#snapshotsObject



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

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

#tagsObject



70
71
72
73
74
# File 'lib/fog/aws/models/rds/server.rb', line 70

def tags
  requires :id
  service.list_tags_for_resource(id).
    body['ListTagsForResourceResult']['TagList']
end