Class: Bio::BaseSpace::AppSession

Inherits:
Model
  • Object
show all
Defined in:
lib/basespace/model/app_session.rb

Overview

App sessions records when an App is being launched.

Instance Attribute Summary

Attributes inherited from Model

#attributes, #swagger_types

Instance Method Summary collapse

Methods inherited from Model

#get_attr, #method_missing, #set_attr

Constructor Details

#initializeAppSession

Create a new AppSession instance.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bio::BaseSpace::Model

Instance Method Details

#can_work_onObject

Returns whether the App is running.



69
70
71
# File 'lib/basespace/model/app_session.rb', line 69

def can_work_on
  return ['running'].include?(get_attr('Status').downcase)
end

#serialize_references(api) ⇒ Object

Serialize references.

api

BaseSpaceAPI instance.



57
58
59
60
61
62
63
64
65
66
# 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) ⇒ Object

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.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# 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_sObject

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



50
51
52
# 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