class NgrokAPI::Services::TunnelsClient

Tunnels provide endpoints to access services exposed by a running ngrok

agent tunnel session or an SSH reverse tunnel session.

ngrok.com/docs/api#api-tunnels

Constants

LIST_PROPERTY

The List Property from the resulting API for list calls

PATH

The API path for the requests

Attributes

client[R]

Public Class Methods

new(client:) click to toggle source
# File lib/ngrokapi/services/tunnels_client.rb, line 18
def initialize(client:)
  @client = client
end

Public Instance Methods

get(id: "") click to toggle source

Get the status of a tunnel by ID

@param [string] id a resource identifier @return [NgrokAPI::Models::Tunnel] result from the API request

ngrok.com/docs/api#api-tunnels-get

# File lib/ngrokapi/services/tunnels_client.rb, line 82
def get(id: "")
  path = '/tunnels/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  result = @client.get(path % replacements, data: data)
  NgrokAPI::Models::Tunnel.new(client: self, attrs: result)
end
get!(id: "") click to toggle source

Get the status of a tunnel by ID Throws an exception if API error.

@param [string] id a resource identifier @return [NgrokAPI::Models::Tunnel] result from the API request

ngrok.com/docs/api#api-tunnels-get

# File lib/ngrokapi/services/tunnels_client.rb, line 100
def get!(id: "")
  path = '/tunnels/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  result = @client.get(path % replacements, data: data, danger: true)
  NgrokAPI::Models::Tunnel.new(client: self, attrs: result)
end
list(before_id: nil, limit: nil, url: nil) click to toggle source

List all online tunnels currently running on the account.

@param [string] before_id @param [string] limit @param [string] url optional and mutually exclusive from before_id and limit @return [NgrokAPI::Models::Listable] result from the API request

ngrok.com/docs/api#api-tunnels-list

# File lib/ngrokapi/services/tunnels_client.rb, line 31
def list(before_id: nil, limit: nil, url: nil)
  result = @client.list(
    before_id: before_id,
    limit: limit,
    url: url,
    path: PATH
  )

  NgrokAPI::Models::Listable.new(
    client: self,
    attrs: result,
    list_property: LIST_PROPERTY,
    klass: NgrokAPI::Models::Tunnel
  )
end
list!(before_id: nil, limit: nil, url: nil) click to toggle source

List all online tunnels currently running on the account. Throws an exception if API error.

@param [string] before_id @param [string] limit @param [string] url optional and mutually exclusive from before_id and limit @return [NgrokAPI::Models::Listable] result from the API request

ngrok.com/docs/api#api-tunnels-list

# File lib/ngrokapi/services/tunnels_client.rb, line 57
def list!(before_id: nil, limit: nil, url: nil)
  result = @client.list(
    before_id: before_id,
    limit: limit,
    danger: true,
    url: url,
    path: PATH
  )

  NgrokAPI::Models::Listable.new(
    client: self,
    attrs: result,
    list_property: LIST_PROPERTY,
    klass: NgrokAPI::Models::Tunnel,
    danger: true
  )
end