Class: Bsdkrun::SnapshotInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/bsdkrun/types.rb

Overview

A machine snapshot: one machine's disk state, captured under a name.

A copy-on-write clone rather than a memory image — the files the guest wrote, not what it was executing. Client#branch boots a new machine from one; Client#restore puts one back.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#cpusObject (readonly)

Returns the value of attribute cpus

Returns:

  • (Object)

    the current value of cpus



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def cpus
  @cpus
end

#created_atObject (readonly)

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def id
  @id
end

#imageObject (readonly)

Returns the value of attribute image

Returns:

  • (Object)

    the current value of image



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def image
  @image
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def kind
  @kind
end

#machine_idObject (readonly)

Returns the value of attribute machine_id

Returns:

  • (Object)

    the current value of machine_id



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def machine_id
  @machine_id
end

#machine_nameObject (readonly)

Returns the value of attribute machine_name

Returns:

  • (Object)

    the current value of machine_name



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def machine_name
  @machine_name
end

#memObject (readonly)

Returns the value of attribute mem

Returns:

  • (Object)

    the current value of mem



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def mem
  @mem
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent

Returns:

  • (Object)

    the current value of parent



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def parent
  @parent
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def path
  @path
end

#portsObject (readonly)

Returns the value of attribute ports

Returns:

  • (Object)

    the current value of ports



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def ports
  @ports
end

#sizeObject (readonly)

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



111
112
113
# File 'lib/bsdkrun/types.rb', line 111

def size
  @size
end

Class Method Details

.from_graphql(s) ⇒ SnapshotInfo

Map a GraphQL Snapshot (camelCase) to a typed instance.

Parameters:

  • s (Hash)

Returns:



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/bsdkrun/types.rb', line 118

def self.from_graphql(s)
  new(
    id: s["id"].to_s,
    name: s["name"].to_s,
    machine_id: s["machineId"].to_s,
    machine_name: (s["machineName"] || "").to_s,
    kind: s["kind"].to_s,
    image: (s["image"] || "").to_s,
    path: (s["path"] || "").to_s,
    parent: s["parent"],
    description: (s["description"] || "").to_s,
    cpus: s["cpus"].to_i,
    mem: s["mem"].to_i,
    ports: (s["ports"] || []).map { |p| PortForward.from_row(p) },
    size: s["size"],
    created_at: s["createdAt"].to_i
  )
end

.from_row(row) ⇒ SnapshotInfo

Map a bsdkrun snapshots --json row (snake_case).

Parameters:

  • row (Hash)

Returns:



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/bsdkrun/types.rb', line 140

def self.from_row(row)
  new(
    id: row["id"].to_s,
    name: row["name"].to_s,
    machine_id: row["machine_id"].to_s,
    machine_name: (row["machine_name"] || "").to_s,
    kind: row["kind"].to_s,
    image: (row["image"] || "").to_s,
    path: (row["path"] || "").to_s,
    parent: row["parent"],
    description: (row["description"] || "").to_s,
    cpus: row["cpus"].to_i,
    mem: row["mem"].to_i,
    ports: (row["ports"] || []).map { |p| PortForward.from_row(p) },
    size: row["size"],
    created_at: row["created_at"].to_i
  )
end