Class: Vapi::SipTrunkGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/sip_trunk_gateway.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip:, port: OMIT, netmask: OMIT, inbound_enabled: OMIT, outbound_enabled: OMIT, outbound_protocol: OMIT, options_ping_enabled: OMIT, additional_properties: nil) ⇒ Vapi::SipTrunkGateway

Parameters:

  • ip (String)

    This is the address of the gateway. It can be an IPv4 address like 1.1.1.1 or a fully qualified domain name like my-sip-trunk.pstn.twilio.com.

  • port (Float) (defaults to: OMIT)

    This is the port number of the gateway. Default is 5060. @default 5060

  • netmask (Float) (defaults to: OMIT)

    This is the netmask of the gateway. Defaults to 32. @default 32

  • inbound_enabled (Boolean) (defaults to: OMIT)

    This is whether inbound calls are allowed from this gateway. Default is true. @default true

  • outbound_enabled (Boolean) (defaults to: OMIT)

    This is whether outbound calls should be sent to this gateway. Default is true. Note, if netmask is less than 32, it doesn’t affect the outbound IPs that are tried. 1 attempt is made to ‘ip:port`. @default true

  • outbound_protocol (Vapi::SipTrunkGatewayOutboundProtocol) (defaults to: OMIT)

    This is the protocol to use for SIP signaling outbound calls. Default is udp. @default udp

  • options_ping_enabled (Boolean) (defaults to: OMIT)

    This is whether to send options ping to the gateway. This can be used to check if the gateway is reachable. Default is false. This is useful for high availability setups where you want to check if the gateway is reachable before routing calls to it. Note, if no gateway for a trunk is reachable, outbound calls will be rejected. @default false

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 66

def initialize(ip:, port: OMIT, netmask: OMIT, inbound_enabled: OMIT, outbound_enabled: OMIT,
               outbound_protocol: OMIT, options_ping_enabled: OMIT, additional_properties: nil)
  @ip = ip
  @port = port if port != OMIT
  @netmask = netmask if netmask != OMIT
  @inbound_enabled = inbound_enabled if inbound_enabled != OMIT
  @outbound_enabled = outbound_enabled if outbound_enabled != OMIT
  @outbound_protocol = outbound_protocol if outbound_protocol != OMIT
  @options_ping_enabled = options_ping_enabled if options_ping_enabled != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "ip": ip,
    "port": port,
    "netmask": netmask,
    "inboundEnabled": inbound_enabled,
    "outboundEnabled": outbound_enabled,
    "outboundProtocol": outbound_protocol,
    "optionsPingEnabled": options_ping_enabled
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



37
38
39
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 37

def additional_properties
  @additional_properties
end

#inbound_enabledBoolean (readonly)

Returns This is whether inbound calls are allowed from this gateway. Default is true. @default true.

Returns:

  • (Boolean)

    This is whether inbound calls are allowed from this gateway. Default is true. @default true



20
21
22
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 20

def inbound_enabled
  @inbound_enabled
end

#ipString (readonly)

Returns This is the address of the gateway. It can be an IPv4 address like 1.1.1.1 or a fully qualified domain name like my-sip-trunk.pstn.twilio.com.

Returns:

  • (String)

    This is the address of the gateway. It can be an IPv4 address like 1.1.1.1 or a fully qualified domain name like my-sip-trunk.pstn.twilio.com.



11
12
13
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 11

def ip
  @ip
end

#netmaskFloat (readonly)

Returns This is the netmask of the gateway. Defaults to 32. @default 32.

Returns:

  • (Float)

    This is the netmask of the gateway. Defaults to 32. @default 32



17
18
19
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 17

def netmask
  @netmask
end

#options_ping_enabledBoolean (readonly)

Returns This is whether to send options ping to the gateway. This can be used to check if the gateway is reachable. Default is false. This is useful for high availability setups where you want to check if the gateway is reachable before routing calls to it. Note, if no gateway for a trunk is reachable, outbound calls will be rejected. @default false.

Returns:

  • (Boolean)

    This is whether to send options ping to the gateway. This can be used to check if the gateway is reachable. Default is false. This is useful for high availability setups where you want to check if the gateway is reachable before routing calls to it. Note, if no gateway for a trunk is reachable, outbound calls will be rejected. @default false



35
36
37
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 35

def options_ping_enabled
  @options_ping_enabled
end

#outbound_enabledBoolean (readonly)

Returns This is whether outbound calls should be sent to this gateway. Default is true. Note, if netmask is less than 32, it doesn’t affect the outbound IPs that are tried. 1 attempt is made to ‘ip:port`. @default true.

Returns:

  • (Boolean)

    This is whether outbound calls should be sent to this gateway. Default is true. Note, if netmask is less than 32, it doesn’t affect the outbound IPs that are tried. 1 attempt is made to ‘ip:port`. @default true



25
26
27
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 25

def outbound_enabled
  @outbound_enabled
end

#outbound_protocolVapi::SipTrunkGatewayOutboundProtocol (readonly)

Returns This is the protocol to use for SIP signaling outbound calls. Default is udp. @default udp.

Returns:



28
29
30
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 28

def outbound_protocol
  @outbound_protocol
end

#portFloat (readonly)

Returns This is the port number of the gateway. Default is 5060. @default 5060.

Returns:

  • (Float)

    This is the port number of the gateway. Default is 5060. @default 5060



14
15
16
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 14

def port
  @port
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::SipTrunkGateway

Deserialize a JSON object to an instance of SipTrunkGateway

Parameters:

  • json_object (String)

Returns:



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 93

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  ip = parsed_json["ip"]
  port = parsed_json["port"]
  netmask = parsed_json["netmask"]
  inbound_enabled = parsed_json["inboundEnabled"]
  outbound_enabled = parsed_json["outboundEnabled"]
  outbound_protocol = parsed_json["outboundProtocol"]
  options_ping_enabled = parsed_json["optionsPingEnabled"]
  new(
    ip: ip,
    port: port,
    netmask: netmask,
    inbound_enabled: inbound_enabled,
    outbound_enabled: outbound_enabled,
    outbound_protocol: outbound_protocol,
    options_ping_enabled: options_ping_enabled,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


128
129
130
131
132
133
134
135
136
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 128

def self.validate_raw(obj:)
  obj.ip.is_a?(String) != false || raise("Passed value for field obj.ip is not the expected type, validation failed.")
  obj.port&.is_a?(Float) != false || raise("Passed value for field obj.port is not the expected type, validation failed.")
  obj.netmask&.is_a?(Float) != false || raise("Passed value for field obj.netmask is not the expected type, validation failed.")
  obj.inbound_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.inbound_enabled is not the expected type, validation failed.")
  obj.outbound_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.outbound_enabled is not the expected type, validation failed.")
  obj.outbound_protocol&.is_a?(Vapi::SipTrunkGatewayOutboundProtocol) != false || raise("Passed value for field obj.outbound_protocol is not the expected type, validation failed.")
  obj.options_ping_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.options_ping_enabled is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of SipTrunkGateway to a JSON object

Returns:

  • (String)


118
119
120
# File 'lib/vapi_server_sdk/types/sip_trunk_gateway.rb', line 118

def to_json(*_args)
  @_field_set&.to_json
end