Class: LiveKit::SIPServiceClient
- Inherits:
-
Twirp::Client
- Object
- Twirp::Client
- LiveKit::SIPServiceClient
- Includes:
- AuthMixin
- Defined in:
- lib/livekit/sip_service_client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
Instance Method Summary collapse
- #create_sip_dispatch_rule(rule, name: nil, trunk_ids: nil, inbound_numbers: nil, hide_phone_number: nil, metadata: nil, attributes: nil, room_config: nil) ⇒ Object
- #create_sip_inbound_trunk(name, numbers, metadata: nil, allowed_addresses: nil, allowed_numbers: nil, auth_username: nil, auth_password: nil, headers: nil, headers_to_attributes: nil, include_headers: Proto::SIPHeaderOptions::SIP_NO_HEADERS, krisp_enabled: false) ⇒ Object
- #create_sip_outbound_trunk(name, address, numbers, metadata: nil, transport: nil, auth_username: nil, auth_password: nil, headers: nil, headers_to_attributes: nil) ⇒ Object
- #create_sip_participant(sip_trunk_id, sip_call_to, room_name, from_number: nil, participant_identity: nil, participant_name: nil, participant_metadata: nil, dtmf: nil, play_dialtone: false, hide_phone_number: nil, ringing_timeout: nil, max_call_duration: nil, krisp_enabled: false) ⇒ Object
- #delete_sip_dispatch_rule(sip_dispatch_rule_id) ⇒ Object
- #delete_sip_trunk(sip_trunk_id) ⇒ Object
-
#initialize(base_url, api_key: nil, api_secret: nil) ⇒ SIPServiceClient
constructor
A new instance of SIPServiceClient.
- #list_sip_dispatch_rule ⇒ Object
- #list_sip_inbound_trunk ⇒ Object
- #list_sip_outbound_trunk ⇒ Object
- #transfer_sip_participant(room_name, participant_identity, transfer_to, play_dialtone: nil) ⇒ Object
Methods included from AuthMixin
Constructor Details
#initialize(base_url, api_key: nil, api_secret: nil) ⇒ SIPServiceClient
Returns a new instance of SIPServiceClient.
11 12 13 14 15 |
# File 'lib/livekit/sip_service_client.rb', line 11 def initialize(base_url, api_key: nil, api_secret: nil) super(File.join(Utils.to_http_url(base_url), "/twirp")) @api_key = api_key @api_secret = api_secret end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/livekit/sip_service_client.rb', line 9 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
9 10 11 |
# File 'lib/livekit/sip_service_client.rb', line 9 def api_secret @api_secret end |
Instance Method Details
#create_sip_dispatch_rule(rule, name: nil, trunk_ids: nil, inbound_numbers: nil, hide_phone_number: nil, metadata: nil, attributes: nil, room_config: nil) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/livekit/sip_service_client.rb', line 130 def create_sip_dispatch_rule( rule, name: nil, trunk_ids: nil, inbound_numbers: nil, hide_phone_number: nil, metadata: nil, attributes: nil, room_config: nil ) request = Proto::CreateSIPDispatchRuleRequest.new( rule: rule, name: name, trunk_ids: trunk_ids, inbound_numbers: inbound_numbers, hide_phone_number: hide_phone_number, metadata: , attributes: attributes, room_config: room_config, ) self.rpc( :CreateSIPDispatchRule, request, headers: auth_header(sip_grant: SIPGrant.new(admin: true)), ) end |
#create_sip_inbound_trunk(name, numbers, metadata: nil, allowed_addresses: nil, allowed_numbers: nil, auth_username: nil, auth_password: nil, headers: nil, headers_to_attributes: nil, include_headers: Proto::SIPHeaderOptions::SIP_NO_HEADERS, krisp_enabled: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/livekit/sip_service_client.rb', line 17 def create_sip_inbound_trunk( # name to identify the trunk name, # numbers associated with LiveKit SIP. The Trunk will only accept calls made to these numbers. numbers, # optional, metadata to attach to the trunk metadata: nil, # optional, CIDR or IPs that traffic is accepted from. allowed_addresses: nil, # CIDR or IPs that traffic is accepted from. allowed_numbers: nil, # optional, Username and password used to authenticate inbound SIP invites. auth_username: nil, auth_password: nil, # optional, include these SIP X-* headers in 200 OK responses. headers: nil, # optional, map SIP X-* headers from INVITE to SIP participant attributes. headers_to_attributes: nil, # optional, map SIP response headers from INVITE to sip.h.* participant attributes automatically. include_headers: Proto::SIPHeaderOptions::SIP_NO_HEADERS, # optional, enable Krisp for this trunk krisp_enabled: false ) request = Proto::CreateSIPInboundTrunkRequest.new( trunk: Proto::SIPInboundTrunkInfo.new( name: name, metadata: , numbers: numbers, allowed_addresses: allowed_addresses, allowed_numbers: allowed_numbers, auth_username: auth_username, auth_password: auth_password, headers: headers, headers_to_attributes: headers_to_attributes, include_headers: include_headers, krisp_enabled: krisp_enabled ) ) self.rpc( :CreateSIPInboundTrunk, request, headers: auth_header(sip_grant: SIPGrant.new(admin: true)), ) end |
#create_sip_outbound_trunk(name, address, numbers, metadata: nil, transport: nil, auth_username: nil, auth_password: nil, headers: nil, headers_to_attributes: nil) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/livekit/sip_service_client.rb', line 62 def create_sip_outbound_trunk( # name to identify the trunk name, # Hostname or IP that SIP INVITE is sent too. address, # Numbers used to make the calls. Random one from this list will be selected. numbers, # optional, metadata to attach to the trunk metadata: nil, # SIP Transport used for outbound call. transport: nil, # optional, Username and password used to authenticate inbound SIP invites. auth_username: nil, auth_password: nil, # optional, include these SIP X-* headers in 200 OK responses. headers: nil, # optional map SIP X-* headers from INVITE to SIP participant attributes. headers_to_attributes: nil ) request = Proto::CreateSIPOutboundTrunkRequest.new( trunk: Proto::SIPOutboundTrunkInfo.new( name: name, address: address, numbers: numbers, metadata: , transport: transport, auth_username: auth_username, auth_password: auth_password, headers: headers, headers_to_attributes: headers_to_attributes ) ) self.rpc( :CreateSIPOutboundTrunk, request, headers: auth_header(sip_grant: SIPGrant.new(admin: true)), ) end |
#create_sip_participant(sip_trunk_id, sip_call_to, room_name, from_number: nil, participant_identity: nil, participant_name: nil, participant_metadata: nil, dtmf: nil, play_dialtone: false, hide_phone_number: nil, ringing_timeout: nil, max_call_duration: nil, krisp_enabled: false) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/livekit/sip_service_client.rb', line 177 def create_sip_participant( sip_trunk_id, sip_call_to, room_name, # Optional SIP From number to use. If empty, trunk number is used. from_number: nil, # Optional identity of the participant in LiveKit room participant_identity: nil, # Optional name of the participant in LiveKit room participant_name: nil, # Optional metadata of the participant in LiveKit room participant_metadata: nil, # Optional, send following DTMF digits (extension codes) when making a call. # Character 'w' can be used to add a 0.5 sec delay. dtmf: nil, # Optional, play dialtone for the participant play_dialtone: false, # Optional, hide phone number from participant attributes hide_phone_number: nil, # Optional, ringing timeout in seconds ringing_timeout: nil, # Optional, max call duration in seconds max_call_duration: nil, # Optional, enable Krisp for this call krisp_enabled: false ) request = Proto::CreateSIPParticipantRequest.new( sip_trunk_id: sip_trunk_id, sip_call_to: sip_call_to, sip_number: from_number, room_name: room_name, participant_identity: participant_identity, participant_name: participant_name, participant_metadata: , dtmf: dtmf, play_dialtone: play_dialtone, hide_phone_number: hide_phone_number, ringing_timeout: ringing_timeout, max_call_duration: max_call_duration, krisp_enabled: krisp_enabled ) self.rpc( :CreateSIPParticipant, request, headers: auth_header(sip_grant: SIPGrant.new(call: true)), ) end |
#delete_sip_dispatch_rule(sip_dispatch_rule_id) ⇒ Object
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/livekit/sip_service_client.rb', line 166 def delete_sip_dispatch_rule(sip_dispatch_rule_id) request = Proto::DeleteSIPDispatchRuleRequest.new( sip_dispatch_rule_id: sip_dispatch_rule_id, ) self.rpc( :DeleteSIPDispatchRule, request, headers: auth_header(sip_grant: SIPGrant.new(admin: true)), ) end |
#delete_sip_trunk(sip_trunk_id) ⇒ Object
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/livekit/sip_service_client.rb', line 119 def delete_sip_trunk(sip_trunk_id) request = Proto::DeleteSIPTrunkRequest.new( sip_trunk_id: sip_trunk_id, ) self.rpc( :DeleteSIPTrunk, request, headers: auth_header(sip_grant: SIPGrant.new(admin: true)), ) end |
#list_sip_dispatch_rule ⇒ Object
157 158 159 160 161 162 163 164 |
# File 'lib/livekit/sip_service_client.rb', line 157 def list_sip_dispatch_rule request = Proto::ListSIPDispatchRuleRequest.new self.rpc( :ListSIPDispatchRule, request, headers: auth_header(sip_grant: SIPGrant.new(admin: true)), ) end |
#list_sip_inbound_trunk ⇒ Object
101 102 103 104 105 106 107 108 |
# File 'lib/livekit/sip_service_client.rb', line 101 def list_sip_inbound_trunk request = Proto::ListSIPInboundTrunkRequest.new self.rpc( :ListSIPInboundTrunk, request, headers: auth_header(sip_grant: SIPGrant.new(admin: true)), ) end |
#list_sip_outbound_trunk ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/livekit/sip_service_client.rb', line 110 def list_sip_outbound_trunk request = Proto::ListSIPOutboundTrunkRequest.new self.rpc( :ListSIPOutboundTrunk, request, headers: auth_header(sip_grant: SIPGrant.new(admin: true)), ) end |
#transfer_sip_participant(room_name, participant_identity, transfer_to, play_dialtone: nil) ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/livekit/sip_service_client.rb', line 225 def transfer_sip_participant( room_name, participant_identity, transfer_to, play_dialtone: nil ) request = Proto::TransferSIPParticipantRequest.new( room_name: room_name, participant_identity: participant_identity, transfer_to: transfer_to, play_dialtone: play_dialtone, ) self.rpc( :TransferSIPParticipant, request, headers: auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room_name), sip_grant: SIPGrant.new(call: true)), ) end |