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.

https://ngrok.com/docs/api#api-endpoints

Constant Summary collapse

PATH =

The API path for the requests

'/endpoints'
LIST_PROPERTY =

The List Property from the resulting API for list calls

'endpoints'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ EndpointsClient

Returns a new instance of EndpointsClient.



21
22
23
# File 'lib/ngrokapi/services/endpoints_client.rb', line 21

def initialize(client:)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

Instance Method Details

#create(url:, type:, traffic_policy:, description: nil, metadata: nil, bindings: nil, pooling_enabled: False) ⇒ NgrokAPI::Models::Endpoint

Create an endpoint, currently available only for cloud endpoints

https://ngrok.com/docs/api#api-endpoints-create

Parameters:

  • url (string)

    the url of the endpoint

  • type (string)

    Type of endpoint. Only 'cloud' is currently supported (represents a cloud endpoint). Defaults to 'cloud' if not specified.

  • traffic_policy (string)

    The traffic policy attached to this endpoint

  • description (string) (defaults to: nil)

    user-supplied description of the associated tunnel

  • metadata (string) (defaults to: nil)

    user-supplied metadata of the associated tunnel or edge object

  • bindings (List<string>) (defaults to: nil)

    the bindings associated with this endpoint

  • pooling_enabled (boolean) (defaults to: False)

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ngrokapi/services/endpoints_client.rb', line 38

def create(url:, type:, traffic_policy:, description: nil, metadata: nil, bindings: nil, pooling_enabled: False)
  path = '/endpoints'
  replacements = {
  }
  data = {}
  data[:url] = url if url
  data[:type] = type if type
  data[:traffic_policy] = traffic_policy if traffic_policy
  data[:description] = description if description
  data[:metadata] =  if 
  data[:bindings] = bindings if bindings
  data[:pooling_enabled] = pooling_enabled if pooling_enabled
  result = @client.post(path % replacements, data: data)
  NgrokAPI::Models::Endpoint.new(client: self, attrs: result)
end

#create!(url:, type:, traffic_policy:, description: nil, metadata: nil, bindings: nil, pooling_enabled: False) ⇒ NgrokAPI::Models::Endpoint

Create an endpoint, currently available only for cloud endpoints Throws an exception if API error.

https://ngrok.com/docs/api#api-endpoints-create

Parameters:

  • url (string)

    the url of the endpoint

  • type (string)

    Type of endpoint. Only 'cloud' is currently supported (represents a cloud endpoint). Defaults to 'cloud' if not specified.

  • traffic_policy (string)

    The traffic policy attached to this endpoint

  • description (string) (defaults to: nil)

    user-supplied description of the associated tunnel

  • metadata (string) (defaults to: nil)

    user-supplied metadata of the associated tunnel or edge object

  • bindings (List<string>) (defaults to: nil)

    the bindings associated with this endpoint

  • pooling_enabled (boolean) (defaults to: False)

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ngrokapi/services/endpoints_client.rb', line 68

def create!(url:, type:, traffic_policy:, description: nil, metadata: nil, bindings: nil, pooling_enabled: False)
  path = '/endpoints'
  replacements = {
  }
  data = {}
  data[:url] = url if url
  data[:type] = type if type
  data[:traffic_policy] = traffic_policy if traffic_policy
  data[:description] = description if description
  data[:metadata] =  if 
  data[:bindings] = bindings if bindings
  data[:pooling_enabled] = pooling_enabled if pooling_enabled
  result = @client.post(path % replacements, data: data, danger: true)
  NgrokAPI::Models::Endpoint.new(client: self, attrs: result)
end

#delete(id: "") ⇒ NgrokAPI::Models::Empty

Delete an Endpoint by ID, currently available only for cloud endpoints

https://ngrok.com/docs/api#api-endpoints-delete

Parameters:

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

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



246
247
248
249
250
251
252
# File 'lib/ngrokapi/services/endpoints_client.rb', line 246

def delete(id: "")
  path = '/endpoints/%{id}'
  replacements = {
    id: id,
  }
  @client.delete(path % replacements)
end

#delete!(id: "") ⇒ NgrokAPI::Models::Empty

Delete an Endpoint by ID, currently available only for cloud endpoints Throws an exception if API error.

https://ngrok.com/docs/api#api-endpoints-delete

Parameters:

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

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



262
263
264
265
266
267
268
# File 'lib/ngrokapi/services/endpoints_client.rb', line 262

