Sha256: f44948b2530c1e0831b3c39eff4bfdea535f4769de186ec6167df3e72484cfe1

Contents?: true

Size: 1.22 KB

Versions: 33

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 removed."
  end

  # TODO acl_test
end
end

Version data entries

33 entries across 33 versions & 1 rubygems

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