Sha256: 192619e56fa7888c0a017ab7128e9136b45c8392c1cfd6d31bb849da20ff4a52

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module Brightbox
  command ["firewall-policies", "firewall-policy"] 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 %i[n name]

      c.desc I18n.t("options.description.desc")
      c.flag %i[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

4 entries across 4 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0 lib/brightbox-cli/commands/firewall/policies_update.rb
brightbox-cli-5.0.0.rc2 lib/brightbox-cli/commands/firewall/policies_update.rb
brightbox-cli-5.0.0.rc1 lib/brightbox-cli/commands/firewall/policies_update.rb
brightbox-cli-5.0.0.alpha lib/brightbox-cli/commands/firewall/policies_update.rb