Class: CPEE::Instantiation::InstantiateUrl

Inherits:
Riddl::Implementation
  • Object
show all
Includes:
Helpers
Defined in:
lib/cpee/instantiation.rb

Overview

}}}

Instance Method Summary collapse

Methods included from Helpers

#handle_data

Instance Method Details

#responseObject



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/cpee/instantiation.rb', line 139

def response
  cpee = @h['X_CPEE'] || @a[0]
  selfurl = @a[1]
  cblist = @a[2]
  status, res = Riddl::Client.new(@p[2].value).get
  tdoc = if status >= 200 && status < 300
    res[0].value.read
  else
    (@status = 500) && return
  end

  if (instance, uuid = load_testset(tdoc,cpee,@p[0].value)).first == -1
    @status = 500
  else
    handle_data cpee, instance, @p[3]&.value
    handle_waiting cpee, instance, uuid, @p[1].value, selfurl, cblist
    handle_starting cpee, instance, @p[1].value

    send = {
      'CPEE-INSTANCE' => instance,
      'CPEE-INSTANCE-URL' => File.join(cpee,instance),
      'CPEE-INSTANCE-UUID' => uuid,
      'CPEE-BEHAVIOR' => @p[1].value
    }
    @headers << Riddl::Header.new('CPEE-INSTANTIATION',JSON::generate(send))
    Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
  end
end