Class: HCloud::Image
Overview
Represents a image
List all images
HCloud::Image.all
Sort images
HCloud::Image.sort(name: :desc)
HCloud::Image.sort(:id, name: :asc)
Search images
HCloud::Image.where(name: "my_image")
HCloud::Image.where(status: "available", include_deprecated: false)
HCloud::Image.where(type: "backup", bound_to: 1)
Find image by ID
HCloud::Image.find(1)
Update image
image = HCloud::Image.find(1)
image.type = "snapshot"
image.description = "#{image.description} (snapshot)"
image.update
Delete image
image = HCloud::Image.find(1)
image.delete
image.deleted?
Actions
List actions
actions = HCloud::Image.find(1).actions
Sort actions
HCloud::Image.find(1).actions.sort(finished: :desc)
HCloud::Image.find(1).actions.sort(:command, finished: :asc)
Search actions
HCloud::Image.find(1).actions.where(command: "change_protection")
HCloud::Image.find(1).actions.where(status: "success")
Find action by ID
HCloud::Image.find(1).actions.find(1)
Resource-specific actions
Change protection
HCloud::Image.find(1).change_protection(delete: true)
Instance Method Summary
collapse
Methods inherited from Resource
#==, attribute, client, #initialize, #inspect, resource_name, #to_h
Instance Method Details
#created? ⇒ Boolean
120
121
122
|
# File 'lib/hcloud/resources/image.rb', line 120
def created?
created.present?
end
|
#deleted? ⇒ Boolean
124
125
126
|
# File 'lib/hcloud/resources/image.rb', line 124
def deleted?
deleted.present?
end
|
#deprecated? ⇒ Boolean
128
129
130
|
# File 'lib/hcloud/resources/image.rb', line 128
def deprecated?
deprecated.present?
end
|
#rapid_deploy? ⇒ Boolean
132
133
134
|
# File 'lib/hcloud/resources/image.rb', line 132
def rapid_deploy?
rapid_deploy.present?
end
|
#updatable_attributes ⇒ Object
136
137
138
|
# File 'lib/hcloud/resources/image.rb', line 136
def updatable_attributes
[:description, :type, :labels]
end
|