Method: App42::Command::Base#delete_service_tunnel

Defined in:
lib/app42/command/base.rb

#delete_service_tunnel(service_name, source_ip) ⇒ Object

Unbind service to requested source IP

Parameters

service_name = service name provided by user source_ip = source IP to which service will get bind

return

display service bind details in tabular form OR ERROR message in case failed



1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
# File 'lib/app42/command/base.rb', line 1415

def delete_service_tunnel service_name, source_ip
  begin
    body = {'app42' => {"request"=> {
        "serviceName" => service_name,
        "sourceIp" => source_ip
    }}}.to_json

    query_params = params
    query_params.store('body', body)
    
    response = with_progress(Paint["Unbinding IP to service", :yellow]) do |s|
      build_put_request body, query_params, 'service', "unbind"    
    end

    if response["success"] == true && response["transactionId"]
      transaction_response = check_transaction_status response["transactionId"], previous_completed = 0, 'created'
      return true
    end
  rescue Interrupt
    puts Paint[" Command cancelled.", :red]
    exit!
  rescue Exception => e
    puts e  
  end
end