Class: CPEE::Instantiation::HandleInstance

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

Overview

}}}

Instance Method Summary collapse

Methods included from Helpers

#add_to_testset, #augment_testset, #handle_attributes, #handle_data, #handle_endpoints

Instance Method Details

#responseObject



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/cpee-instantiation/instantiation.rb', line 338

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

  srv = Riddl::Client.new(cpee)
  res = srv.resource("/#{instance}/properties/attributes/uuid/")
  status, response = res.get

  if status >= 200 && status < 300
    uuid = response.first.value
    handle_data cpee, instance, @p[2]&.value
    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
    }

    if @p[0].value =~ /^wait/
      @headers << Riddl::Header.new('CPEE-CALLBACK','true')
    end
    Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
  else
    @status = 500
  end
end