Class: CPEE::Instantiation::InstantiateGit

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, #handle_endpoints

Instance Method Details

#responseObject



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/cpee/instantiation.rb', line 152

def response
  cpee = @h['X_CPEE'] || @a[0]
  selfurl = @a[1]
  cblist = @a[2]

  status, res = Riddl::Client.new(File.join(@p[1].value,'raw',@p[2].value,@p[3].value).gsub(/ /,'%20')).get
  tdoc = if status >= 200 && status < 300
    res[0].value.read
  else
    (@status = 500) && return
  end

  if (instance, uuid = load_testset(tdoc,cpee)).first == -1
    @status = 500
  else
    handle_data cpee, instance, @p[4]&.value if @p[4]&.name == 'init'
    handle_endpoints cpee, instance, @p[4]&.value if @p[4]&.name == 'endpoints'
    handle_endpoints cpee, instance, @p[5]&.value if @p[5]&.name == 'endpoints'

    handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
    handle_starting cpee, instance, @p[0].value

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