class WavefrontDisplay::Account

Format human-readable output for account management.

Public Instance Methods

do_business_functions() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 59
def do_business_functions
  puts data.sort
end
do_grant_to() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 63
def do_grant_to
  puts format("Granted '%<permission>s' to %<quoted_accounts>s.",
              permission: options[:'<permission>'],
              quoted_accounts: quoted(options[:'<account>']))
end
do_group_add_to() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 37
def do_group_add_to
  puts format("Added '%<id>s' to %<quoted_group>s.",
              id: options[:'<id>'],
              quoted_group: quoted(options[:'<group>']))
end
do_group_remove_from() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 43
def do_group_remove_from
  puts format("Removed '%<id>s' from %<quoted_group>s.",
              id: options[:'<id>'],
              quoted_group: quoted(options[:'<group>']))
end
do_groups() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 49
def do_groups
  groups = data.fetch(:userGroups, [])

  if groups.empty?
    puts "'#{options[:'<id>']}' does not belong to any groups."
  else
    puts groups.sort
  end
end
do_ingestionpolicy() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 98
def do_ingestionpolicy
  policy = data.fetch(:ingestionPolicyId, [])

  if policy.empty?
    puts "'#{options[:'<id>']}' has no ingestion policy."
  else
    puts policy
  end
end
do_ingestionpolicy_add_to() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 86
def do_ingestionpolicy_add_to
  puts format("Added '%<policy>s' to '%<id>s'.",
              id: options[:'<id>'],
              policy: options[:'<policy>'])
end
do_ingestionpolicy_remove_from() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 92
def do_ingestionpolicy_remove_from
  puts format("Removed '%<policy>s' from '%<id>s'.",
              id: options[:'<id>'],
              policy: options[:'<policy>'])
end
do_invite_user() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 108
def do_invite_user
  puts format("Sent invitation to '%<id>s'.", id: options[:'<id>'])
end
do_list() click to toggle source
Calls superclass method
# File lib/wavefront-cli/display/account.rb, line 15
def do_list
  filter_user_list
  super
end
do_list_brief() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 10
def do_list_brief
  filter_user_list
  puts(data.map { |account| account[:identifier] })
end
do_permissions() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 75
def do_permissions
  perms = data.fetch(:groups, [])

  if perms.empty?
    puts "'#{options[:'<id>']}' does not have any permissions directly " \
         'attached.'
  else
    puts perms.sort
  end
end
do_revoke_from() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 69
def do_revoke_from
  puts format("Revoked '%<permission>s' from %<quoted_accounts>s.",
              permission: options[:'<permission>'],
              quoted_accounts: quoted(options[:'<account>']))
end
do_role_add_to() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 20
def do_role_add_to
  puts format("Gave %<quoted_roles>s to '%<id>s'.",
              id: options[:'<id>'],
              quoted_roles: quoted(options[:'<role>']))
end
do_role_remove_from() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 26
def do_role_remove_from
  puts format("Removed %<quoted_roles>s from '%<id>s'.",
              id: options[:'<id>'],
              quoted_roles: quoted(options[:'<role>']))
end
do_roles() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 32
def do_roles
  roles = data.fetch(:roles, [])
  puts roles.empty? ? "'#{options[:'<id>']}' has no roles." : roles
end

Private Instance Methods

filter_user_list() click to toggle source
# File lib/wavefront-cli/display/account.rb, line 114
def filter_user_list
  if options[:user]
    data.delete_if { |a| a[:identifier].start_with?('sa::') }
  elsif options[:service]
    data.delete_if { |a| !a[:identifier].start_with?('sa::') }
  end
end