Sha256: 9fc51ec5aceb3c49b7d8a1e4e7190bb8222d9c315a318ad358ffc5dc260d2949

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

module Brightbox
  command [:"firewall-policies"] do |cmd|

    cmd.desc I18n.t("firewall.policies.update.desc")
    cmd.arg_name "firewall-policy-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.action do |global_options, options, args|
        policy_id = args.shift
        raise "You must specify the firewall-policy-id to update" if policy_id.nil?

        params = NilableHash.new

        if options[:n]
          params[:name] = options[:n]
        end

        if options[:d]
          params[:description] = options[:d]
        end

        params.nilify_blanks

        if params.empty?
          raise "No options were given so unable to update"
        end

        info "Updating policy #{policy_id}"
        # FirewallPolicy fog model does not currently include update so done
        # with a request, before updating the model
        data = FirewallPolicy.conn.update_firewall_policy(policy_id, params)

        model = Fog::Brightbox::Compute::FirewallPolicy.new(data)
        policy = FirewallPolicy.new(model)

        render_table([policy], global_options)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 lib/brightbox-cli/commands/firewall/policies-update.rb
brightbox-cli-3.2.0 lib/brightbox-cli/commands/firewall/policies-update.rb
brightbox-cli-3.1.0 lib/brightbox-cli/commands/firewall/policies-update.rb
brightbox-cli-3.0.1 lib/brightbox-cli/commands/firewall/policies-update.rb
brightbox-cli-3.0.0 lib/brightbox-cli/commands/firewall/policies-update.rb