Class: Vkit::CLI::Commands::AgentTokensRevokeCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/vkit/cli/commands/agent_tokens_revoke_command.rb

Instance Method Summary collapse

Instance Method Details

#call(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vkit/cli/commands/agent_tokens_revoke_command.rb', line 9

def call(options)
  token_ref = options.fetch(:token)

  with_auth do
    user = credential_store.user
    org  = user["organization_slug"]

    token = resolve_token!(org, token_ref)

    unless options[:force]
      confirm!(token)
    end

    authenticated_client.post(
      "/api/v1/orgs/#{org}/agent_tokens/#{token["id"]}/revoke",
      body: {}
    )

    puts "🛑 AGENT TOKEN REVOKED"
    puts
    puts "🧠 Name:   #{token["name"]}"
    puts "🏷  Prefix: #{token["prefix"]}"
    puts "🆔 ID:     #{token["id"]}"
    puts
    puts "✅ The token is no longer valid."
  end
end