Sha256: 0c73fc7d0cb32d041658440915aff84c2c550227d55b863894fc3f49414e17a3

Contents?: true

Size: 1.26 KB

Versions: 21

Compression:

Stored size: 1.26 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}
    }

    $stdout.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} " + Config.cl_options_string + "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 removed."
  end

  # TODO acl_test
end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
td-0.15.8 lib/td/command/acl.rb
td-0.15.7 lib/td/command/acl.rb
td-0.15.6 lib/td/command/acl.rb
td-0.15.5 lib/td/command/acl.rb
td-0.15.4 lib/td/command/acl.rb
td-0.15.3 lib/td/command/acl.rb
td-0.15.2 lib/td/command/acl.rb
td-0.15.0 lib/td/command/acl.rb
td-0.14.1 lib/td/command/acl.rb
td-0.14.0 lib/td/command/acl.rb
td-0.13.2 lib/td/command/acl.rb
td-0.13.1 lib/td/command/acl.rb
td-0.13.0 lib/td/command/acl.rb
td-0.12.0 lib/td/command/acl.rb
td-0.11.14 lib/td/command/acl.rb
td-0.11.13 lib/td/command/acl.rb
td-0.11.12 lib/td/command/acl.rb
td-0.11.11.2 lib/td/command/acl.rb
td-0.11.11.1 lib/td/command/acl.rb
td-0.11.11 lib/td/command/acl.rb