class Bio::BaseSpace::AppSession

App sessions records when an App is being launched.

Public Class Methods

new() click to toggle source

Create a new AppSession instance.

# File lib/basespace/model/app_session.rb, line 23
def initialize
  @swagger_types = {
    'Id'             => 'str',
    'Href'           => 'str',
    'Type'           => 'str',
    'UserCreatedBy'  => 'User',
    'DateCreated'    => 'datetime',
    'Status'         => 'str',
    'StatusSummary'  => 'str',
    'Application'    => 'Application',
    'References'     => 'list<AppSessionLaunchObject>',
  }
  @attributes = {
    'Id'             => nil,
    'Href'           => nil, # The URI of BaseSpace
    'Type'           => nil,
    # TODO UserUserCreatedBy in Python code would be typo of UserCreatedBy (bug in Python SDK)
    'UserCreatedBy'  => nil, # The user that triggered your application
    'DateCreated'    => nil, # The datetime the user acted in BaseSpace
    'Status'         => nil,
    'StatusSummary'  => nil,
    'Application'    => nil,
    'References'     => nil,
  }
end

Public Instance Methods

can_work_on() click to toggle source

Returns whether the App is running.

# File lib/basespace/model/app_session.rb, line 69
def can_work_on
  return ['running'].include?(get_attr('Status').downcase)
end
serialize_references(api) click to toggle source

Serialize references.

api

BaseSpaceAPI instance.

# File lib/basespace/model/app_session.rb, line 57
def serialize_references(api)
  ref = []
  # [TODO] should this attribute initialized with []?
  get_attr('References').each do |r|
    res = r.serialize_object(api)  # AppSessionLaunchObject
    ref << res
  end
  set_attr('References', ref)
  return self
end
set_status(api, status, summary) click to toggle source

Sets the status of the AppSession.

Note: once set to ‘completed’ or ‘aborted’, no more work can be done to the instance

api

BaseSpaceAPI instance.

status

Status value, either: completed, aborted, working, or suspended.

summary

Status summary.

# File lib/basespace/model/app_session.rb, line 80
def set_status(api, status, summary)
  current_status = get_attr('Status')
  if current_status.downcase == 'complete' or current_status.downcase == 'aborted'
    raise "The status of AppSession = #{self.to_s} is #{current_status}, no further status changes are allowed."
  end

  # To prevent the AppResult object from being in an inconsistent state
  # and having two identical objects floating around, we update the current object
  # and discard the returned object
  new_session = api.set_app_session_state(get_attr('Id'), status, summary)
  set_attr('Status', new_session.status)
  set_attr('StatusSummary', new_session.status_summary)
  return self
end
to_s() click to toggle source

Return a string representation of the object, showing user information, ID and status.

# File lib/basespace/model/app_session.rb, line 50
def to_s
  return "App session by #{get_attr('UserCreatedBy')} - Id: #{get_attr('Id')} - status: #{get_attr('Status')}"
end