Module: Morpheus::Cli::WhoamiHelper

Included in:
Clusters, Whoami
Defined in:
lib/morpheus/cli/mixins/whoami_helper.rb

Overview

Mixin for Morpheus::Cli command classes Provides common methods for fetching and printing accounts, roles, and users. The including class must establish @accounts_interface, @roles_interface, @users_interface

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



8
9
10
# File 'lib/morpheus/cli/mixins/whoami_helper.rb', line 8

def self.included(klass)
  klass.send :include, Morpheus::Cli::PrintHelper
end

Instance Method Details

#load_whoamiObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/morpheus/cli/mixins/whoami_helper.rb', line 12

def load_whoami()
  whoami_interface = @whoami_interface || @api_client.whoami
  whoami_response = whoami_interface.get()
  # whoami_response = @whoami_interface.get()
  @current_user = whoami_response["user"]
  if @current_user.empty?
    print_red_alert "Unauthenticated. Please login."
    exit 1
  end
  @is_master_account = whoami_response["isMasterAccount"]
  @user_permissions = whoami_response["permissions"]

  if whoami_response["appliance"]
    @appliance_build_verison = whoami_response["appliance"]["buildVersion"]
  else
    @appliance_build_verison = nil
  end

  return whoami_response
end