Class: NgrokAPI::Services::EndpointsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ngrokapi/services/endpoints_client.rb

Overview

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.

ngrok.com/docs/api#api-endpoints

Constant Summary collapse

LIST_PROPERTY =

The List Property from the resulting API for list calls

'endpoints'
PATH =

The API path for the requests

'/endpoints'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ EndpointsClient

Returns a new instance of EndpointsClient.



19
20
21
# File 'lib/ngrokapi/services/endpoints_client.rb', line 19

def initialize(client:)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



17
18
19
# File 'lib/ngrokapi/services/endpoints_client.rb', line 17

def client
  @client
end

Instance Method Details

#get(id: "") ⇒ NgrokAPI::Models::Endpoint

Get the status of an endpoint by ID

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

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:



83
84
85
86
87
88
89
90
91
# File 'lib/ngrokapi/services/endpoints_client.rb', line 83

def get(id: "")
  path = '/endpoints/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  result = @client.get(path % replacements, data: data)
  NgrokAPI::Models::Endpoint.new(client: self, attrs: result)
end

#get!(id: "") ⇒ NgrokAPI::Models::Endpoint

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

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

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:



101
102
103
104
105
106
107
108
109
# File 'lib/ngrokapi/services/endpoints_client.rb', line 101

def get!(id: "")
  path = '/endpoints/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  result = @client.get(path % replacements, data: data, danger: true)
  NgrokAPI::Models::Endpoint.new(client: self, attrs: result)
end

#list(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable

List all active endpoints on the account

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

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ngrokapi/services/endpoints_client.rb', line 32

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::Endpoint
  )
end

#list!(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable

List all active endpoints on the account Throws an exception if API error.

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

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ngrokapi/services/endpoints_client.rb', line 58

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::Endpoint,
    danger: true
  )
end