class NgrokAPI::Services::IPPolicyRulesClient

IP Policy Rules are the IPv4 or IPv6 CIDRs entries that

make up an IP Policy.

ngrok.com/docs/api#api-ip-policy-rules

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

Public Instance Methods

create(description: "", metadata: "", cidr:, ip_policy_id:, action: nil) click to toggle source

Create a new IP policy rule attached to an IP Policy.

@param [string] description human-readable description of the source IPs of this IP rule. optional, max 255 bytes. @param [string] metadata arbitrary user-defined machine-readable data of this IP policy rule. optional, max 4096 bytes. @param [string] cidr an IP or IP range specified in CIDR notation. IPv4 and IPv6 are both supported. @param [string] ip_policy_id ID of the IP policy this IP policy rule will be attached to @param [string] action the action to apply to the policy rule, either “allow“ or “deny“ @return [NgrokAPI::Models::IPPolicyRule] result from the API request

ngrok.com/docs/api#api-ip-policy-rules-create

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

Create a new IP policy rule attached to an IP Policy. Throws an exception if API error.

@param [string] description human-readable description of the source IPs of this IP rule. optional, max 255 bytes. @param [string] metadata arbitrary user-defined machine-readable data of this IP policy rule. optional, max 4096 bytes. @param [string] cidr an IP or IP range specified in CIDR notation. IPv4 and IPv6 are both supported. @param [string] ip_policy_id ID of the IP policy this IP policy rule will be attached to @param [string] action the action to apply to the policy rule, either “allow“ or “deny“ @return [NgrokAPI::Models::IPPolicyRule] result from the API request

ngrok.com/docs/api#api-ip-policy-rules-create

# File lib/ngrokapi/services/ip_policy_rules_client.rb, line 59
def create!(description: "", metadata: "", cidr:, ip_policy_id:, action: nil)
  path = '/ip_policy_rules'
  replacements = {
  }
  data = {}
  data[:description] = description if description
  data[:metadata] = metadata if metadata
  data[:cidr] = cidr if cidr
  data[:ip_policy_id] = ip_policy_id if ip_policy_id
  data[:action] = action if action
  result = @client.post(path % replacements, data: data, danger: true)
  NgrokAPI::Models::IPPolicyRule.new(client: self, attrs: result)
end
delete(id: "") click to toggle source

Delete an IP policy rule.

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

ngrok.com/docs/api#api-ip-policy-rules-delete

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

Delete an IP policy rule. 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-ip-policy-rules-delete

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

Get detailed information about an IP policy rule by ID.

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

ngrok.com/docs/api#api-ip-policy-rules-get

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

Get detailed information about an IP policy rule by ID. Throws an exception if API error.

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

ngrok.com/docs/api#api-ip-policy-rules-get

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

List all IP policy rules 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-ip-policy-rules-list

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

List all IP policy rules 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-ip-policy-rules-list

# File lib/ngrokapi/services/ip_policy_rules_client.rb, line 174
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::IPPolicyRule,
    danger: true
  )
end
update(id: "", description: nil, metadata: nil, cidr: nil) click to toggle source

Update attributes of an IP policy rule by ID

@param [string] id @param [string] description human-readable description of the source IPs of this IP rule. optional, max 255 bytes. @param [string] metadata arbitrary user-defined machine-readable data of this IP policy rule. optional, max 4096 bytes. @param [string] cidr an IP or IP range specified in CIDR notation. IPv4 and IPv6 are both supported. @return [NgrokAPI::Models::IPPolicyRule] result from the API request

ngrok.com/docs/api#api-ip-policy-rules-update

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

Update attributes of an IP policy rule by ID Throws an exception if API error.

@param [string] id @param [string] description human-readable description of the source IPs of this IP rule. optional, max 255 bytes. @param [string] metadata arbitrary user-defined machine-readable data of this IP policy rule. optional, max 4096 bytes. @param [string] cidr an IP or IP range specified in CIDR notation. IPv4 and IPv6 are both supported. @return [NgrokAPI::Models::IPPolicyRule] result from the API request

ngrok.com/docs/api#api-ip-policy-rules-update

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