Class: AwsInstanceList::RDS
- Inherits:
-
Object
- Object
- AwsInstanceList::RDS
- Defined in:
- lib/aws_instance_list/rds.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#region ⇒ Object
Returns the value of attribute region.
Instance Method Summary collapse
- #db_descriptions(options = {}) ⇒ Object
- #db_instances(options = {}) ⇒ Object
- #db_list(options: {}, fields: nil) ⇒ Object
- #demodulize ⇒ Object
- #free_storage_space(db_instance_identifier) ⇒ Object
-
#initialize(region: 'eu-west-1') ⇒ RDS
constructor
A new instance of RDS.
- #load_db_fields ⇒ Object
- #yaml ⇒ Object
- #yaml_default ⇒ Object
- #yaml_file ⇒ Object
Constructor Details
#initialize(region: 'eu-west-1') ⇒ RDS
Returns a new instance of RDS.
10 11 12 13 14 15 16 17 18 |
# File 'lib/aws_instance_list/rds.rb', line 10 def initialize region: 'eu-west-1' @region=region @client=Aws::RDS::Client.new region: region @db_instances = [] end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
8 9 10 |
# File 'lib/aws_instance_list/rds.rb', line 8 def client @client end |
#region ⇒ Object
Returns the value of attribute region.
8 9 10 |
# File 'lib/aws_instance_list/rds.rb', line 8 def region @region end |
Instance Method Details
#db_descriptions(options = {}) ⇒ Object
20 21 22 |
# File 'lib/aws_instance_list/rds.rb', line 20 def db_descriptions ={} client.describe_db_instances() end |
#db_instances(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/aws_instance_list/rds.rb', line 24 def db_instances ={} descriptions=db_descriptions() @db_instances+=descriptions.db_instances if descriptions.marker [:marker]=descriptions.marker db_instances() else @db_instances end end |
#db_list(options: {}, fields: nil) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/aws_instance_list/rds.rb', line 35 def db_list options: {}, fields: nil fields||=load_db_fields db_instances().map do |i| fields.map { |f| i.send(f) } << free_storage_space(i.db_instance_identifier) << region end end |
#demodulize ⇒ Object
60 61 62 |
# File 'lib/aws_instance_list/rds.rb', line 60 def demodulize self.class.name.split('::').last end |
#free_storage_space(db_instance_identifier) ⇒ Object
64 65 66 67 |
# File 'lib/aws_instance_list/rds.rb', line 64 def free_storage_space db_instance_identifier metric = AwsInstanceList::Metric.new region: region metric.free_storage_space db_instance_identifier end |
#load_db_fields ⇒ Object
44 45 46 |
# File 'lib/aws_instance_list/rds.rb', line 44 def load_db_fields yaml['db']['fields'] end |
#yaml ⇒ Object
48 49 50 |
# File 'lib/aws_instance_list/rds.rb', line 48 def yaml @yaml||=yaml_default.merge(yaml_file)[demodulize] end |
#yaml_default ⇒ Object
52 53 54 |
# File 'lib/aws_instance_list/rds.rb', line 52 def yaml_default YAML.load_file AwsInstanceList::DEFAULT_SETTINGS end |
#yaml_file ⇒ Object
56 57 58 |
# File 'lib/aws_instance_list/rds.rb', line 56 def yaml_file ENV.has_key?('AWS_INSTANCE_LIST_YAML') ? YAML.load_file(ENV['AWS_INSTANCE_LIST_YAML']) : {} end |