Class: Nahook::Resources::PortalSessions

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

Overview

Resource for creating developer portal sessions via the Management API.

Portal sessions generate short-lived URLs that grant your customers access to a self-service endpoint management portal.

Examples:

mgmt = Nahook::Management.new("nhm_token")
session = mgmt.portal_sessions.create("ws_abc123", "app_def456")
puts session["url"] # => "https://portal.nahook.com/..."

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ PortalSessions

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PortalSessions.

Parameters:



19
20
21
# File 'lib/nahook/resources/portal_sessions.rb', line 19

def initialize(http)
  @http = http
end

Instance Method Details

#create(workspace_id, app_id, metadata: nil) ⇒ Hash

Create a portal session for an application.

Parameters:

  • workspace_id (String)

    the workspace public ID

  • app_id (String)

    the application public ID

  • metadata (Hash, nil) (defaults to: nil)

    optional metadata for the session

Returns:

  • (Hash)

    session with “url”, “code”, and “expiresAt” keys



29
30
31
32
33
34
35
36
37
38
# File 'lib/nahook/resources/portal_sessions.rb', line 29

def create(workspace_id, app_id, metadata: nil)
  body = {}
  body["metadata"] =  if 

  @http.request(
    method: :post,
    path: "/management/v1/workspaces/#{e(workspace_id)}/applications/#{e(app_id)}/portal",
    body: body
  )
end