Sha256: dddfcdd7d4bb4a2775337057633c89749949291cb4f9fbb75acbf19a9fe5a866

Contents?: true

Size: 1.22 KB

Versions: 23

Compression:

Stored size: 1.22 KB

Contents

module Brightbox
  command [:sql] do |product|
    product.command [:instances] do |cmd|

      cmd.desc I18n.t("sql.instances.update.desc")
      cmd.arg_name "instance-id"
      cmd.command [:update] do |c|

        c.desc I18n.t("options.name.desc")
        c.flag [:n, :name]

        c.desc I18n.t("options.description.desc")
        c.flag [:d, "description"]

        c.desc I18n.t("sql.instances.options.allow_access.desc")
        c.flag [:"allow-access"]

        c.action do |global_options, options, args|
          dbs_id = args.shift
          unless dbs_id =~ /^dbs-/
            raise "You must specify a valid SQL instance ID as the first argument"
          end

          server = DatabaseServer.find dbs_id

          params = NilableHash.new
          params[:name] = options[:n] if options[:n]
          params[:description] = options[:d] if options[:d]

          if options[:"allow-access"]
            access_items = options[:"allow-access"].split(",")
            params[:allow_access] = access_items
          end

          params.nilify_blanks

          info "Updating #{server}"
          server.update params
          server.reload
          render_table([server], global_options)
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
brightbox-cli-2.5.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.4.1 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.4.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.3.4 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.3.3 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.3.2 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.3.1 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.3.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.2.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.1.2 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.1.1 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.1.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-2.0.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-1.6.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-1.5.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-1.4.3 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-1.4.2 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-1.4.1 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-1.4.0 lib/brightbox-cli/commands/sql/instances_update.rb
brightbox-cli-1.3.0 lib/brightbox-cli/commands/sql/instances_update.rb