Class: Fog::AWS::RDS::Cluster

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#storage_encryptedObject

not in the response



23
24
25
# File 'lib/fog/aws/models/rds/cluster.rb', line 23

def storage_encrypted
  @storage_encrypted
end

Instance Method Details

#attributes_to_paramsObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fog/aws/models/rds/cluster.rb', line 69

def attributes_to_params
  options = {
    'AllocatedStorage'           => allocated_storage,
    'BackupRetentionPeriod'      => backup_retention_period,
    'DBClusterIdentifier'        => identity,
    'DBClusterParameterGroup'    => db_cluster_parameter_group,
    'DBSubnetGroup'              => db_subnet_group,
    'Endpoint'                   => endpoint,
    'Engine'                     => engine,
    'EngineVersion'              => engine_version,
    'MasterUserPassword'         => password,
    'MasterUsername'             => master_username,
    'PreferredBackupWindow'      => preferred_backup_window,
    'PreferredMaintenanceWindow' => preferred_maintenance_window,
    'Status'                     => state,
    'StorageEncrypted'           => storage_encrypted,
    'VpcSecurityGroups'          => vpc_security_groups,
  }

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

#destroy(snapshot_identifier = nil) ⇒ Object



52
53
54
55
56
# File 'lib/fog/aws/models/rds/cluster.rb', line 52

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

#has_replica?(replica_name) ⇒ Boolean

Returns:

  • (Boolean)


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

def has_replica?(replica_name)
  replicas.detect { |replica| replica.id == replica_name }
end

#masterObject



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

def master
  db_cluster_members.detect { |member| member["master"] }
end

#ready?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/fog/aws/models/rds/cluster.rb', line 25

def ready?
  state == "available"
end

#replicasObject



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

def replicas
  servers(db_cluster_members.select { |member| !member["master"] })
end

#saveObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/aws/models/rds/cluster.rb', line 58

def save
  requires :id
  requires :engine
  requires :master_username
  requires :password

  data = service.create_db_cluster(id, attributes_to_params)
  merge_attributes(data.body['CreateDBClusterResult']['DBCluster'])
  true
end

#servers(set = db_cluster_members) ⇒ Object



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

def servers(set=db_cluster_members)
  set.map do |member|
    service.servers.get(member['DBInstanceIdentifier'])
  end
end

#snapshotsObject



29
30
31
32
# File 'lib/fog/aws/models/rds/cluster.rb', line 29

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