Sha256: b5b321f37369b847c1d32b897e5e475cc3e3ff428bbc850a51e9dee761370bc1

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

module Brightbox
  command [:"firewall-policies"] do |cmd|
    cmd.desc I18n.t("firewall.policies.create.desc")
    cmd.arg_name "[server-group-id...]"
    cmd.command [:create] do |c|
      c.desc I18n.t("options.name.desc")
      c.flag %i[n name]

      c.desc I18n.t("options.description.desc")
      c.flag %i[d description]

      c.action do |global_options, options, args|
        server_group_id = nil
        server_group = nil

        unless args.empty?
          server_group_id = args.shift
        end

        if server_group_id && !server_group_id.empty?
          server_group = ServerGroup.find(server_group_id)
        end

        name = options[:n]
        description = options[:d]

        firewall_options = {
          :name => name, :description => description
        }

        if server_group
          firewall_options.update(:server_group_id => server_group.id)
        end

        firewall_policy = FirewallPolicy.create(firewall_options)
        render_table([firewall_policy], global_options)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
brightbox-cli-4.8.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.7.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.6.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.5.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.5.0.rc1 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.4.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.3.2 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.3.1 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.3.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.2.1 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.2.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.1.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.0.0 lib/brightbox-cli/commands/firewall/policies_create.rb
brightbox-cli-4.0.0.rc2 lib/brightbox-cli/commands/firewall/policies_create.rb