Class: UnimatrixCLI::Keymaker::ResourceOwner::FindCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/unimatrix_cli/keymaker/resource_owner/find_command.rb

Instance Method Summary collapse

Methods inherited from Command

available_commands, descendants, #initialize, #read_file, #validate, #validate_collection, #write

Methods included from UnimatrixParser

included

Constructor Details

This class inherits a constructor from UnimatrixCLI::Command

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/unimatrix_cli/keymaker/resource_owner/find_command.rb', line 14

def execute
  if ( @options[ :email_address ] && @options[ :resource_owner_uuid ].nil? ) ||
     ( @options[ :email_address ].nil? && @options[ :resource_owner_uuid ] )
    
    resource_owner_response = resource_owner_request
    
    if !resource_owner_response[ 'error' ]
      write(
        message: "Resource Owner found. \n" +
        "Email Address: #{ resource_owner_response[ 'email_address' ] } \n" +
        "UUID: #{ resource_owner_response[ 'uuid' ] } \n" +
        "First Name: #{ resource_owner_response[ 'name_first' ] || '<none>' } \n" +
        "Last Name: #{ resource_owner_response[ 'name_last' ] || '<none>' }"
      )
    else
      write( 
        message: "Error: unable to retrieve resource owner: " +
        "#{ resource_owner_response.inspect }", error: true 
      )
    end
  else
    write(
      message: "Error: either option --email-address OR --resource-owner-uuid must be specified.",
      error: true
    )
  end
end