Class: Kontena::Plugin::Cloud::Token::RemoveCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common, Cli::TableGenerator::Helper
Defined in:
lib/kontena/plugin/cloud/token/remove_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_idObject



25
26
27
# File 'lib/kontena/plugin/cloud/token/remove_command.rb', line 25

def default_id
  prompt_token
end

#executeObject



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

def execute
  id = self.id
  confirm unless forced?
  cloud_client.delete("/user/personal_access_tokens/#{id}")
end

#prompt_tokenObject



16
17
18
19
20
21
22
23
# File 'lib/kontena/plugin/cloud/token/remove_command.rb', line 16

def prompt_token
  tokens = cloud_client.get('/user/personal_access_tokens')['data']
  prompt.select("Choose token:") do |menu|
    tokens.each do |d|
      menu.choice d.dig('attributes', 'name'), d['id']
    end
  end
end