class NgrokAPI::Services::WeightedBackendsClient

A Weighted Backend balances traffic among the referenced backends. Traffic

is assigned proportionally to each based on its weight. The percentage of
traffic is calculated by dividing a backend's weight by the sum of all
weights.

ngrok.com/docs/api#api-weighted-backends

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/weighted_backends_client.rb, line 20
def initialize(client:)
  @client = client
end

Public Instance Methods

create(description: "", metadata: "", backends: {}) click to toggle source

Create a new Weighted backend

@param [string] description human-readable description of this backend. Optional @param [string] metadata arbitrary user-defined machine-readable data of this backend. Optional @param [Map<string, int64>] backends the ids of the child backends to their weights [0-10000] @return [NgrokAPI::Models::WeightedBackend] result from the API request

ngrok.com/docs/api#api-weighted-backends-create

# File lib/ngrokapi/services/weighted_backends_client.rb, line 33
def create(description: "", metadata: "", backends: {})
  path = '/backends/weighted'
  replacements = {
  }
  data = {}
  data[:description] = description if description
  data[:metadata] = metadata if metadata
  data[:backends] = backends if backends
  result = @client.post(path % replacements, data: data)
  NgrokAPI::Models::WeightedBackend.new(client: self, attrs: result)
end
create!(description: "", metadata: "", backends: {}) click to toggle source

Create a new Weighted backend Throws an exception if API error.

@param [string] description human-readable description of this backend. Optional @param [string] metadata arbitrary user-defined machine-readable data of this backend. Optional @param [Map<string, int64>] backends the ids of the child backends to their weights [0-10000] @return [NgrokAPI::Models::WeightedBackend] result from the API request

ngrok.com/docs/api#api-weighted-backends-create

# File lib/ngrokapi/services/weighted_backends_client.rb, line 55
def create!(description: "", metadata: "", backends: {})
  path = '/backends/weighted'
  replacements = {
  }
  data = {}
  data[:description] = description if description
  data[:metadata] = metadata if metadata
  data[:backends] = backends if backends
  result = @client.post(path % replacements, data: data, danger: true)
  NgrokAPI::Models::WeightedBackend.new(client: self, attrs: result)
end
delete(id: "") click to toggle source

Delete a Weighted backend by ID.

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

ngrok.com/docs/api#api-weighted-backends-delete

# File lib/ngrokapi/services/weighted_backends_client.rb, line 74
def delete(id: "")
  path = '/backends/weighted/%{id}'
  replacements = {
    id: id,
  }
  @client.delete(path % replacements)
end
delete!(id: "") click to toggle source

Delete a Weighted backend by ID. Throws an exception if API error.

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

ngrok.com/docs/api#api-weighted-backends-delete

# File lib/ngrokapi/services/weighted_backends_client.rb, line 90
def delete!(id: "")
  path = '/backends/weighted/%{id}'
  replacements = {
    id: id,
  }
  @client.delete(path % replacements, danger: true)
end
get(id: "") click to toggle source

Get detailed information about a Weighted backend by ID

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

ngrok.com/docs/api#api-weighted-backends-get

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

Get detailed information about a Weighted backend by ID Throws an exception if API error.

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

ngrok.com/docs/api#api-weighted-backends-get

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

List all Weighted backends on this 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-weighted-backends-list

# File lib/ngrokapi/services/weighted_backends_client.rb, line 142
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::WeightedBackend
  )
end
list!(before_id: nil, limit: nil, url: nil) click to toggle source

List all Weighted backends on this 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-weighted-backends-list

# File lib/ngrokapi/services/weighted_backends_client.rb, line 168
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::WeightedBackend,
    danger: true
  )
end
update(id: "", description: nil, metadata: nil, backends: {}) click to toggle source

Update Weighted backend by ID

@param [string] id @param [string] description human-readable description of this backend. Optional @param [string] metadata arbitrary user-defined machine-readable data of this backend. Optional @param [Map<string, int64>] backends the ids of the child backends to their weights [0-10000] @return [NgrokAPI::Models::WeightedBackend] result from the API request

ngrok.com/docs/api#api-weighted-backends-update

# File lib/ngrokapi/services/weighted_backends_client.rb, line 196
def update(id: "", description: nil, metadata: nil, backends: {})
  path = '/backends/weighted/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  data[:description] = description if description
  data[:metadata] = metadata if metadata
  data[:backends] = backends if backends
  result = @client.patch(path % replacements, data: data)
  NgrokAPI::Models::WeightedBackend.new(client: self, attrs: result)
end
update!(id: "", description: nil, metadata: nil, backends: {}) click to toggle source

Update Weighted backend by ID Throws an exception if API error.

@param [string] id @param [string] description human-readable description of this backend. Optional @param [string] metadata arbitrary user-defined machine-readable data of this backend. Optional @param [Map<string, int64>] backends the ids of the child backends to their weights [0-10000] @return [NgrokAPI::Models::WeightedBackend] result from the API request

ngrok.com/docs/api#api-weighted-backends-update

# File lib/ngrokapi/services/weighted_backends_client.rb, line 220
def update!(id: "", description: nil, metadata: nil, backends: {})
  path = '/backends/weighted/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  data[:description] = description if description
  data[:metadata] = metadata if metadata
  data[:backends] = backends if backends
  result = @client.patch(path % replacements, data: data, danger: true)
  NgrokAPI::Models::WeightedBackend.new(client: self, attrs: result)
end