Class: Xshellz::SandboxProcs

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

Overview

Top processes + session info for a running sandbox (+Sandbox#procs+).

procs is an Array; sessions counts active SSH sessions; agents lists detected agent processes (e.g. "claude") by name.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#agentsObject

Returns the value of attribute agents

Returns:

  • (Object)

    the current value of agents



117
118
119
# File 'lib/xshellz/models.rb', line 117

def agents
  @agents
end

#disk_allowed_mbObject

Returns the value of attribute disk_allowed_mb

Returns:

  • (Object)

    the current value of disk_allowed_mb



117
118
119
# File 'lib/xshellz/models.rb', line 117

def disk_allowed_mb
  @disk_allowed_mb
end

#disk_used_mbObject

Returns the value of attribute disk_used_mb

Returns:

  • (Object)

    the current value of disk_used_mb



117
118
119
# File 'lib/xshellz/models.rb', line 117

def disk_used_mb
  @disk_used_mb
end

#procsObject

Returns the value of attribute procs

Returns:

  • (Object)

    the current value of procs



117
118
119
# File 'lib/xshellz/models.rb', line 117

def procs
  @procs
end

#sessionsObject

Returns the value of attribute sessions

Returns:

  • (Object)

    the current value of sessions



117
118
119
# File 'lib/xshellz/models.rb', line 117

def sessions
  @sessions
end

Class Method Details

.from_api(payload) ⇒ Object

Build a SandboxProcs from the API's JSON payload (tolerant of missing keys).



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/xshellz/models.rb', line 127

def self.from_api(payload)
  payload ||= {}
  rows = payload["procs"]
  rows = [] unless rows.is_a?(Array)
  new(
    procs: rows.map { |row| ProcessInfo.from_api(row) },
    sessions: (payload["sessions"] || 0).to_i,
    agents: Array(payload["agents"]).map(&:to_s),
    disk_used_mb: (payload["disk_used_mb"] || 0).to_i,
    disk_allowed_mb: (payload["disk_allowed_mb"] || 0).to_i
  )
end