Class: Etna::Clients::Janus::GenerateTokenWorkflow

Inherits:
Struct
  • Object
show all
Defined in:
lib/etna/clients/janus/workflows/generate_token_workflow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email

Returns:

  • (Object)

    the current value of email



15
16
17
# File 'lib/etna/clients/janus/workflows/generate_token_workflow.rb', line 15

def email
  @email
end

#janus_clientObject

Returns the value of attribute janus_client

Returns:

  • (Object)

    the current value of janus_client



15
16
17
# File 'lib/etna/clients/janus/workflows/generate_token_workflow.rb', line 15

def janus_client
  @janus_client
end

#private_key_fileObject

Returns the value of attribute private_key_file

Returns:

  • (Object)

    the current value of private_key_file



15
16
17
# File 'lib/etna/clients/janus/workflows/generate_token_workflow.rb', line 15

def private_key_file
  @private_key_file
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



15
16
17
# File 'lib/etna/clients/janus/workflows/generate_token_workflow.rb', line 15

def project_name
  @project_name
end

#token_typeObject

Returns the value of attribute token_type

Returns:

  • (Object)

    the current value of token_type



15
16
17
# File 'lib/etna/clients/janus/workflows/generate_token_workflow.rb', line 15

def token_type
  @token_type
end

Instance Method Details

#generate!Object



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
41
42
43
# File 'lib/etna/clients/janus/workflows/generate_token_workflow.rb', line 16

def generate!
  nonce = janus_client.get_nonce

  unless email
    puts "Email address for #{janus_client.host} account?"
    email = STDIN.gets.chomp
  end

  if use_nonce?
    until private_key_file
      puts "Location of private key file?"
      private_key_file = ::File.expand_path(STDIN.gets.chomp)
      unless File.exists?(private_key_file)
        puts "No such file."
        private_key_file = nil
      end
    end
  end

  if needs_project_name?
    puts "Project name?"
    project_name = STDIN.gets.chomp
  end
  
  token = janus_client.generate_token(token_type, signed_nonce: use_nonce? ? signed_nonce(nonce) : nil, project_name: project_name)

  puts token
end