Sha256: 5064024e4843643605524cb2639ade7fd8eb75369a85b0adb92b4fd7f9a41e4e

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

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

    cmd.desc "Update a firewall policy"
    cmd.arg_name "firewall-policy-id"
    cmd.command [:update] do |c|

      c.desc "Name of policy"
      c.flag [:n, :name]

      c.desc "Description of policy"
      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::Compute::Brightbox::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-1.1.0 lib/brightbox-cli/commands/firewall-policies-update.rb
brightbox-cli-1.0.0 lib/brightbox-cli/commands/firewall-policies-update.rb
brightbox-cli-1.0.0.rc2 lib/brightbox-cli/commands/firewall-policies-update.rb
brightbox-cli-1.0.0.rc1 lib/brightbox-cli/commands/firewall-policies-update.rb