def delete!(id: "")
  path = '/endpoints/%{id}'
  replacements = {
    id: id,
  }
  @client.delete(path % replacements, danger: true)
end

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

Get the status of an endpoint by ID

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

Parameters:

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

    a resource identifier

Returns:



152
153
154
155
156
157
158
159
160
# File 'lib/ngrokapi/services/endpoints_client.rb', line 152

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.

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

Parameters:

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

    a resource identifier

Returns:



170
171
172
173
174
175
176
177
178
# File 'lib/ngrokapi/services/endpoints_client.rb', line 170

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, ids: [], urls: [], url: nil) ⇒ NgrokAPI::Models::Listable

List all active endpoints on the account

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

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • ids (List<string>) (defaults to: [])
  • urls (List<string>) (defaults to: [])
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/ngrokapi/services/endpoints_client.rb', line 95

def list(before_id: nil, limit: nil, ids: [], urls: [], url: nil)
  result = @client.list(
    before_id: before_id,
    limit: limit,
    ids: ids,
    urls: urls,
    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, ids: [], urls: [], url: nil) ⇒ NgrokAPI::Models::Listable

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

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

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • ids (List<string>) (defaults to: [])
  • urls (List<string>) (defaults to: [])
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/ngrokapi/services/endpoints_client.rb', line 125

def list!(before_id: nil, limit: nil, ids: [], urls: [], url: nil)
  result = @client.list(
    before_id: before_id,
    limit: limit,
    ids: ids,
    urls: urls,
    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

#update(id: "", url: nil, traffic_policy: nil, description: nil, metadata: nil, bindings: nil, pooling_enabled: False) ⇒ NgrokAPI::Models::Endpoint

Update an Endpoint by ID, currently available only for cloud endpoints

https://ngrok.com/docs/api#api-endpoints-update

Parameters:

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

    unique endpoint resource identifier

  • url (string) (defaults to: nil)

    the url of the endpoint

  • traffic_policy (string) (defaults to: nil)

    The traffic policy attached to this endpoint

  • description (string) (defaults to: nil)

    user-supplied description of the associated tunnel

  • metadata (string) (defaults to: nil)

    user-supplied metadata of the associated tunnel or edge object

  • bindings (List<string>) (defaults to: nil)

    the bindings associated with this endpoint

  • pooling_enabled (boolean) (defaults to: False)

Returns:



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/ngrokapi/services/endpoints_client.rb', line 193

def update(id: "", url: nil, traffic_policy: nil, description: nil, metadata: nil, bindings: nil, pooling_enabled: False)
  path = '/endpoints/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  data[:url] = url if url
  data[:traffic_policy] = traffic_policy if traffic_policy
  data[:description] = description if description
  data[:metadata] =  if 
  data[:bindings] = bindings if bindings
  data[:pooling_enabled] = pooling_enabled if pooling_enabled
  result = @client.patch(path % replacements, data: data)
  NgrokAPI::Models::Endpoint.new(client: self, attrs: result)
end

#update!(id: "", url: nil, traffic_policy: nil, description: nil, metadata: nil, bindings: nil, pooling_enabled: False) ⇒ NgrokAPI::Models::Endpoint

Update an Endpoint by ID, currently available only for cloud endpoints Throws an exception if API error.

https://ngrok.com/docs/api#api-endpoints-update

Parameters:

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

    unique endpoint resource identifier

  • url (string) (defaults to: nil)

    the url of the endpoint

  • traffic_policy (string) (defaults to: nil)

    The traffic policy attached to this endpoint

  • description (string) (defaults to: nil)

    user-supplied description of the associated tunnel

  • metadata (string) (defaults to: nil)

    user-supplied metadata of the associated tunnel or edge object

  • bindings (List<string>) (defaults to: nil)

    the bindings associated with this endpoint

  • pooling_enabled (boolean) (defaults to: False)

Returns:



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/ngrokapi/services/endpoints_client.rb', line 223

def update!(id: "", url: nil, traffic_policy: nil, description: nil, metadata: nil, bindings: nil, pooling_enabled: False)
  path = '/endpoints/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  data[:url] = url if url
  data[:traffic_policy] = traffic_policy if traffic_policy
  data[:description] = description if description
  data[:metadata] =  if 
  data[:bindings] = bindings if bindings
  data[:pooling_enabled] = pooling_enabled if pooling_enabled
  result = @client.patch(path % replacements, data: data, danger: true)
  NgrokAPI::Models::Endpoint.new(client: self, attrs: result)
end