Class: Melaya::RunnerAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/melaya/runner.rb

Overview

Runner API — mint, list, and revoke runner tokens.

Runner tokens (mel_run_ prefix) authenticate the Melaya runner CLI process that executes agent pipelines on your infrastructure. The plaintext token is returned only once on creation — store it securely.

Maps to /api/v1/private/runner/tokens/*.

Examples:

result = melaya.runner.create_token(label: "prod-server-1")
token = result["token"]   # store securely — shown only once

tokens = melaya.runner.list_tokens
melaya.runner.revoke_token(tokens.first["id"])

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ RunnerAPI

Returns a new instance of RunnerAPI.



19
20
21
# File 'lib/melaya/runner.rb', line 19

def initialize(http)
  @http = http
end

Instance Method Details

#create_token(label: nil) ⇒ Object

POST /api/v1/private/runner/tokens Mint a new mel_run_ runner token.

Parameters:

  • label (String, nil) (defaults to: nil)

    human-readable label for the token



26
27
28
29
# File 'lib/melaya/runner.rb', line 26

def create_token(label: nil)
  body = label ? { "label" => label } : nil
  @http.post("/api/v1/private/runner/tokens", body)
end

#list_tokensObject

GET /api/v1/private/runner/tokens List all runner tokens for the caller (masked, with last_seen).



33
34
35
# File 'lib/melaya/runner.rb', line 33

def list_tokens
  @http.get("/api/v1/private/runner/tokens")
end

#revoke_token(token_id) ⇒ Object

DELETE /api/v1/private/runner/tokens/:tokenId Revoke a runner token by ID.

Parameters:

  • token_id (String)


40
41
42
# File 'lib/melaya/runner.rb', line 40

def revoke_token(token_id)
  @http.delete("/api/v1/private/runner/tokens/#{URI.encode_www_form_component(token_id.to_s)}")
end