Class: Daytona::Snapshot
- Inherits:
-
Object
- Object
- Daytona::Snapshot
- Defined in:
- lib/daytona/common/snapshot.rb
Constant Summary collapse
- SNAPSHOT_ID_PATTERN =
Matches RFC 4122 UUIDs (versions 1-5) and the nil UUID - the same set the Daytona API recognizes as snapshot IDs. Anything else is treated as a name.
Regexp.new( '\A(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}' \ '|00000000-0000-0000-0000-000000000000)\z', Regexp::IGNORECASE ).freeze
Instance Attribute Summary collapse
-
#build_info ⇒ DaytonaApiClient::BuildInfo?
readonly
Build information for the snapshot.
-
#cpu ⇒ Float
readonly
CPU of the Snapshot.
-
#created_at ⇒ String
readonly
Timestamp when the Snapshot was created.
-
#disk ⇒ Float
readonly
Disk of the Snapshot in GiB.
-
#entrypoint ⇒ Array<String>?
readonly
Entrypoint of the Snapshot.
-
#error_reason ⇒ String?
readonly
Error reason of the Snapshot.
-
#general ⇒ Boolean?
readonly
Whether the Snapshot is general.
-
#gpu ⇒ Float
readonly
GPU of the Snapshot.
-
#id ⇒ String
readonly
Unique identifier for the Snapshot.
-
#image_name ⇒ String
readonly
Name of the Image of the Snapshot.
-
#last_used_at ⇒ String?
readonly
Timestamp when the Snapshot was last used.
-
#mem ⇒ Float
readonly
Memory of the Snapshot in GiB.
-
#name ⇒ String
readonly
Name of the Snapshot.
-
#organization_id ⇒ String?
readonly
Organization ID of the Snapshot.
-
#size ⇒ Float?
readonly
Size of the Snapshot.
-
#source_sandbox_id ⇒ String?
readonly
ID of the sandbox the Snapshot was created from.
-
#state ⇒ String
readonly
State of the Snapshot.
-
#updated_at ⇒ String
readonly
Timestamp when the Snapshot was last updated.
Class Method Summary collapse
-
.from_dto(dto) ⇒ Daytona::Snapshot
Creates a Snapshot instance from a SnapshotDto.
-
.id?(value) ⇒ Boolean
Whether the given value looks like a Snapshot ID (a UUID) rather than a name.
Instance Method Summary collapse
-
#initialize(snapshot_dto) ⇒ Snapshot
constructor
A new instance of Snapshot.
Constructor Details
#initialize(snapshot_dto) ⇒ Snapshot
Returns a new instance of Snapshot.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/daytona/common/snapshot.rb', line 109 def initialize(snapshot_dto) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength @id = snapshot_dto.id @organization_id = snapshot_dto.organization_id @general = snapshot_dto.general @name = snapshot_dto.name @image_name = snapshot_dto.image_name @state = snapshot_dto.state @size = snapshot_dto.size @entrypoint = snapshot_dto.entrypoint @cpu = snapshot_dto.cpu @gpu = snapshot_dto.gpu @mem = snapshot_dto.mem @disk = snapshot_dto.disk @error_reason = snapshot_dto.error_reason @created_at = snapshot_dto.created_at @updated_at = snapshot_dto.updated_at @last_used_at = snapshot_dto.last_used_at @build_info = snapshot_dto.build_info @source_sandbox_id = snapshot_dto.source_sandbox_id end |
Instance Attribute Details
#build_info ⇒ DaytonaApiClient::BuildInfo? (readonly)
Returns Build information for the snapshot.
103 104 105 |
# File 'lib/daytona/common/snapshot.rb', line 103 def build_info @build_info end |
#cpu ⇒ Float (readonly)
Returns CPU of the Snapshot.
79 80 81 |
# File 'lib/daytona/common/snapshot.rb', line 79 def cpu @cpu end |
#created_at ⇒ String (readonly)
Returns Timestamp when the Snapshot was created.
94 95 96 |
# File 'lib/daytona/common/snapshot.rb', line 94 def created_at @created_at end |
#disk ⇒ Float (readonly)
Returns Disk of the Snapshot in GiB.
88 89 90 |
# File 'lib/daytona/common/snapshot.rb', line 88 def disk @disk end |
#entrypoint ⇒ Array<String>? (readonly)
Returns Entrypoint of the Snapshot.
76 77 78 |
# File 'lib/daytona/common/snapshot.rb', line 76 def entrypoint @entrypoint end |
#error_reason ⇒ String? (readonly)
Returns Error reason of the Snapshot.
91 92 93 |
# File 'lib/daytona/common/snapshot.rb', line 91 def error_reason @error_reason end |
#general ⇒ Boolean? (readonly)
Returns Whether the Snapshot is general.
61 62 63 |
# File 'lib/daytona/common/snapshot.rb', line 61 def general @general end |
#gpu ⇒ Float (readonly)
Returns GPU of the Snapshot.
82 83 84 |
# File 'lib/daytona/common/snapshot.rb', line 82 def gpu @gpu end |
#id ⇒ String (readonly)
Returns Unique identifier for the Snapshot.
55 56 57 |
# File 'lib/daytona/common/snapshot.rb', line 55 def id @id end |
#image_name ⇒ String (readonly)
Returns Name of the Image of the Snapshot.
67 68 69 |
# File 'lib/daytona/common/snapshot.rb', line 67 def image_name @image_name end |
#last_used_at ⇒ String? (readonly)
Returns Timestamp when the Snapshot was last used.
100 101 102 |
# File 'lib/daytona/common/snapshot.rb', line 100 def last_used_at @last_used_at end |
#mem ⇒ Float (readonly)
Returns Memory of the Snapshot in GiB.
85 86 87 |
# File 'lib/daytona/common/snapshot.rb', line 85 def mem @mem end |
#name ⇒ String (readonly)
Returns Name of the Snapshot.
64 65 66 |
# File 'lib/daytona/common/snapshot.rb', line 64 def name @name end |
#organization_id ⇒ String? (readonly)
Returns Organization ID of the Snapshot.
58 59 60 |
# File 'lib/daytona/common/snapshot.rb', line 58 def organization_id @organization_id end |
#size ⇒ Float? (readonly)
Returns Size of the Snapshot.
73 74 75 |
# File 'lib/daytona/common/snapshot.rb', line 73 def size @size end |
#source_sandbox_id ⇒ String? (readonly)
Returns ID of the sandbox the Snapshot was created from.
106 107 108 |
# File 'lib/daytona/common/snapshot.rb', line 106 def source_sandbox_id @source_sandbox_id end |
#state ⇒ String (readonly)
Returns State of the Snapshot.
70 71 72 |
# File 'lib/daytona/common/snapshot.rb', line 70 def state @state end |
#updated_at ⇒ String (readonly)
Returns Timestamp when the Snapshot was last updated.
97 98 99 |
# File 'lib/daytona/common/snapshot.rb', line 97 def updated_at @updated_at end |
Class Method Details
.from_dto(dto) ⇒ Daytona::Snapshot
Creates a Snapshot instance from a SnapshotDto
134 |
# File 'lib/daytona/common/snapshot.rb', line 134 def self.from_dto(dto) = new(dto) |
.id?(value) ⇒ Boolean
Whether the given value looks like a Snapshot ID (a UUID) rather than a name.
140 |
# File 'lib/daytona/common/snapshot.rb', line 140 def self.id?(value) = value.is_a?(String) && SNAPSHOT_ID_PATTERN.match?(value) |