Class: Magellan::Cli::Resources::Cloudsql

Inherits:
Base
  • Object
show all
Includes:
Deletable
Defined in:
lib/magellan/cli/resources/cloudsql.rb

Constant Summary

Constants included from FileAccess

FileAccess::DEFAULT_SELECTION_FILENAME

Instance Method Summary collapse

Methods included from Deletable

included

Methods included from FileAccess

ensure_config_dir, load_selection, load_selections, remove_selection_file, selection_filename, update_selections

Methods inherited from Base

command_help, help, log_error, log_info, log_success, log_verbose, log_warning, puts_with_color, sorted_commands, sorted_printable_commands, update_common_help_message

Instance Method Details

#create(name) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/magellan/cli/resources/cloudsql.rb', line 19

def create(name)
  o = load_selection!(Stage)
  params = {
    parameter_name => {
      "stage_title_id" => o["id"],
      "name" => name,
    }
  }
  res0 = post_json("/admin/#{resource_key}/new.json", params)
  select(name)

  return res0 if options["A"]

  id = load_selection!(parameter_name)["id"]
  interval = options["i"]
  Timeout.timeout(options["t"]) do
    loop do
      sleep(interval)
      res1 = get_json("/admin/#{resource_key}/#{id}.json")
      return res1 if res1["available"]
    end
  end
end