Class: Xshellz::SandboxInfo

Inherits:
Struct
  • Object
show all
Defined in:
lib/xshellz/models.rb

Overview

A sandbox as reported by the control plane (snake_case wire shape).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#always_onObject

Returns the value of attribute always_on

Returns:

  • (Object)

    the current value of always_on



16
17
18
# File 'lib/xshellz/models.rb', line 16

def always_on
  @always_on
end

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



16
17
18
# File 'lib/xshellz/models.rb', line 16

def created_at
  @created_at
end

#gvisorObject

Returns the value of attribute gvisor

Returns:

  • (Object)

    the current value of gvisor



16
17
18
# File 'lib/xshellz/models.rb', line 16

def gvisor
  @gvisor
end

#isolationObject

Returns the value of attribute isolation

Returns:

  • (Object)

    the current value of isolation



16
17
18
# File 'lib/xshellz/models.rb', line 16

def isolation
  @isolation
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



16
17
18
# File 'lib/xshellz/models.rb', line 16

def name
  @name
end

#spawned_atObject

Returns the value of attribute spawned_at

Returns:

  • (Object)

    the current value of spawned_at



16
17
18
# File 'lib/xshellz/models.rb', line 16

def spawned_at
  @spawned_at
end

#ssh_commandObject

Returns the value of attribute ssh_command

Returns:

  • (Object)

    the current value of ssh_command



16
17
18
# File 'lib/xshellz/models.rb', line 16

def ssh_command
  @ssh_command
end

#ssh_hostObject

Returns the value of attribute ssh_host

Returns:

  • (Object)

    the current value of ssh_host



16
17
18
# File 'lib/xshellz/models.rb', line 16

def ssh_host
  @ssh_host
end

#ssh_portObject

Returns the value of attribute ssh_port

Returns:

  • (Object)

    the current value of ssh_port



16
17
18
# File 'lib/xshellz/models.rb', line 16

def ssh_port
  @ssh_port
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



16
17
18
# File 'lib/xshellz/models.rb', line 16

def status
  @status
end

#trial_hours_remainingObject

Returns the value of attribute trial_hours_remaining

Returns:

  • (Object)

    the current value of trial_hours_remaining



16
17
18
# File 'lib/xshellz/models.rb', line 16

def trial_hours_remaining
  @trial_hours_remaining
end

#uuidObject

Returns the value of attribute uuid

Returns:

  • (Object)

    the current value of uuid



16
17
18
# File 'lib/xshellz/models.rb', line 16

def uuid
  @uuid
end

#web_terminal_readyObject

Returns the value of attribute web_terminal_ready

Returns:

  • (Object)

    the current value of web_terminal_ready



16
17
18
# File 'lib/xshellz/models.rb', line 16

def web_terminal_ready
  @web_terminal_ready
end

Class Method Details

.from_api(payload) ⇒ Object

Build a SandboxInfo from the API's JSON payload.

Tolerant of missing keys so a newer/older API version never breaks deserialization.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/xshellz/models.rb', line 36

def self.from_api(payload)
  payload ||= {}
  port = payload["ssh_port"]
  new(
    uuid: payload["uuid"].to_s,
    name: payload["name"].to_s,
    status: payload["status"].to_s,
    ssh_command: payload["ssh_command"],
    ssh_host: payload["ssh_host"],
    ssh_port: port.nil? ? nil : Integer(port),
    web_terminal_ready: !!payload["web_terminal_ready"],
    always_on: !!payload["always_on"],
    trial_hours_remaining: (payload["trial_hours_remaining"] || 0.0).to_f,
    spawned_at: payload["spawned_at"],
    created_at: payload["created_at"],
    isolation: payload["isolation"],
    gvisor: !!payload["gvisor"]
  )
end