Class: HCloud::StorageBoxSnapshot
- Inherits:
-
Resource
- Object
- Resource
- HCloud::StorageBoxSnapshot
show all
- Defined in:
- lib/hcloud/resources/storage_box_snapshot.rb
Overview
Represents a storage box’s snapshot
List all snapshots
storage_box = HCloud::StorageBox.find(1)
storage_box.snapshots
Search snapshots
storage_box = HCloud::StorageBox.find(1)
storage_box.snapshots.where(name: "monthly_backup")
storage_box = HCloud::StorageBox.find(1)
storage_box.snapshots.where(label_selector: "environment=production")
Find snapshot by ID
storage_box = HCloud::StorageBox.find(1)
storage_box.snapshots.find(1)
Create snapshot
storage_box = HCloud::StorageBox.find(1)
snapshot = storage_box.snapshots.new(description: "my_snapshot")
snapshot.create
snapshot.created?
# => false
Note: this method returns a {HCloud::Action} instance rather than the created resource itself, as the snapshot is created asynchronously.
Reload the snapshot to check if it was created successfully.
snapshot.reload
snapshot.created?
# => true
snapshot = storage_box.snapshots.create(description: "my_snapshot")
# => #<HCloud::Action id: 1, ...>
Note: this method returns a {HCloud::Action} instance rather than the created resource itself
snapshot = HCloud::StorageBox::Snapshot.create(storage_box: 1, description: "my_snapshot")
# => #<HCloud::Action id: 1, ...>
Note: this method returns a {HCloud::Action} instance rather than the created resource itself
Update snapshot
storage_box = HCloud::StorageBox.find(1)
snapshot = storage_box.snapshots.find(1)
snapshot.description = "another_snapshot"
snapshot.update
Delete snapshot
storage_box = HCloud::StorageBox.find(1)
snapshot = storage_box.snapshots.find(1)
snapshot.delete
# => #<HCloud::Action id: 1, ...>
snapshot.deleted?
# => true
Note: this method returns a {HCloud::Action} instance rather than the deleted resource itself
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
#==, attribute, #initialize, #inspect, #to_h
Class Method Details
.client ⇒ Object
104
105
106
|
# File 'lib/hcloud/resources/storage_box_snapshot.rb', line 104
def self.client
HCloud::Client.connection.storage_box_client
end
|
.resource_name ⇒ Object
100
101
102
|
# File 'lib/hcloud/resources/storage_box_snapshot.rb', line 100
def self.resource_name
"snapshot"
end
|
Instance Method Details
#creatable_attributes ⇒ Object
92
93
94
|
# File 'lib/hcloud/resources/storage_box_snapshot.rb', line 92
def creatable_attributes
[:description]
end
|
#updatable_attributes ⇒ Object
96
97
98
|
# File 'lib/hcloud/resources/storage_box_snapshot.rb', line 96
def updatable_attributes
[:description, :labels]
end
|