Class: Kontena::Plugin::Cloud::Token::CreateCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common
Defined in:
lib/kontena/plugin/cloud/token/create_command.rb

Constant Summary

Constants included from CloudCommand

CloudCommand::PLATFORM_NOT_SELECTED_ERROR

Instance Method Summary collapse

Methods included from CloudCommand

#verify_current_grid, #verify_current_master, #verify_current_master_token

Instance Method Details

#default_nameObject



14
15
16
# File 'lib/kontena/plugin/cloud/token/create_command.rb', line 14

def default_name
  prompt.ask("Name:")
end

#executeObject



8
9
10
11
12
# File 'lib/kontena/plugin/cloud/token/create_command.rb', line 8

def execute
  data = { attributes: { name: self.name }}
  token = cloud_client.post("/user/personal_access_tokens", { data: data })['data']
  puts token.dig('attributes','access-token')
end