class NgrokAPI::Client

Low-level api client for communicating with Ngrok’s HTTP API. Use this object to instantiate your clients.

Public Class Methods

new(api_key:, base_url: 'https://api.ngrok.com') click to toggle source
# File lib/ngrokapi/client.rb, line 10
def initialize(api_key:, base_url: 'https://api.ngrok.com')
  @client = NgrokAPI::HttpClient.new(api_key: api_key, base_url: base_url)
end

Public Instance Methods

abuse_reports() click to toggle source

Abuse Reports allow you to submit take-down requests for URLs hosted by

ngrok that violate ngrok's terms of service.

@return [NgrokAPI::Services::AbuseReportsClient]

# File lib/ngrokapi/client.rb, line 19
def abuse_reports
  @_abuse_reports ||= NgrokAPI::Services::AbuseReportsClient.new(client: @client)
end
agent_ingresses() click to toggle source
# File lib/ngrokapi/client.rb, line 23
def agent_ingresses
  @_agent_ingresses ||= NgrokAPI::Services::AgentIngressesClient.new(client: @client)
end
api_keys() click to toggle source

API Keys are used to authenticate to the [ngrok

API](https://ngrok.com/docs/api#authentication). You may use the API itself
to provision and manage API Keys but you'll need to provision your first API
key from the [API Keys page](https://dashboard.ngrok.com/api/keys) on your
ngrok.com dashboard.

@return [NgrokAPI::Services::APIKeysClient]

# File lib/ngrokapi/client.rb, line 35
def api_keys
  @_api_keys ||= NgrokAPI::Services::APIKeysClient.new(client: @client)
end
backends() click to toggle source
# File lib/ngrokapi/client.rb, line 207
def backends
  ns = OpenStruct.new
  ns.failover = NgrokAPI::Services::FailoverBackendsClient.new(client: @client)
  ns.http_response = NgrokAPI::Services::HTTPResponseBackendsClient.new(client: @client)
  ns.tunnel_group = NgrokAPI::Services::TunnelGroupBackendsClient.new(client: @client)
  ns.weighted = NgrokAPI::Services::WeightedBackendsClient.new(client: @client)

  ns
end
certificate_authorities() click to toggle source

Certificate Authorities are x509 certificates that are used to sign other

x509 certificates. Attach a Certificate Authority to the Mutual TLS module
to verify that the TLS certificate presented by a client has been signed by
this CA. Certificate Authorities  are used only for mTLS validation only and
thus a private key is not included in the resource.

@return [NgrokAPI::Services::CertificateAuthoritiesClient]

# File lib/ngrokapi/client.rb, line 47
def certificate_authorities
  @_certificate_authorities ||= NgrokAPI::Services::CertificateAuthoritiesClient.new(client: @client)
end
credentials() click to toggle source

Tunnel Credentials are ngrok agent authtokens. They authorize the ngrok

agent to connect the ngrok service as your account. They are installed with
the `ngrok authtoken` command or by specifying it in the `ngrok.yml`
configuration file with the `authtoken` property.

@return [NgrokAPI::Services::CredentialsClient]

# File lib/ngrokapi/client.rb, line 58
def credentials
  @_credentials ||= NgrokAPI::Services::CredentialsClient.new(client: @client)
end
edge_modules() click to toggle source
# File lib/ngrokapi/client.rb, line 227
def edge_modules
  ns = OpenStruct.new
  ns.https_edge_mutual_tls = NgrokAPI::Services::HTTPSEdgeMutualTLSModuleClient.new(client: @client)
  ns.https_edge_tls_termination = NgrokAPI::Services::HTTPSEdgeTLSTerminationModuleClient.new(client: @client)
  ns.https_edge_route_backend = NgrokAPI::Services::EdgeRouteBackendModuleClient.new(client: @client)
  ns.https_edge_route_ip_restriction = NgrokAPI::Services::EdgeRouteIPRestrictionModuleClient.new(client: @client)
  ns.https_edge_route_request_headers = NgrokAPI::Services::EdgeRouteRequestHeadersModuleClient.new(client: @client)
  ns.https_edge_route_response_headers = NgrokAPI::Services::EdgeRouteResponseHeadersModuleClient.new(client: @client)
  ns.https_edge_route_compression = NgrokAPI::Services::EdgeRouteCompressionModuleClient.new(client: @client)
  ns.https_edge_route_circuit_breaker = NgrokAPI::Services::EdgeRouteCircuitBreakerModuleClient.new(client: @client)
  ns.https_edge_route_webhook_verification = NgrokAPI::Services::EdgeRouteWebhookVerificationModuleClient.new(client: @client)
  ns.https_edge_route_oauth = NgrokAPI::Services::EdgeRouteOAuthModuleClient.new(client: @client)
  ns.https_edge_route_saml = NgrokAPI::Services::EdgeRouteSAMLModuleClient.new(client: @client)
  ns.https_edge_route_oidc = NgrokAPI::Services::EdgeRouteOIDCModuleClient.new(client: @client)
  ns.https_edge_route_websocket_tcp_converter = NgrokAPI::Services::EdgeRouteWebsocketTCPConverterModuleClient.new(client: @client)
  ns.tcp_edge_backend = NgrokAPI::Services::TCPEdgeBackendModuleClient.new(client: @client)
  ns.tcp_edge_ip_restriction = NgrokAPI::Services::TCPEdgeIPRestrictionModuleClient.new(client: @client)
  ns.tls_edge_backend = NgrokAPI::Services::TLSEdgeBackendModuleClient.new(client: @client)
  ns.tls_edge_ip_restriction = NgrokAPI::Services::TLSEdgeIPRestrictionModuleClient.new(client: @client)
  ns.tls_edge_mutual_tls = NgrokAPI::Services::TLSEdgeMutualTLSModuleClient.new(client: @client)
  ns.tls_edge_tls_termination = NgrokAPI::Services::TLSEdgeTLSTerminationModuleClient.new(client: @client)

  ns
end
edges() click to toggle source
# File lib/ngrokapi/client.rb, line 217
def edges
  ns = OpenStruct.new
  ns.https_routes = NgrokAPI::Services::EdgesHTTPSRoutesClient.new(client: @client)
  ns.https = NgrokAPI::Services::EdgesHTTPSClient.new(client: @client)
  ns.tcp = NgrokAPI::Services::EdgesTCPClient.new(client: @client)
  ns.tls = NgrokAPI::Services::EdgesTLSClient.new(client: @client)

  ns
end
endpoints() click to toggle source

Endpoints provides an API for querying the endpoint objects

which define what tunnel or edge is used to serve a hostport.
Only active endpoints associated with a tunnel or backend are returned.

@return [NgrokAPI::Services::EndpointsClient]

# File lib/ngrokapi/client.rb, line 68
def endpoints
  @_endpoints ||= NgrokAPI::Services::EndpointsClient.new(client: @client)
end
event_destinations() click to toggle source
# File lib/ngrokapi/client.rb, line 72
def event_destinations
  @_event_destinations ||= NgrokAPI::Services::EventDestinationsClient.new(client: @client)
end
event_sources() click to toggle source
# File lib/ngrokapi/client.rb, line 80
def event_sources
  @_event_sources ||= NgrokAPI::Services::EventSourcesClient.new(client: @client)
end
event_subscriptions() click to toggle source
# File lib/ngrokapi/client.rb, line 76
def event_subscriptions
  @_event_subscriptions ||= NgrokAPI::Services::EventSubscriptionsClient.new(client: @client)
end
ip_policies() click to toggle source

IP Policies are reusable groups of CIDR ranges with an ‘allow` or `deny`

action. They can be attached to endpoints via the Endpoint Configuration IP
Policy module. They can also be used with IP Restrictions to control source
IP ranges that can start tunnel sessions and connect to the API and dashboard.

@return [NgrokAPI::Services::IPPoliciesClient]

# File lib/ngrokapi/client.rb, line 91
def ip_policies
  @_ip_policies ||= NgrokAPI::Services::IPPoliciesClient.new(client: @client)
end
ip_policy_rules() click to toggle source

IP Policy Rules are the IPv4 or IPv6 CIDRs entries that

make up an IP Policy.

@return [NgrokAPI::Services::IPPolicyRulesClient]

# File lib/ngrokapi/client.rb, line 100
def ip_policy_rules
  @_ip_policy_rules ||= NgrokAPI::Services::IPPolicyRulesClient.new(client: @client)
end
ip_restrictions() click to toggle source

An IP restriction is a restriction placed on the CIDRs that are allowed to

initiate traffic to a specific aspect of your ngrok account. An IP
restriction has a type which defines the ingress it applies to. IP
restrictions can be used to enforce the source IPs that can make API
requests, log in to the dashboard, start ngrok agents, and connect to your
public-facing endpoints.

@return [NgrokAPI::Services::IPRestrictionsClient]

# File lib/ngrokapi/client.rb, line 113
def ip_restrictions
  @_ip_restrictions ||= NgrokAPI::Services::IPRestrictionsClient.new(client: @client)
end
reserved_addrs() click to toggle source

Reserved Addresses are TCP addresses that can be used to listen for traffic.

TCP address hostnames and ports are assigned by ngrok, they cannot be
chosen.

@return [NgrokAPI::Services::ReservedAddrsClient]

# File lib/ngrokapi/client.rb, line 123
def reserved_addrs
  @_reserved_addrs ||= NgrokAPI::Services::ReservedAddrsClient.new(client: @client)
end
reserved_domains() click to toggle source

Reserved Domains are hostnames that you can listen for traffic on. Domains

can be used to listen for http, https or tls traffic. You may use a domain
that you own by creating a CNAME record specified in the returned resource.
This CNAME record points traffic for that domain to ngrok's edge servers.

@return [NgrokAPI::Services::ReservedDomainsClient]

# File lib/ngrokapi/client.rb, line 134
def reserved_domains
  @_reserved_domains ||= NgrokAPI::Services::ReservedDomainsClient.new(client: @client)
end
ssh_certificate_authorities() click to toggle source

An SSH Certificate Authority is a pair of an SSH Certificate and its private

key that can be used to sign other SSH host and user certificates.

@return [NgrokAPI::Services::SSHCertificateAuthoritiesClient]

# File lib/ngrokapi/client.rb, line 143
def ssh_certificate_authorities
  @_ssh_certificate_authorities ||= NgrokAPI::Services::SSHCertificateAuthoritiesClient.new(client: @client)
end
ssh_credentials() click to toggle source

SSH Credentials are SSH public keys that can be used to start SSH tunnels

via the ngrok SSH tunnel gateway.

@return [NgrokAPI::Services::SSHCredentialsClient]

# File lib/ngrokapi/client.rb, line 152
def ssh_credentials
  @_ssh_credentials ||= NgrokAPI::Services::SSHCredentialsClient.new(client: @client)
end
ssh_host_certificates() click to toggle source

SSH Host Certificates along with the corresponding private key allows an SSH

server to assert its authenticity to connecting SSH clients who trust the
SSH Certificate Authority that was used to sign the certificate.

@return [NgrokAPI::Services::SSHHostCertificatesClient]

# File lib/ngrokapi/client.rb, line 162
def ssh_host_certificates
  @_ssh_host_certificates ||= NgrokAPI::Services::SSHHostCertificatesClient.new(client: @client)
end
ssh_user_certificates() click to toggle source

SSH User Certificates are presented by SSH clients when connecting to an SSH

server to authenticate their connection. The SSH server must trust the SSH
Certificate Authority used to sign the certificate.

@return [NgrokAPI::Services::SSHUserCertificatesClient]

# File lib/ngrokapi/client.rb, line 172
def ssh_user_certificates
  @_ssh_user_certificates ||= NgrokAPI::Services::SSHUserCertificatesClient.new(client: @client)
end
tls_certificates() click to toggle source

TLS Certificates are pairs of x509 certificates and their matching private

key that can be used to terminate TLS traffic. TLS certificates are unused
until they are attached to a Domain. TLS Certificates may also be
provisioned by ngrok automatically for domains on which you have enabled
automated certificate provisioning.

@return [NgrokAPI::Services::TLSCertificatesClient]

# File lib/ngrokapi/client.rb, line 184
def tls_certificates
  @_tls_certificates ||= NgrokAPI::Services::TLSCertificatesClient.new(client: @client)
end
tunnel_sessions() click to toggle source

Tunnel Sessions represent instances of ngrok agents or SSH reverse tunnel

sessions that are running and connected to the ngrok service. Each tunnel
session can include one or more Tunnels.

@return [NgrokAPI::Services::TunnelSessionsClient]

# File lib/ngrokapi/client.rb, line 194
def tunnel_sessions
  @_tunnel_sessions ||= NgrokAPI::Services::TunnelSessionsClient.new(client: @client)
end
tunnels() click to toggle source

Tunnels provide endpoints to access services exposed by a running ngrok

agent tunnel session or an SSH reverse tunnel session.

@return [NgrokAPI::Services::TunnelsClient]

# File lib/ngrokapi/client.rb, line 203
def tunnels
  @_tunnels ||= NgrokAPI::Services::TunnelsClient.new(client: @client)
end