Sha256: 52e998739f9a006ec6acb034afd9f5306d2b833b08d3d0809d75f9259740a2ae

Contents?: true

Size: 1.26 KB

Versions: 18

Compression:

Stored size: 1.26 KB

Contents

module TreasureData
module Command
  def ip_limit_list(op)
    op.cmd_parse

    client = get_client

    ip_limits = client.ip_limits
    rows = ip_limits.map { |ip_limit|
      {:Organization => ip_limit.org, 'IP Range' => ip_limit.ip_range}
    }

    puts cmd_render_table(rows, :fields => [:Organization, 'IP Range'])

    if rows.empty?
      $stderr.puts "There are no IP range limitations."
      $stderr.puts "Use '#{$prog} ip_limit:set <organization> <ip_range>' to create IP range limitation."
    end
  end

  def ip_limit_show(op)
    organization = op.cmd_parse

    client = get_client

    ip_limits = client.ip_limits
    rows = ip_limits.select { |ip_limit|
      ip_limit.org == organization
    }.map { |ip_limit| {'IP Range' => ip_limit.ip_range} }

    puts cmd_render_table(rows, :fields => ['IP Range'])
  end

  def ip_limit_set(op)
    organization, *ip_ranges = op.cmd_parse

    client = get_client
    client.set_ip_limit(organization, ip_ranges)

    $stderr.puts "IP range limitations [#{ip_ranges.join(' ')}] are set to #{organization}"
  end

  def ip_limit_delete(op)
    organization = op.cmd_parse

    client = get_client
    client.delete_ip_limit(organization)

    $stderr.puts "All IP range limitations are deleted from #{organization}"
  end
end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
td-0.10.92 lib/td/command/ip_limit.rb
td-0.10.91 lib/td/command/ip_limit.rb
td-0.10.90 lib/td/command/ip_limit.rb
td-0.10.89 lib/td/command/ip_limit.rb
td-0.10.88 lib/td/command/ip_limit.rb
td-0.10.87 lib/td/command/ip_limit.rb
td-0.10.86 lib/td/command/ip_limit.rb
td-0.10.85 lib/td/command/ip_limit.rb
td-0.10.84 lib/td/command/ip_limit.rb
td-0.10.83 lib/td/command/ip_limit.rb
td-0.10.82 lib/td/command/ip_limit.rb
td-0.10.81 lib/td/command/ip_limit.rb
td-0.10.79 lib/td/command/ip_limit.rb
td-0.10.78 lib/td/command/ip_limit.rb
td-0.10.77 lib/td/command/ip_limit.rb
td-0.10.76 lib/td/command/ip_limit.rb
td-0.10.75 lib/td/command/ip_limit.rb
td-0.10.74 lib/td/command/ip_limit.rb