-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuacconnection.go
More file actions
1069 lines (1037 loc) · 45.8 KB
/
Copy pathuacconnection.go
File metadata and controls
1069 lines (1037 loc) · 45.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
61
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package cmd
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-cli/internal/apiquery"
"github.com/team-telnyx/telnyx-cli/internal/requestflag"
"github.com/team-telnyx/telnyx-go/v4"
"github.com/team-telnyx/telnyx-go/v4/option"
"github.com/tidwall/gjson"
"github.com/urfave/cli/v3"
)
var uacConnectionsCreate = requestflag.WithInnerFlags(cli.Command{
Name: "create",
Usage: "Creates a UAC connection. A UAC (User Agent Client) Connection registers Telnyx\nto your PBX — the opposite of a standard SIP trunk, where the PBX registers to\nTelnyx. Use UAC when your PBX doesn’t support outbound SIP registration or you\nneed Telnyx to maintain the registration.",
Suggest: true,
Flags: []cli.Flag{
&requestflag.Flag[string]{
Name: "connection-name",
Usage: "A user-assigned name to help manage the connection.",
Required: true,
BodyPath: "connection_name",
},
&requestflag.Flag[bool]{
Name: "active",
Usage: "Defaults to true",
BodyPath: "active",
},
&requestflag.Flag[string]{
Name: "anchorsite-override",
Usage: "`Latency` directs Telnyx to route media through the site with the lowest round-trip time to the user's connection. Telnyx calculates this time using ICMP ping messages. This can be disabled by specifying a site to handle all media.",
Default: "Latency",
BodyPath: "anchorsite_override",
},
&requestflag.Flag[*string]{
Name: "android-push-credential-id",
Usage: "The uuid of the push credential for Android",
Default: nil,
BodyPath: "android_push_credential_id",
},
&requestflag.Flag[bool]{
Name: "call-cost-in-webhooks",
Usage: "Specifies if call cost webhooks should be sent for this connection.",
Default: false,
BodyPath: "call_cost_in_webhooks",
},
&requestflag.Flag[bool]{
Name: "default-on-hold-comfort-noise-enabled",
Usage: "When enabled, Telnyx will generate comfort noise when you place the call on hold. If disabled, you will need to generate comfort noise or on hold music to avoid RTP timeout.",
Default: false,
BodyPath: "default_on_hold_comfort_noise_enabled",
},
&requestflag.Flag[string]{
Name: "dtmf-type",
Usage: "Sets the type of DTMF digits sent from Telnyx to this Connection. Note that DTMF digits sent to Telnyx will be accepted in all formats.",
Default: "RFC 2833",
BodyPath: "dtmf_type",
},
&requestflag.Flag[bool]{
Name: "encode-contact-header-enabled",
Usage: "Encode the SIP contact header sent by Telnyx to avoid issues for NAT or ALG scenarios.",
Default: false,
BodyPath: "encode_contact_header_enabled",
},
&requestflag.Flag[*string]{
Name: "encrypted-media",
Usage: "Enable use of SRTP for encryption. Cannot be set if the transport_portocol is TLS.",
BodyPath: "encrypted_media",
},
&requestflag.Flag[map[string]any]{
Name: "external-uac-settings",
Usage: "External SIP peer settings used by Telnyx when registering to your PBX and routing outbound calls.",
BodyPath: "external_uac_settings",
},
&requestflag.Flag[map[string]any]{
Name: "inbound",
Usage: "Inbound settings that can be supplied when creating or updating a UAC connection. The SIP subdomain fields returned in UAC connection responses are generated by Telnyx and are not accepted as request parameters.",
BodyPath: "inbound",
},
&requestflag.Flag[map[string]any]{
Name: "internal-uac-settings",
Usage: "Internal Telnyx-side settings for a UAC connection.",
BodyPath: "internal_uac_settings",
},
&requestflag.Flag[*string]{
Name: "ios-push-credential-id",
Usage: "The uuid of the push credential for Ios",
Default: nil,
BodyPath: "ios_push_credential_id",
},
&requestflag.Flag[map[string]any]{
Name: "jitter-buffer",
Usage: "Configuration options for Jitter Buffer. Enables Jitter Buffer for RTP streams of SIP Trunking calls. The feature is off unless enabled. You may define min and max values in msec for customized buffering behaviors. Larger values add latency but tolerate more jitter, while smaller values reduce latency but are more sensitive to jitter and reordering.",
BodyPath: "jitter_buffer",
},
&requestflag.Flag[string]{
Name: "noise-suppression",
Usage: "Controls when noise suppression is applied to calls. When set to 'inbound', noise suppression is applied to incoming audio. When set to 'outbound', it's applied to outgoing audio. When set to 'both', it's applied in both directions. When set to 'disabled', noise suppression is turned off.",
BodyPath: "noise_suppression",
},
&requestflag.Flag[map[string]any]{
Name: "noise-suppression-details",
Usage: "Configuration options for noise suppression. These settings are stored regardless of the noise_suppression value, but only take effect when noise_suppression is not 'disabled'. If you disable noise suppression and later re-enable it, the previously configured settings will be used.",
BodyPath: "noise_suppression_details",
},
&requestflag.Flag[bool]{
Name: "onnet-t38-passthrough-enabled",
Usage: "Enable on-net T38 if you prefer the sender and receiver negotiating T38 directly if both are on the Telnyx network. If this is disabled, Telnyx will be able to use T38 on just one leg of the call depending on each leg's settings.",
Default: false,
BodyPath: "onnet_t38_passthrough_enabled",
},
&requestflag.Flag[map[string]any]{
Name: "outbound",
BodyPath: "outbound",
},
&requestflag.Flag[string]{
Name: "password",
Usage: "The password to be used as part of the credentials. Must be 8 to 128 characters long.",
BodyPath: "password",
},
&requestflag.Flag[map[string]any]{
Name: "rtcp-settings",
BodyPath: "rtcp_settings",
},
&requestflag.Flag[string]{
Name: "sip-uri-calling-preference",
Usage: "This feature enables inbound SIP URI calls to your Credential Auth Connection. If enabled for all (unrestricted) then anyone who calls the SIP URI <your-username>@telnyx.com will be connected to your Connection. You can also choose to allow only calls that are originated on any Connections under your account (internal).",
BodyPath: "sip_uri_calling_preference",
},
&requestflag.Flag[[]string]{
Name: "tag",
Usage: "Tags associated with the connection.",
BodyPath: "tags",
},
&requestflag.Flag[string]{
Name: "user-name",
Usage: "The user name to be used as part of the credentials. Must be 4-32 characters long and alphanumeric values only (no spaces or special characters).",
BodyPath: "user_name",
},
&requestflag.Flag[string]{
Name: "webhook-api-version",
Usage: "Determines which webhook format will be used, Telnyx API v1, v2 or texml. Note - texml can only be set when the outbound object parameter call_parking_enabled is included and set to true.",
Default: "1",
BodyPath: "webhook_api_version",
},
&requestflag.Flag[*string]{
Name: "webhook-event-failover-url",
Usage: "The failover URL where webhooks related to this connection will be sent if sending to the primary URL fails. Must include a scheme, such as 'https'.",
Default: requestflag.Ptr[string](""),
BodyPath: "webhook_event_failover_url",
},
&requestflag.Flag[string]{
Name: "webhook-event-url",
Usage: "The URL where webhooks related to this connection will be sent. Must include a scheme, such as 'https'.",
BodyPath: "webhook_event_url",
},
&requestflag.Flag[*int64]{
Name: "webhook-timeout-secs",
Usage: "Specifies how many seconds to wait before timing out a webhook.",
Default: nil,
BodyPath: "webhook_timeout_secs",
},
},
Action: handleUacConnectionsCreate,
HideHelpCommand: true,
}, map[string][]requestflag.HasOuterFlag{
"external-uac-settings": {
&requestflag.InnerFlag[*string]{
Name: "external-uac-settings.auth-username",
Usage: "The authentication username used in SIP digest authentication. If not set, the Username value will be used.",
InnerField: "auth_username",
},
&requestflag.InnerFlag[*int64]{
Name: "external-uac-settings.expiration-sec",
Usage: "The registration interval, in seconds, indicating how often the system refreshes the SIP registration with the external SIP peer.",
InnerField: "expiration_sec",
},
&requestflag.InnerFlag[*string]{
Name: "external-uac-settings.from-user",
Usage: "The user portion of the SIP From header used in outbound requests. This controls the caller identity presented to the external SIP peer.",
InnerField: "from_user",
},
&requestflag.InnerFlag[*string]{
Name: "external-uac-settings.outbound-proxy",
Usage: "An optional SIP proxy used to route outbound requests before reaching the external SIP peer.",
InnerField: "outbound_proxy",
},
&requestflag.InnerFlag[string]{
Name: "external-uac-settings.password",
Usage: "The SIP password used for digest authentication with the external SIP peer.",
InnerField: "password",
},
&requestflag.InnerFlag[string]{
Name: "external-uac-settings.proxy",
Usage: "The SIP proxy address of the external SIP peer used for registrations and outbound call routing.",
InnerField: "proxy",
},
&requestflag.InnerFlag[*string]{
Name: "external-uac-settings.transport",
Usage: "The transport protocol used for SIP signaling when communicating with the external SIP peer. One of UDP, TLS, or TCP.",
InnerField: "transport",
},
&requestflag.InnerFlag[string]{
Name: "external-uac-settings.username",
Usage: "The SIP username used to authenticate with the external SIP peer for registrations and outbound calls. Must start with a letter or number and contain only letters, numbers, hyphens, and underscores.",
InnerField: "username",
},
},
"inbound": {
&requestflag.InnerFlag[string]{
Name: "inbound.ani-number-format",
Usage: "This setting allows you to set the format with which the caller's number (ANI) is sent for inbound phone calls.",
InnerField: "ani_number_format",
},
&requestflag.InnerFlag[int64]{
Name: "inbound.channel-limit",
Usage: "When set, this will limit the total number of inbound calls to phone numbers associated with this connection.",
InnerField: "channel_limit",
},
&requestflag.InnerFlag[[]string]{
Name: "inbound.codecs",
Usage: "Defines the list of codecs that Telnyx will send for inbound calls to a specific number on your portal account, in priority order. This only works when the Connection the number is assigned to uses Media Handling mode: default. OPUS and H.264 codecs are available only when using TCP or TLS transport for SIP.",
InnerField: "codecs",
},
&requestflag.InnerFlag[string]{
Name: "inbound.default-routing-method",
Usage: "Default routing method to be used when a number is associated with the connection. Must be one of the routing method types or left blank, other values are not allowed.",
InnerField: "default_routing_method",
},
&requestflag.InnerFlag[string]{
Name: "inbound.dnis-number-format",
Usage: `Allowed values: "+e164", "e164", "national", "sip_username".`,
InnerField: "dnis_number_format",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.generate-ringback-tone",
Usage: "Generate ringback tone through 183 session progress message with early media.",
InnerField: "generate_ringback_tone",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.isup-headers-enabled",
Usage: "When set, inbound phone calls will receive ISUP parameters via SIP headers. (Only when available and only when using TCP or TLS transport.)",
InnerField: "isup_headers_enabled",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.prack-enabled",
Usage: "Enable PRACK messages as defined in RFC3262.",
InnerField: "prack_enabled",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.shaken-stir-enabled",
Usage: "When enabled the SIP Connection will receive the Identity header with Shaken/Stir data in the SIP INVITE message of inbound calls, even when using UDP transport.",
InnerField: "shaken_stir_enabled",
},
&requestflag.InnerFlag[string]{
Name: "inbound.simultaneous-ringing",
Usage: "When enabled, allows multiple devices to ring simultaneously on incoming calls.",
InnerField: "simultaneous_ringing",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.sip-compact-headers-enabled",
Usage: "Defaults to true.",
InnerField: "sip_compact_headers_enabled",
},
&requestflag.InnerFlag[string]{
Name: "inbound.sip-region",
Usage: "Selects which `sip_region` to receive inbound calls from. If null, the default region (US) will be used.",
InnerField: "sip_region",
},
&requestflag.InnerFlag[int64]{
Name: "inbound.timeout-1xx-secs",
Usage: "Time(sec) before aborting if connection is not made.",
InnerField: "timeout_1xx_secs",
},
&requestflag.InnerFlag[int64]{
Name: "inbound.timeout-2xx-secs",
Usage: "Time(sec) before aborting if call is unanswered (min: 1, max: 600).",
InnerField: "timeout_2xx_secs",
},
},
"internal-uac-settings": {
&requestflag.InnerFlag[string]{
Name: "internal-uac-settings.destination-uri",
Usage: "The SIP URI that Telnyx will call when handling an inbound request from the external peer. Do not include a `sip:` prefix. The value must be in the format `userinfo@<subdomain.>sip.telnyx.com` or `userinfo@<subdomain.>sipdev.telnyx.com`; the userinfo portion may contain only letters, digits, hyphens, and underscores.",
InnerField: "destination_uri",
},
},
"jitter-buffer": {
&requestflag.InnerFlag[bool]{
Name: "jitter-buffer.enable-jitter-buffer",
Usage: "Enables Jitter Buffer for RTP streams of SIP Trunking calls. The feature is off unless enabled.",
InnerField: "enable_jitter_buffer",
},
&requestflag.InnerFlag[int64]{
Name: "jitter-buffer.jitterbuffer-msec-max",
Usage: "The maximum jitter buffer size in milliseconds. Must be between 40 and 400. Has no effect if enable_jitter_buffer is not true.",
InnerField: "jitterbuffer_msec_max",
},
&requestflag.InnerFlag[int64]{
Name: "jitter-buffer.jitterbuffer-msec-min",
Usage: "The minimum jitter buffer size in milliseconds. Must be between 40 and 400. Has no effect if enable_jitter_buffer is not true.",
InnerField: "jitterbuffer_msec_min",
},
},
"noise-suppression-details": {
&requestflag.InnerFlag[int64]{
Name: "noise-suppression-details.attenuation-limit",
Usage: "The attenuation limit value for the selected engine. Default values vary by engine: 0 for 'denoiser', 80 for 'deep_filter_net', 'deep_filter_net_large', and all Krisp engines ('krisp_viva_tel', 'krisp_viva_tel_lite', 'krisp_viva_promodel', 'krisp_viva_ss'), 100 for 'quail_voice_focus'.",
InnerField: "attenuation_limit",
},
&requestflag.InnerFlag[string]{
Name: "noise-suppression-details.engine",
Usage: "The noise suppression engine to use. 'denoiser' is the default engine. 'deep_filter_net' and 'deep_filter_net_large' are alternative engines with different performance characteristics. Krisp engines ('krisp_viva_tel', 'krisp_viva_tel_lite', 'krisp_viva_promodel', 'krisp_viva_ss') provide advanced noise suppression capabilities. 'quail_voice_focus' provides Quail-based voice focus noise suppression.",
InnerField: "engine",
},
},
"outbound": {
&requestflag.InnerFlag[string]{
Name: "outbound.ani-override",
Usage: "Set a phone number as the ani_override value to override caller id number on outbound calls.",
InnerField: "ani_override",
},
&requestflag.InnerFlag[string]{
Name: "outbound.ani-override-type",
Usage: "Specifies when we apply your ani_override setting. Only applies when ani_override is not blank.",
InnerField: "ani_override_type",
},
&requestflag.InnerFlag[*bool]{
Name: "outbound.call-parking-enabled",
Usage: `Forces all SIP calls originated on this connection to be "parked" instead of "bridged" to the destination specified on the URI. Parked calls will return ringback to the caller and will await for a Call Control command to define which action will be taken next.`,
InnerField: "call_parking_enabled",
},
&requestflag.InnerFlag[int64]{
Name: "outbound.channel-limit",
Usage: "When set, this will limit the total number of outbound calls to phone numbers associated with this connection.",
InnerField: "channel_limit",
},
&requestflag.InnerFlag[bool]{
Name: "outbound.generate-ringback-tone",
Usage: "Generate ringback tone through 183 session progress message with early media.",
InnerField: "generate_ringback_tone",
},
&requestflag.InnerFlag[bool]{
Name: "outbound.instant-ringback-enabled",
Usage: "When set, ringback will not wait for indication before sending ringback tone to calling party.",
InnerField: "instant_ringback_enabled",
},
&requestflag.InnerFlag[string]{
Name: "outbound.localization",
Usage: "A 2-character country code specifying the country whose national dialing rules should be used. For example, if set to `US` then any US number can be dialed without preprending +1 to the number. When left blank, Telnyx will try US and GB dialing rules, in that order, by default.",
InnerField: "localization",
},
&requestflag.InnerFlag[string]{
Name: "outbound.outbound-voice-profile-id",
Usage: "Identifies the associated outbound voice profile.",
InnerField: "outbound_voice_profile_id",
},
&requestflag.InnerFlag[string]{
Name: "outbound.t38-reinvite-source",
Usage: "This setting only affects connections with Fax-type Outbound Voice Profiles. The setting dictates whether or not Telnyx sends a t.38 reinvite.<br/><br/> By default, Telnyx will send the re-invite. If set to `customer`, the caller is expected to send the t.38 reinvite.",
InnerField: "t38_reinvite_source",
},
},
"rtcp-settings": {
&requestflag.InnerFlag[bool]{
Name: "rtcp-settings.capture-enabled",
Usage: "BETA - Enable the capture and storage of RTCP messages to create QoS reports on the Telnyx Mission Control Portal.",
InnerField: "capture_enabled",
},
&requestflag.InnerFlag[string]{
Name: "rtcp-settings.port",
Usage: "RTCP port by default is rtp+1, it can also be set to rtcp-mux",
InnerField: "port",
},
&requestflag.InnerFlag[int64]{
Name: "rtcp-settings.report-frequency-secs",
Usage: "RTCP reports are sent to customers based on the frequency set. Frequency is in seconds and it can be set to values from 5 to 3000 seconds.",
InnerField: "report_frequency_secs",
},
},
})
var uacConnectionsRetrieve = cli.Command{
Name: "retrieve",
Usage: "Retrieves the details of an existing UAC connection.",
Suggest: true,
Flags: []cli.Flag{
&requestflag.Flag[string]{
Name: "id",
Required: true,
PathParam: "id",
},
},
Action: handleUacConnectionsRetrieve,
HideHelpCommand: true,
}
var uacConnectionsUpdate = requestflag.WithInnerFlags(cli.Command{
Name: "update",
Usage: "Updates settings of an existing UAC connection.",
Suggest: true,
Flags: []cli.Flag{
&requestflag.Flag[string]{
Name: "id",
Required: true,
PathParam: "id",
},
&requestflag.Flag[bool]{
Name: "active",
Usage: "Defaults to true",
BodyPath: "active",
},
&requestflag.Flag[string]{
Name: "anchorsite-override",
Usage: "`Latency` directs Telnyx to route media through the site with the lowest round-trip time to the user's connection. Telnyx calculates this time using ICMP ping messages. This can be disabled by specifying a site to handle all media.",
Default: "Latency",
BodyPath: "anchorsite_override",
},
&requestflag.Flag[*string]{
Name: "android-push-credential-id",
Usage: "The uuid of the push credential for Android",
Default: nil,
BodyPath: "android_push_credential_id",
},
&requestflag.Flag[bool]{
Name: "call-cost-in-webhooks",
Usage: "Specifies if call cost webhooks should be sent for this connection.",
Default: false,
BodyPath: "call_cost_in_webhooks",
},
&requestflag.Flag[string]{
Name: "connection-name",
Usage: "A user-assigned name to help manage the connection.",
BodyPath: "connection_name",
},
&requestflag.Flag[bool]{
Name: "default-on-hold-comfort-noise-enabled",
Usage: "When enabled, Telnyx will generate comfort noise when you place the call on hold. If disabled, you will need to generate comfort noise or on hold music to avoid RTP timeout.",
Default: false,
BodyPath: "default_on_hold_comfort_noise_enabled",
},
&requestflag.Flag[string]{
Name: "dtmf-type",
Usage: "Sets the type of DTMF digits sent from Telnyx to this Connection. Note that DTMF digits sent to Telnyx will be accepted in all formats.",
Default: "RFC 2833",
BodyPath: "dtmf_type",
},
&requestflag.Flag[bool]{
Name: "encode-contact-header-enabled",
Usage: "Encode the SIP contact header sent by Telnyx to avoid issues for NAT or ALG scenarios.",
Default: false,
BodyPath: "encode_contact_header_enabled",
},
&requestflag.Flag[*string]{
Name: "encrypted-media",
Usage: "Enable use of SRTP for encryption. Cannot be set if the transport_portocol is TLS.",
BodyPath: "encrypted_media",
},
&requestflag.Flag[map[string]any]{
Name: "external-uac-settings",
Usage: "External SIP peer settings used by Telnyx when registering to your PBX and routing outbound calls.",
BodyPath: "external_uac_settings",
},
&requestflag.Flag[map[string]any]{
Name: "inbound",
Usage: "Inbound settings that can be supplied when creating or updating a UAC connection. The SIP subdomain fields returned in UAC connection responses are generated by Telnyx and are not accepted as request parameters.",
BodyPath: "inbound",
},
&requestflag.Flag[map[string]any]{
Name: "internal-uac-settings",
Usage: "Internal Telnyx-side settings for a UAC connection.",
BodyPath: "internal_uac_settings",
},
&requestflag.Flag[*string]{
Name: "ios-push-credential-id",
Usage: "The uuid of the push credential for Ios",
Default: nil,
BodyPath: "ios_push_credential_id",
},
&requestflag.Flag[map[string]any]{
Name: "jitter-buffer",
Usage: "Configuration options for Jitter Buffer. Enables Jitter Buffer for RTP streams of SIP Trunking calls. The feature is off unless enabled. You may define min and max values in msec for customized buffering behaviors. Larger values add latency but tolerate more jitter, while smaller values reduce latency but are more sensitive to jitter and reordering.",
BodyPath: "jitter_buffer",
},
&requestflag.Flag[string]{
Name: "noise-suppression",
Usage: "Controls when noise suppression is applied to calls. When set to 'inbound', noise suppression is applied to incoming audio. When set to 'outbound', it's applied to outgoing audio. When set to 'both', it's applied in both directions. When set to 'disabled', noise suppression is turned off.",
BodyPath: "noise_suppression",
},
&requestflag.Flag[map[string]any]{
Name: "noise-suppression-details",
Usage: "Configuration options for noise suppression. These settings are stored regardless of the noise_suppression value, but only take effect when noise_suppression is not 'disabled'. If you disable noise suppression and later re-enable it, the previously configured settings will be used.",
BodyPath: "noise_suppression_details",
},
&requestflag.Flag[bool]{
Name: "onnet-t38-passthrough-enabled",
Usage: "Enable on-net T38 if you prefer the sender and receiver negotiating T38 directly if both are on the Telnyx network. If this is disabled, Telnyx will be able to use T38 on just one leg of the call depending on each leg's settings.",
Default: false,
BodyPath: "onnet_t38_passthrough_enabled",
},
&requestflag.Flag[map[string]any]{
Name: "outbound",
BodyPath: "outbound",
},
&requestflag.Flag[string]{
Name: "password",
Usage: "The password to be used as part of the credentials. Must be 8 to 128 characters long.",
BodyPath: "password",
},
&requestflag.Flag[map[string]any]{
Name: "rtcp-settings",
BodyPath: "rtcp_settings",
},
&requestflag.Flag[string]{
Name: "sip-uri-calling-preference",
Usage: "This feature enables inbound SIP URI calls to your Credential Auth Connection. If enabled for all (unrestricted) then anyone who calls the SIP URI <your-username>@telnyx.com will be connected to your Connection. You can also choose to allow only calls that are originated on any Connections under your account (internal).",
BodyPath: "sip_uri_calling_preference",
},
&requestflag.Flag[[]string]{
Name: "tag",
Usage: "Tags associated with the connection.",
BodyPath: "tags",
},
&requestflag.Flag[string]{
Name: "user-name",
Usage: "The user name to be used as part of the credentials. Must be 4-32 characters long and alphanumeric values only (no spaces or special characters).",
BodyPath: "user_name",
},
&requestflag.Flag[string]{
Name: "webhook-api-version",
Usage: "Determines which webhook format will be used, Telnyx API v1 or v2.",
Default: "1",
BodyPath: "webhook_api_version",
},
&requestflag.Flag[*string]{
Name: "webhook-event-failover-url",
Usage: "The failover URL where webhooks related to this connection will be sent if sending to the primary URL fails. Must include a scheme, such as 'https'.",
Default: requestflag.Ptr[string](""),
BodyPath: "webhook_event_failover_url",
},
&requestflag.Flag[string]{
Name: "webhook-event-url",
Usage: "The URL where webhooks related to this connection will be sent. Must include a scheme, such as 'https'.",
BodyPath: "webhook_event_url",
},
&requestflag.Flag[*int64]{
Name: "webhook-timeout-secs",
Usage: "Specifies how many seconds to wait before timing out a webhook.",
Default: nil,
BodyPath: "webhook_timeout_secs",
},
},
Action: handleUacConnectionsUpdate,
HideHelpCommand: true,
}, map[string][]requestflag.HasOuterFlag{
"external-uac-settings": {
&requestflag.InnerFlag[*string]{
Name: "external-uac-settings.auth-username",
Usage: "The authentication username used in SIP digest authentication. If not set, the Username value will be used.",
InnerField: "auth_username",
},
&requestflag.InnerFlag[*int64]{
Name: "external-uac-settings.expiration-sec",
Usage: "The registration interval, in seconds, indicating how often the system refreshes the SIP registration with the external SIP peer.",
InnerField: "expiration_sec",
},
&requestflag.InnerFlag[*string]{
Name: "external-uac-settings.from-user",
Usage: "The user portion of the SIP From header used in outbound requests. This controls the caller identity presented to the external SIP peer.",
InnerField: "from_user",
},
&requestflag.InnerFlag[*string]{
Name: "external-uac-settings.outbound-proxy",
Usage: "An optional SIP proxy used to route outbound requests before reaching the external SIP peer.",
InnerField: "outbound_proxy",
},
&requestflag.InnerFlag[string]{
Name: "external-uac-settings.password",
Usage: "The SIP password used for digest authentication with the external SIP peer.",
InnerField: "password",
},
&requestflag.InnerFlag[string]{
Name: "external-uac-settings.proxy",
Usage: "The SIP proxy address of the external SIP peer used for registrations and outbound call routing.",
InnerField: "proxy",
},
&requestflag.InnerFlag[*string]{
Name: "external-uac-settings.transport",
Usage: "The transport protocol used for SIP signaling when communicating with the external SIP peer. One of UDP, TLS, or TCP.",
InnerField: "transport",
},
&requestflag.InnerFlag[string]{
Name: "external-uac-settings.username",
Usage: "The SIP username used to authenticate with the external SIP peer for registrations and outbound calls. Must start with a letter or number and contain only letters, numbers, hyphens, and underscores.",
InnerField: "username",
},
},
"inbound": {
&requestflag.InnerFlag[string]{
Name: "inbound.ani-number-format",
Usage: "This setting allows you to set the format with which the caller's number (ANI) is sent for inbound phone calls.",
InnerField: "ani_number_format",
},
&requestflag.InnerFlag[int64]{
Name: "inbound.channel-limit",
Usage: "When set, this will limit the total number of inbound calls to phone numbers associated with this connection.",
InnerField: "channel_limit",
},
&requestflag.InnerFlag[[]string]{
Name: "inbound.codecs",
Usage: "Defines the list of codecs that Telnyx will send for inbound calls to a specific number on your portal account, in priority order. This only works when the Connection the number is assigned to uses Media Handling mode: default. OPUS and H.264 codecs are available only when using TCP or TLS transport for SIP.",
InnerField: "codecs",
},
&requestflag.InnerFlag[string]{
Name: "inbound.default-routing-method",
Usage: "Default routing method to be used when a number is associated with the connection. Must be one of the routing method types or left blank, other values are not allowed.",
InnerField: "default_routing_method",
},
&requestflag.InnerFlag[string]{
Name: "inbound.dnis-number-format",
Usage: `Allowed values: "+e164", "e164", "national", "sip_username".`,
InnerField: "dnis_number_format",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.generate-ringback-tone",
Usage: "Generate ringback tone through 183 session progress message with early media.",
InnerField: "generate_ringback_tone",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.isup-headers-enabled",
Usage: "When set, inbound phone calls will receive ISUP parameters via SIP headers. (Only when available and only when using TCP or TLS transport.)",
InnerField: "isup_headers_enabled",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.prack-enabled",
Usage: "Enable PRACK messages as defined in RFC3262.",
InnerField: "prack_enabled",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.shaken-stir-enabled",
Usage: "When enabled the SIP Connection will receive the Identity header with Shaken/Stir data in the SIP INVITE message of inbound calls, even when using UDP transport.",
InnerField: "shaken_stir_enabled",
},
&requestflag.InnerFlag[string]{
Name: "inbound.simultaneous-ringing",
Usage: "When enabled, allows multiple devices to ring simultaneously on incoming calls.",
InnerField: "simultaneous_ringing",
},
&requestflag.InnerFlag[bool]{
Name: "inbound.sip-compact-headers-enabled",
Usage: "Defaults to true.",
InnerField: "sip_compact_headers_enabled",
},
&requestflag.InnerFlag[string]{
Name: "inbound.sip-region",
Usage: "Selects which `sip_region` to receive inbound calls from. If null, the default region (US) will be used.",
InnerField: "sip_region",
},
&requestflag.InnerFlag[int64]{
Name: "inbound.timeout-1xx-secs",
Usage: "Time(sec) before aborting if connection is not made.",
InnerField: "timeout_1xx_secs",
},
&requestflag.InnerFlag[int64]{
Name: "inbound.timeout-2xx-secs",
Usage: "Time(sec) before aborting if call is unanswered (min: 1, max: 600).",
InnerField: "timeout_2xx_secs",
},
},
"internal-uac-settings": {
&requestflag.InnerFlag[string]{
Name: "internal-uac-settings.destination-uri",
Usage: "The SIP URI that Telnyx will call when handling an inbound request from the external peer. Do not include a `sip:` prefix. The value must be in the format `userinfo@<subdomain.>sip.telnyx.com` or `userinfo@<subdomain.>sipdev.telnyx.com`; the userinfo portion may contain only letters, digits, hyphens, and underscores.",
InnerField: "destination_uri",
},
},
"jitter-buffer": {
&requestflag.InnerFlag[bool]{
Name: "jitter-buffer.enable-jitter-buffer",
Usage: "Enables Jitter Buffer for RTP streams of SIP Trunking calls. The feature is off unless enabled.",
InnerField: "enable_jitter_buffer",
},
&requestflag.InnerFlag[int64]{
Name: "jitter-buffer.jitterbuffer-msec-max",
Usage: "The maximum jitter buffer size in milliseconds. Must be between 40 and 400. Has no effect if enable_jitter_buffer is not true.",
InnerField: "jitterbuffer_msec_max",
},
&requestflag.InnerFlag[int64]{
Name: "jitter-buffer.jitterbuffer-msec-min",
Usage: "The minimum jitter buffer size in milliseconds. Must be between 40 and 400. Has no effect if enable_jitter_buffer is not true.",
InnerField: "jitterbuffer_msec_min",
},
},
"noise-suppression-details": {
&requestflag.InnerFlag[int64]{
Name: "noise-suppression-details.attenuation-limit",
Usage: "The attenuation limit value for the selected engine. Default values vary by engine: 0 for 'denoiser', 80 for 'deep_filter_net', 'deep_filter_net_large', and all Krisp engines ('krisp_viva_tel', 'krisp_viva_tel_lite', 'krisp_viva_promodel', 'krisp_viva_ss'), 100 for 'quail_voice_focus'.",
InnerField: "attenuation_limit",
},
&requestflag.InnerFlag[string]{
Name: "noise-suppression-details.engine",
Usage: "The noise suppression engine to use. 'denoiser' is the default engine. 'deep_filter_net' and 'deep_filter_net_large' are alternative engines with different performance characteristics. Krisp engines ('krisp_viva_tel', 'krisp_viva_tel_lite', 'krisp_viva_promodel', 'krisp_viva_ss') provide advanced noise suppression capabilities. 'quail_voice_focus' provides Quail-based voice focus noise suppression.",
InnerField: "engine",
},
},
"outbound": {
&requestflag.InnerFlag[string]{
Name: "outbound.ani-override",
Usage: "Set a phone number as the ani_override value to override caller id number on outbound calls.",
InnerField: "ani_override",
},
&requestflag.InnerFlag[string]{
Name: "outbound.ani-override-type",
Usage: "Specifies when we apply your ani_override setting. Only applies when ani_override is not blank.",
InnerField: "ani_override_type",
},
&requestflag.InnerFlag[*bool]{
Name: "outbound.call-parking-enabled",
Usage: `Forces all SIP calls originated on this connection to be "parked" instead of "bridged" to the destination specified on the URI. Parked calls will return ringback to the caller and will await for a Call Control command to define which action will be taken next.`,
InnerField: "call_parking_enabled",
},
&requestflag.InnerFlag[int64]{
Name: "outbound.channel-limit",
Usage: "When set, this will limit the total number of outbound calls to phone numbers associated with this connection.",
InnerField: "channel_limit",
},
&requestflag.InnerFlag[bool]{
Name: "outbound.generate-ringback-tone",
Usage: "Generate ringback tone through 183 session progress message with early media.",
InnerField: "generate_ringback_tone",
},
&requestflag.InnerFlag[bool]{
Name: "outbound.instant-ringback-enabled",
Usage: "When set, ringback will not wait for indication before sending ringback tone to calling party.",
InnerField: "instant_ringback_enabled",
},
&requestflag.InnerFlag[string]{
Name: "outbound.localization",
Usage: "A 2-character country code specifying the country whose national dialing rules should be used. For example, if set to `US` then any US number can be dialed without preprending +1 to the number. When left blank, Telnyx will try US and GB dialing rules, in that order, by default.",
InnerField: "localization",
},
&requestflag.InnerFlag[string]{
Name: "outbound.outbound-voice-profile-id",
Usage: "Identifies the associated outbound voice profile.",
InnerField: "outbound_voice_profile_id",
},
&requestflag.InnerFlag[string]{
Name: "outbound.t38-reinvite-source",
Usage: "This setting only affects connections with Fax-type Outbound Voice Profiles. The setting dictates whether or not Telnyx sends a t.38 reinvite.<br/><br/> By default, Telnyx will send the re-invite. If set to `customer`, the caller is expected to send the t.38 reinvite.",
InnerField: "t38_reinvite_source",
},
},
"rtcp-settings": {
&requestflag.InnerFlag[bool]{
Name: "rtcp-settings.capture-enabled",
Usage: "BETA - Enable the capture and storage of RTCP messages to create QoS reports on the Telnyx Mission Control Portal.",
InnerField: "capture_enabled",
},
&requestflag.InnerFlag[string]{
Name: "rtcp-settings.port",
Usage: "RTCP port by default is rtp+1, it can also be set to rtcp-mux",
InnerField: "port",
},
&requestflag.InnerFlag[int64]{
Name: "rtcp-settings.report-frequency-secs",
Usage: "RTCP reports are sent to customers based on the frequency set. Frequency is in seconds and it can be set to values from 5 to 3000 seconds.",
InnerField: "report_frequency_secs",
},
},
})
var uacConnectionsList = requestflag.WithInnerFlags(cli.Command{
Name: "list",
Usage: "Returns a list of your UAC connections. A UAC (User Agent Client) Connection\nregisters Telnyx to your PBX — the opposite of a standard SIP trunk, where the\nPBX registers to Telnyx. Use UAC when your PBX doesn’t support outbound SIP\nregistration or you need Telnyx to maintain the registration.",
Suggest: true,
Flags: []cli.Flag{
&requestflag.Flag[map[string]any]{
Name: "filter",
Usage: "Consolidated filter parameter (deepObject style). Originally: filter[connection_name], filter[fqdn], filter[outbound_voice_profile_id], filter[outbound.outbound_voice_profile_id]",
QueryPath: "filter",
},
&requestflag.Flag[int64]{
Name: "page-number",
QueryPath: "page[number]",
},
&requestflag.Flag[int64]{
Name: "page-size",
QueryPath: "page[size]",
},
&requestflag.Flag[string]{
Name: "sort",
Usage: "Specifies the sort order for results. By default sorting direction is ascending. To have the results sorted in descending order add the <code> -</code> prefix.<br/><br/>\nThat is: <ul>\n <li>\n <code>connection_name</code>: sorts the result by the\n <code>connection_name</code> field in ascending order.\n </li>\n\n <li>\n <code>-connection_name</code>: sorts the result by the\n <code>connection_name</code> field in descending order.\n </li>\n</ul> <br/> If not given, results are sorted by <code>created_at</code> in descending order.",
Default: "created_at",
QueryPath: "sort",
},
&requestflag.Flag[int64]{
Name: "max-items",
Usage: "The maximum number of items to return (use -1 for unlimited).",
},
},
Action: handleUacConnectionsList,
HideHelpCommand: true,
}, map[string][]requestflag.HasOuterFlag{
"filter": {
&requestflag.InnerFlag[map[string]any]{
Name: "filter.connection-name",
Usage: "Filter by connection_name using nested operations",
InnerField: "connection_name",
},
&requestflag.InnerFlag[string]{
Name: "filter.fqdn",
Usage: "If present, connections with an `fqdn` that equals the given value will be returned. Matching is case-sensitive, and the full string must match.",
InnerField: "fqdn",
},
&requestflag.InnerFlag[string]{
Name: "filter.outbound-voice-profile-id",
Usage: "Identifies the associated outbound voice profile.",
InnerField: "outbound_voice_profile_id",
},
},
})
var uacConnectionsDelete = cli.Command{
Name: "delete",
Usage: "Deletes an existing UAC connection.",
Suggest: true,
Flags: []cli.Flag{
&requestflag.Flag[string]{
Name: "id",
Required: true,
PathParam: "id",
},
},
Action: handleUacConnectionsDelete,
HideHelpCommand: true,
}
func handleUacConnectionsCreate(ctx context.Context, cmd *cli.Command) error {
client := telnyx.NewClient(getDefaultRequestOptions(cmd)...)
unusedArgs := cmd.Args().Slice()
if len(unusedArgs) > 0 {
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
}
options, err := flagOptions(
cmd,
apiquery.NestedQueryFormatBrackets,
apiquery.ArrayQueryFormatComma,
ApplicationJSON,
false,
)
if err != nil {
return err
}
params := telnyx.UacConnectionNewParams{}
var res []byte
options = append(options, option.WithResponseBodyInto(&res))
_, err = client.UacConnections.New(ctx, params, options...)
if err != nil {
return err
}
obj := gjson.ParseBytes(res)
format := cmd.Root().String("format")
explicitFormat := cmd.Root().IsSet("format")
transform := cmd.Root().String("transform")
return ShowJSON(obj, ShowJSONOpts{
ExplicitFormat: explicitFormat,
Format: format,
RawOutput: cmd.Root().Bool("raw-output"),
Title: "uac-connections create",
Transform: transform,
})
}
func handleUacConnectionsRetrieve(ctx context.Context, cmd *cli.Command) error {
client := telnyx.NewClient(getDefaultRequestOptions(cmd)...)
unusedArgs := cmd.Args().Slice()
if !cmd.IsSet("id") && len(unusedArgs) > 0 {
cmd.Set("id", unusedArgs[0])
unusedArgs = unusedArgs[1:]
}
if len(unusedArgs) > 0 {
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
}
options, err := flagOptions(
cmd,
apiquery.NestedQueryFormatBrackets,
apiquery.ArrayQueryFormatComma,
EmptyBody,
false,
)
if err != nil {
return err
}
var res []byte
options = append(options, option.WithResponseBodyInto(&res))
_, err = client.UacConnections.Get(ctx, cmd.Value("id").(string), options...)
if err != nil {
return err
}
obj := gjson.ParseBytes(res)
format := cmd.Root().String("format")
explicitFormat := cmd.Root().IsSet("format")
transform := cmd.Root().String("transform")
return ShowJSON(obj, ShowJSONOpts{
ExplicitFormat: explicitFormat,
Format: format,
RawOutput: cmd.Root().Bool("raw-output"),
Title: "uac-connections retrieve",
Transform: transform,
})
}
func handleUacConnectionsUpdate(ctx context.Context, cmd *cli.Command) error {
client := telnyx.NewClient(getDefaultRequestOptions(cmd)...)
unusedArgs := cmd.Args().Slice()
if !cmd.IsSet("id") && len(unusedArgs) > 0 {
cmd.Set("id", unusedArgs[0])
unusedArgs = unusedArgs[1:]
}
if len(unusedArgs) > 0 {
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
}
options, err := flagOptions(
cmd,
apiquery.NestedQueryFormatBrackets,
apiquery.ArrayQueryFormatComma,
ApplicationJSON,
false,
)
if err != nil {
return err
}
params := telnyx.UacConnectionUpdateParams{}
var res []byte
options = append(options, option.WithResponseBodyInto(&res))
_, err = client.UacConnections.Update(
ctx,
cmd.Value("id").(string),
params,
options...,
)
if err != nil {
return err
}
obj := gjson.ParseBytes(res)
format := cmd.Root().String("format")
explicitFormat := cmd.Root().IsSet("format")
transform := cmd.Root().String("transform")
return ShowJSON(obj, ShowJSONOpts{
ExplicitFormat: explicitFormat,
Format: format,
RawOutput: cmd.Root().Bool("raw-output"),
Title: "uac-connections update",
Transform: transform,
})
}
func handleUacConnectionsList(ctx context.Context, cmd *cli.Command) error {
client := telnyx.NewClient(getDefaultRequestOptions(cmd)...)
unusedArgs := cmd.Args().Slice()
if len(unusedArgs) > 0 {
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
}
options, err := flagOptions(
cmd,
apiquery.NestedQueryFormatBrackets,
apiquery.ArrayQueryFormatComma,
EmptyBody,
false,
)
if err != nil {
return err
}
params := telnyx.UacConnectionListParams{}
format := cmd.Root().String("format")
explicitFormat := cmd.Root().IsSet("format")
transform := cmd.Root().String("transform")
if format == "raw" {
var res []byte
options = append(options, option.WithResponseBodyInto(&res))