Sha256: 88d73ae9336577fa436b9145a6e5b8ea740df8e81f3b6dee6adae43f7f479213

Contents?: true

Size: 1.22 KB

Versions: 23

Compression:

Stored size: 1.22 KB

Contents

module TreasureData
module Command

  def acl_list(op)
    op.cmd_parse

    client = get_client

    acl = client.access_controls

    rows = []
    acl.each {|ac|
      rows << {:Subject => ac.subject, :Action => ac.action, :Scope => ac.scope, :"Grant option" => ac.grant_option}
    }

    puts cmd_render_table(rows, :fields => [:Subject, :Action, :Scope, :"Grant option"])

    if rows.empty?
      $stderr.puts "There are no access controls."
      $stderr.puts "Use '#{$prog} acl:grant <subject> <action> <scope>' to grant permissions."
    end
  end

  def acl_grant(op)
    grant_option = true

    op.on('--no-grant-option', '-N', 'Grant without grant option', TrueClass) {|b|
      grant_option = !b
    }

    subject, action, scope = op.cmd_parse

    client = get_client

    client.grant_access_control(subject, action, scope, grant_option)

    $stderr.puts "Access control [#{subject} #{action} #{scope}] is created #{grant_option ? 'with' : 'without'} grant option."
  end

  def acl_revoke(op)
    subject, action, scope = op.cmd_parse

    client = get_client

    client.revoke_access_control(subject, action, scope)

    $stderr.puts "Access control [#{subject} #{action} #{scope}] is created."
  end

  # TODO acl_test
end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
td-0.10.61 lib/td/command/acl.rb
td-0.10.60 lib/td/command/acl.rb
td-0.10.59 lib/td/command/acl.rb
td-0.10.58 lib/td/command/acl.rb
td-0.10.57 lib/td/command/acl.rb
td-0.10.56 lib/td/command/acl.rb
td-0.10.55 lib/td/command/acl.rb
td-0.10.54 lib/td/command/acl.rb
td-0.10.53 lib/td/command/acl.rb
td-0.10.52 lib/td/command/acl.rb
td-0.10.51 lib/td/command/acl.rb
td-0.10.50 lib/td/command/acl.rb
td-0.10.49 lib/td/command/acl.rb
td-0.10.48 lib/td/command/acl.rb
td-0.10.47 lib/td/command/acl.rb
td-0.10.46 lib/td/command/acl.rb
td-0.10.45 lib/td/command/acl.rb
td-0.10.44 lib/td/command/acl.rb
td-0.10.43 lib/td/command/acl.rb
td-0.10.42 lib/td/command/acl.rb