Class: Aws::RDS::DBSnapshot
- Inherits:
-
Object
- Object
- Aws::RDS::DBSnapshot
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-rds/db_snapshot.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#allocated_storage ⇒ Integer
Specifies the allocated storage size in gibibytes (GiB).
-
#availability_zone ⇒ String
Specifies the name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
-
#db_snapshot_arn ⇒ String
The Amazon Resource Name (ARN) for the DB snapshot.
-
#dbi_resource_id ⇒ String
The identifier for the source DB instance, which can’t be changed and which is unique to an AWS Region.
-
#encrypted ⇒ Boolean
Specifies whether the DB snapshot is encrypted.
-
#engine ⇒ String
Specifies the name of the database engine.
-
#engine_version ⇒ String
Specifies the version of the database engine.
-
#iam_database_authentication_enabled ⇒ Boolean
True if mapping of AWS Identity and Access Management (IAM) accounts to database accounts is enabled, and otherwise false.
-
#instance_create_time ⇒ Time
Specifies the time in Coordinated Universal Time (UTC) when the DB instance, from which the snapshot was taken, was created.
- #instance_id ⇒ String (also: #db_instance_identifier)
-
#iops ⇒ Integer
Specifies the Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
-
#kms_key_id ⇒ String
If ‘Encrypted` is true, the AWS KMS key identifier for the encrypted DB snapshot.
-
#license_model ⇒ String
License model information for the restored DB instance.
-
#master_username ⇒ String
Provides the master username for the DB snapshot.
-
#option_group_name ⇒ String
Provides the option group name for the DB snapshot.
-
#percent_progress ⇒ Integer
The percentage of the estimated data that has been transferred.
-
#port ⇒ Integer
Specifies the port that the database engine was listening on at the time of the snapshot.
-
#processor_features ⇒ Array<Types::ProcessorFeature>
The number of CPU cores and the number of threads per core for the DB instance class of the DB instance when the DB snapshot was created.
-
#snapshot_create_time ⇒ Time
Specifies when the snapshot was taken in Coordinated Universal Time (UTC).
- #snapshot_id ⇒ String (also: #db_snapshot_identifier)
-
#snapshot_type ⇒ String
Provides the type of the DB snapshot.
-
#source_db_snapshot_identifier ⇒ String
The DB snapshot Amazon Resource Name (ARN) that the DB snapshot was copied from.
-
#source_region ⇒ String
The AWS Region that the DB snapshot was created in or copied from.
-
#status ⇒ String
Specifies the status of this DB snapshot.
-
#storage_type ⇒ String
Specifies the storage type associated with DB snapshot.
-
#tag_list ⇒ Array<Types::Tag>
A list of tags.
-
#tde_credential_arn ⇒ String
The ARN from the key store with which to associate the instance for TDE encryption.
-
#timezone ⇒ String
The time zone of the DB snapshot.
-
#vpc_id ⇒ String
Provides the VPC ID associated with the DB snapshot.
Actions collapse
- #copy(options = {}) ⇒ DBSnapshot
- #create(options = {}) ⇒ DBSnapshot
- #delete(options = {}) ⇒ DBSnapshot
- #restore(options = {}) ⇒ DBInstance
- #subscribe_to(options = {}) ⇒ EventSubscription
- #unsubscribe_from(options = {}) ⇒ EventSubscription
Associations collapse
- #attributes(options = {}) ⇒ DBSnapshotAttribute::Collection
- #events(options = {}) ⇒ Event::Collection
- #identifiers ⇒ Object deprecated private Deprecated.
- #instance ⇒ DBInstance
- #option_group ⇒ OptionGroup?
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::DBSnapshot
Returns the data for this DBSnapshot.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ DBSnapshot
constructor
A new instance of DBSnapshot.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current DBSnapshot.
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::RDS::Client] #wait_until instead
Constructor Details
#initialize(instance_id, snapshot_id, options = {}) ⇒ DBSnapshot #initialize(options = {}) ⇒ DBSnapshot
Returns a new instance of DBSnapshot.
24 25 26 27 28 29 30 31 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 24 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @instance_id = extract_instance_id(args, ) @snapshot_id = extract_snapshot_id(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#allocated_storage ⇒ Integer
Specifies the allocated storage size in gibibytes (GiB).
62 63 64 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 62 def allocated_storage data[:allocated_storage] end |
#attributes(options = {}) ⇒ DBSnapshotAttribute::Collection
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 926 def attributes( = {}) batches = Enumerator.new do |y| batch = [] = .merge(db_snapshot_identifier: @snapshot_id) resp = @client.describe_db_snapshot_attributes() resp.data.db_snapshot_attributes_result.db_snapshot_attributes.each do |d| batch << DBSnapshotAttribute.new( snapshot_id: @snapshot_id, name: d.attribute_name, data: d, client: @client ) end y.yield(batch) end DBSnapshotAttribute::Collection.new(batches) end |
#availability_zone ⇒ String
Specifies the name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
82 83 84 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 82 def availability_zone data[:availability_zone] end |
#client ⇒ Client
235 236 237 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 235 def client @client end |
#copy(options = {}) ⇒ DBSnapshot
541 542 543 544 545 546 547 548 549 550 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 541 def copy( = {}) = .merge(source_db_snapshot_identifier: @snapshot_id) resp = @client.copy_db_snapshot() DBSnapshot.new( instance_id: resp.data.db_snapshot.db_instance_identifier, snapshot_id: resp.data.db_snapshot.db_snapshot_identifier, data: resp.data.db_snapshot, client: @client ) end |
#create(options = {}) ⇒ DBSnapshot
385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 385 def create( = {}) = .merge( db_instance_identifier: @instance_id, db_snapshot_identifier: @snapshot_id ) resp = @client.create_db_snapshot() DBSnapshot.new( instance_id: resp.data.db_snapshot.db_instance_identifier, snapshot_id: resp.data.db_snapshot.db_snapshot_identifier, data: resp.data.db_snapshot, client: @client ) end |
#data ⇒ Types::DBSnapshot
Returns the data for this Aws::RDS::DBSnapshot. Calls Client#describe_db_snapshots if #data_loaded? is ‘false`.
255 256 257 258 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 255 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
263 264 265 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 263 def data_loaded? !!@data end |
#db_snapshot_arn ⇒ String
The Amazon Resource Name (ARN) for the DB snapshot.
187 188 189 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 187 def db_snapshot_arn data[:db_snapshot_arn] end |
#dbi_resource_id ⇒ String
The identifier for the source DB instance, which can’t be changed and which is unique to an AWS Region.
217 218 219 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 217 def dbi_resource_id data[:dbi_resource_id] end |
#delete(options = {}) ⇒ DBSnapshot
557 558 559 560 561 562 563 564 565 566 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 557 def delete( = {}) = .merge(db_snapshot_identifier: @snapshot_id) resp = @client.delete_db_snapshot() DBSnapshot.new( instance_id: resp.data.db_snapshot.db_instance_identifier, snapshot_id: resp.data.db_snapshot.db_snapshot_identifier, data: resp.data.db_snapshot, client: @client ) end |
#encrypted ⇒ Boolean
Specifies whether the DB snapshot is encrypted.
171 172 173 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 171 def encrypted data[:encrypted] end |
#engine ⇒ String
Specifies the name of the database engine.
56 57 58 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 56 def engine data[:engine] end |
#engine_version ⇒ String
Specifies the version of the database engine.
107 108 109 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 107 def engine_version data[:engine_version] end |
#events(options = {}) ⇒ Event::Collection
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 989 def events( = {}) batches = Enumerator.new do |y| = .merge( source_type: "db-snapshot", source_identifier: @snapshot_id ) resp = @client.describe_events() resp.each_page do |page| batch = [] page.data.events.each do |e| batch << Event.new( source_id: e.source_identifier, date: e.date, data: e, client: @client ) end y.yield(batch) end end Event::Collection.new(batches) end |
#iam_database_authentication_enabled ⇒ Boolean
True if mapping of AWS Identity and Access Management (IAM) accounts to database accounts is enabled, and otherwise false.
203 204 205 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 203 def iam_database_authentication_enabled data[:iam_database_authentication_enabled] end |
#identifiers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1034 1035 1036 1037 1038 1039 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 1034 def identifiers { instance_id: @instance_id, snapshot_id: @snapshot_id } end |
#instance ⇒ DBInstance
1013 1014 1015 1016 1017 1018 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 1013 def instance DBInstance.new( id: @instance_id, client: @client ) end |
#instance_create_time ⇒ Time
Specifies the time in Coordinated Universal Time (UTC) when the DB instance, from which the snapshot was taken, was created.
95 96 97 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 95 def instance_create_time data[:instance_create_time] end |
#instance_id ⇒ String Also known as: db_instance_identifier
36 37 38 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 36 def instance_id @instance_id end |
#iops ⇒ Integer
Specifies the Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
126 127 128 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 126 def iops data[:iops] end |
#kms_key_id ⇒ String
If ‘Encrypted` is true, the AWS KMS key identifier for the encrypted DB snapshot.
The AWS KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the AWS KMS customer master key (CMK).
181 182 183 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 181 def kms_key_id data[:kms_key_id] end |
#license_model ⇒ String
License model information for the restored DB instance.
113 114 115 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 113 def license_model data[:license_model] end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::RDS::DBSnapshot. Returns ‘self` making it possible to chain methods.
db_snapshot.reload.data
245 246 247 248 249 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 245 def load resp = @client.describe_db_snapshots(db_snapshot_identifier: @snapshot_id) @data = resp.db_snapshots[0] self end |
#master_username ⇒ String
Provides the master username for the DB snapshot.
101 102 103 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 101 def master_username data[:master_username] end |
#option_group ⇒ OptionGroup?
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 1021 def option_group if data[:db_snapshot][:option_group_name] OptionGroup.new( name: data[:db_snapshot][:option_group_name], client: @client ) else nil end end |
#option_group_name ⇒ String
Provides the option group name for the DB snapshot.
132 133 134 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 132 def option_group_name data[:option_group_name] end |
#percent_progress ⇒ Integer
The percentage of the estimated data that has been transferred.
138 139 140 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 138 def percent_progress data[:percent_progress] end |
#port ⇒ Integer
Specifies the port that the database engine was listening on at the time of the snapshot.
75 76 77 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 75 def port data[:port] end |
#processor_features ⇒ Array<Types::ProcessorFeature>
The number of CPU cores and the number of threads per core for the DB instance class of the DB instance when the DB snapshot was created.
210 211 212 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 210 def processor_features data[:processor_features] end |
#restore(options = {}) ⇒ DBInstance
869 870 871 872 873 874 875 876 877 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 869 def restore( = {}) = .merge(db_snapshot_identifier: @snapshot_id) resp = @client.restore_db_instance_from_db_snapshot() DBInstance.new( id: resp.data.db_instance.db_instance_identifier, data: resp.data.db_instance, client: @client ) end |
#snapshot_create_time ⇒ Time
Specifies when the snapshot was taken in Coordinated Universal Time (UTC).
50 51 52 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 50 def snapshot_create_time data[:snapshot_create_time] end |
#snapshot_id ⇒ String Also known as: db_snapshot_identifier
42 43 44 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 42 def snapshot_id @snapshot_id end |
#snapshot_type ⇒ String
Provides the type of the DB snapshot.
119 120 121 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 119 def snapshot_type data[:snapshot_type] end |
#source_db_snapshot_identifier ⇒ String
The DB snapshot Amazon Resource Name (ARN) that the DB snapshot was copied from. It only has value in case of cross-customer or cross-region copy.
152 153 154 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 152 def source_db_snapshot_identifier data[:source_db_snapshot_identifier] end |
#source_region ⇒ String
The AWS Region that the DB snapshot was created in or copied from.
144 145 146 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 144 def source_region data[:source_region] end |
#status ⇒ String
Specifies the status of this DB snapshot.
68 69 70 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 68 def status data[:status] end |
#storage_type ⇒ String
Specifies the storage type associated with DB snapshot.
158 159 160 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 158 def storage_type data[:storage_type] end |
#subscribe_to(options = {}) ⇒ EventSubscription
889 890 891 892 893 894 895 896 897 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 889 def subscribe_to( = {}) = .merge(source_identifier: @snapshot_id) resp = @client.add_source_identifier_to_subscription() EventSubscription.new( name: resp.data.event_subscription.cust_subscription_id, data: resp.data.event_subscription, client: @client ) end |
#tag_list ⇒ Array<Types::Tag>
A list of tags. For more information, see [Tagging Amazon RDS Resources] in the *Amazon RDS User Guide.*
[1]: docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html
228 229 230 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 228 def tag_list data[:tag_list] end |
#tde_credential_arn ⇒ String
The ARN from the key store with which to associate the instance for TDE encryption.
165 166 167 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 165 def tde_credential_arn data[:tde_credential_arn] end |
#timezone ⇒ String
The time zone of the DB snapshot. In most cases, the ‘Timezone` element is empty. `Timezone` content appears only for snapshots taken from Microsoft SQL Server DB instances that were created with a time zone specified.
196 197 198 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 196 def timezone data[:timezone] end |
#unsubscribe_from(options = {}) ⇒ EventSubscription
909 910 911 912 913 914 915 916 917 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 909 def unsubscribe_from( = {}) = .merge(source_identifier: @snapshot_id) resp = @client.remove_source_identifier_from_subscription() EventSubscription.new( name: resp.data.event_subscription.cust_subscription_id, data: resp.data.event_subscription, client: @client ) end |
#vpc_id ⇒ String
Provides the VPC ID associated with the DB snapshot.
88 89 90 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 88 def vpc_id data[:vpc_id] end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::RDS::Client] #wait_until instead
The waiting operation is performed on a copy. The original resource remains unchanged.
Waiter polls an API operation until a resource enters a desired state.
## Basic Usage
Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop until condition is true
resource.wait_until() {|resource| condition}
## Example
instance.wait_until(max_attempts:10, delay:5) do |instance|
instance.state.name == 'running'
end
## Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:
# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}
## Callbacks
You can be notified before each polling attempt and before each delay. If you throw ‘:success` or `:failure` from these callbacks, it will terminate the waiter.
started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
# disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}
## Handling Errors
When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.
begin
resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
attempts attempt in seconds invoked before each attempt invoked before each wait
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/aws-sdk-rds/db_snapshot.rb', line 347 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Waiters::Waiter.new().wait({}) end |