Class: Xshellz::SandboxInfo
- Inherits:
-
Struct
- Object
- Struct
- Xshellz::SandboxInfo
- Defined in:
- lib/xshellz/models.rb
Overview
A sandbox as reported by the control plane (snake_case wire shape).
Instance Attribute Summary collapse
-
#always_on ⇒ Object
Returns the value of attribute always_on.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#gvisor ⇒ Object
Returns the value of attribute gvisor.
-
#isolation ⇒ Object
Returns the value of attribute isolation.
-
#name ⇒ Object
Returns the value of attribute name.
-
#spawned_at ⇒ Object
Returns the value of attribute spawned_at.
-
#ssh_command ⇒ Object
Returns the value of attribute ssh_command.
-
#ssh_host ⇒ Object
Returns the value of attribute ssh_host.
-
#ssh_port ⇒ Object
Returns the value of attribute ssh_port.
-
#status ⇒ Object
Returns the value of attribute status.
-
#trial_hours_remaining ⇒ Object
Returns the value of attribute trial_hours_remaining.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#web_terminal_ready ⇒ Object
Returns the value of attribute web_terminal_ready.
Class Method Summary collapse
-
.from_api(payload) ⇒ Object
Build a
SandboxInfofrom the API's JSON payload.
Instance Attribute Details
#always_on ⇒ Object
Returns the value of attribute always_on
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def always_on @always_on end |
#created_at ⇒ Object
Returns the value of attribute created_at
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def created_at @created_at end |
#gvisor ⇒ Object
Returns the value of attribute gvisor
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def gvisor @gvisor end |
#isolation ⇒ Object
Returns the value of attribute isolation
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def isolation @isolation end |
#name ⇒ Object
Returns the value of attribute name
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def name @name end |
#spawned_at ⇒ Object
Returns the value of attribute spawned_at
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def spawned_at @spawned_at end |
#ssh_command ⇒ Object
Returns the value of attribute ssh_command
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def ssh_command @ssh_command end |
#ssh_host ⇒ Object
Returns the value of attribute ssh_host
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def ssh_host @ssh_host end |
#ssh_port ⇒ Object
Returns the value of attribute ssh_port
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def ssh_port @ssh_port end |
#status ⇒ Object
Returns the value of attribute status
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def status @status end |
#trial_hours_remaining ⇒ Object
Returns the value of attribute trial_hours_remaining
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def trial_hours_remaining @trial_hours_remaining end |
#uuid ⇒ Object
Returns the value of attribute uuid
16 17 18 |
# File 'lib/xshellz/models.rb', line 16 def uuid @uuid end |
#web_terminal_ready ⇒ Object
Returns the value of attribute 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 |