Method: Cnvrg::Project#get_storage_client

Defined in:
lib/cnvrg/project.rb

#get_storage_clientObject

Raises:

  • (StandardError)


321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/cnvrg/project.rb', line 321

def get_storage_client
  client_params = nil
  i = 0
  begin
    response = Cnvrg::API.request("users/#{@owner}/projects/#{@slug}/client", 'GET')
    unless Cnvrg::CLI.is_response_success(response, false)
      raise StandardError.new("Can't find project credentials")
    end
    client_params = response['client']
  rescue StandardError
    i += 1
    sleep(5 * i)
    retry if i < 10
    client_params = get_storage_client_fallback
  end
  raise StandardError.new("Can't find project credentials") unless client_params
  Cnvrg::Downloader::Client.factory(client_params)
end