Class: Nahook::Management

Inherits:
Object
  • Object
show all
Defined in:
lib/nahook/management.rb

Overview

Client for the Nahook Management API.

Provides programmatic access to manage workspaces, endpoints, event types, applications, subscriptions, and portal sessions. Intended for server-side use with a management token.

Unlike Client, the Management client does not support retries – management operations are not idempotent by default.

Examples:

mgmt = Nahook::Management.new("nhm_your_token")

# List endpoints
result = mgmt.endpoints.list("ws_abc123")
result["data"].each { |ep| puts ep["url"] }

# Create an endpoint
endpoint = mgmt.endpoints.create("ws_abc123",
  url: "https://example.com/webhook",
  description: "Production webhook"
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, base_url: HttpClient::DEFAULT_BASE_URL, timeout_ms: HttpClient::DEFAULT_TIMEOUT_MS) ⇒ Management

Returns a new instance of Management.

Parameters:

  • token (String)

    management token (must start with “nhm_”)

  • base_url (String) (defaults to: HttpClient::DEFAULT_BASE_URL)

    API base URL

  • timeout_ms (Integer) (defaults to: HttpClient::DEFAULT_TIMEOUT_MS)

    request timeout in milliseconds (default: 30000)

Raises:

  • (ArgumentError)

    if the token does not start with “nhm_”



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/nahook/management.rb', line 48

def initialize(token, base_url: HttpClient::DEFAULT_BASE_URL, timeout_ms: HttpClient::DEFAULT_TIMEOUT_MS)
  unless token.start_with?("nhm_")
    raise ArgumentError, "Invalid management token: must start with 'nhm_'"
  end

  http = HttpClient.new(token: token, base_url: base_url, timeout_ms: timeout_ms)

  @endpoints       = Resources::Endpoints.new(http)
  @event_types     = Resources::EventTypes.new(http)
  @applications    = Resources::Applications.new(http)
  @subscriptions   = Resources::Subscriptions.new(http)
  @portal_sessions = Resources::PortalSessions.new(http)
  @environments    = Resources::Environments.new(http)
end

Instance Attribute Details

#applicationsResources::Applications (readonly)



33
34
35
# File 'lib/nahook/management.rb', line 33

def applications
  @applications
end

#endpointsResources::Endpoints (readonly)



27
28
29
# File 'lib/nahook/management.rb', line 27

def endpoints
  @endpoints
end

#environmentsResources::Environments (readonly)



42
43
44
# File 'lib/nahook/management.rb', line 42

def environments
  @environments
end

#event_typesResources::EventTypes (readonly)



30
31
32
# File 'lib/nahook/management.rb', line 30

def event_types
  @event_types
end

#portal_sessionsResources::PortalSessions (readonly)



39
40
41
# File 'lib/nahook/management.rb', line 39

def portal_sessions
  @portal_sessions
end

#subscriptionsResources::Subscriptions (readonly)



36
37
38
# File 'lib/nahook/management.rb', line 36

def subscriptions
  @subscriptions
end