class Fog::AWS::RDS::Server

Attributes

parameter_group_name[RW]
password[RW]
port[RW]
security_group_names[RW]
source_snapshot_id[RW]

Public Instance Methods

add_tags(new_tags) click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 84
def add_tags(new_tags)
  requires :id
  service.add_tags_to_resource(id, new_tags)
  tags
end
attributes_to_params() click to toggle source

Converts attributes to a parameter hash suitable for requests

# File lib/fog/aws/models/rds/server.rb, line 139
def attributes_to_params
  options = {
    'AllocatedStorage'                => allocated_storage,
    'AutoMinorVersionUpgrade'         => auto_minor_version_upgrade,
    'AvailabilityZone'                => availability_zone,
    'BackupRetentionPeriod'           => backup_retention_period,
    'DBClusterIdentifier'             => cluster_id,
    'DBInstanceClass'                 => flavor_id,
    'DBInstanceIdentifier'            => id,
    'DBName'                          => db_name,
    'DBParameterGroupName'            => parameter_group_name || attributes['DBParameterGroupName'],
    'DBSecurityGroups'                => security_group_names,
    'DBSubnetGroupName'               => db_subnet_group_name,
    'EnableIAMDatabaseAuthentication' => enable_iam_database_authentication,
    'Engine'                          => engine,
    'EngineVersion'                   => engine_version,
    'Iops'                            => iops,
    'KmsKeyId'                        => kms_key_id,
    '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,
    'StorageEncrypted'                => storage_encrypted,
    'StorageType'                     => storage_type,
    'VpcSecurityGroups'               => vpc_security_groups,
  }

  options.delete_if {|key, value| value.nil?}
end
cluster() click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 46
def cluster
  return nil unless cluster_id
  service.clusters.get(cluster_id)
end
create_read_replica(replica_id, options={}) click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 51
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) click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 62
def destroy(snapshot_identifier=nil)
  requires :id
  service.delete_db_instance(id, snapshot_identifier, snapshot_identifier.nil?)
  true
end
modify(immediately, options) click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 106
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()
promote_read_replica() click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 96
def promote_read_replica
  requires :id

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

  merge_attributes(data)
end
Also aliased as: promote
ready?() click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 58
def ready?
  state == 'available'
end
reboot() click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 68
def reboot
  service.reboot_db_instance(id)
  true
end
remove_tags(tag_keys) click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 90
def remove_tags(tag_keys)
  requires :id
  service.remove_tags_from_resource(id, tag_keys)
  tags
end
save() click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 114
def save
  if source_snapshot_id
    requires :id
    data = service.restore_db_instance_from_db_snapshot(source_snapshot_id, id, attributes_to_params)
    merge_attributes(data.body['RestoreDBInstanceFromDBSnapshotResult']['DBInstance'])
  else
    requires :engine

    if engine.start_with?('aurora')
      requires :cluster_id
      self.flavor_id ||= 'db.r4.large'
    else
      requires :master_username
      requires :password
      requires :allocated_storage
      self.flavor_id ||= 'db.m4.large'
    end

    data = service.create_db_instance(id, attributes_to_params)
    merge_attributes(data.body['CreateDBInstanceResult']['DBInstance'])
    true
  end
end
snapshots() click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 73
def snapshots
  requires :id
  service.snapshots(:server => self)
end
tags() click to toggle source
# File lib/fog/aws/models/rds/server.rb, line 78
def tags
  requires :id
  service.list_tags_for_resource(id).
    body['ListTagsForResourceResult']['TagList']
end