diff --git a/autocomplete/fish_autocomplete b/autocomplete/fish_autocomplete index abab0de0e..26cc99c2e 100644 --- a/autocomplete/fish_autocomplete +++ b/autocomplete/fish_autocomplete @@ -632,9 +632,11 @@ complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcomman complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'create' -d 'Create an inbound SIP Trunk' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l name -r -d 'Sets a new name for the trunk' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l numbers -r -d 'Sets a list of numbers for the trunk' -complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l media-enc -r -d 'Sets media encryption for outbound call' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l auth-user -r -d 'Set username for authentication' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l auth-pass -r -d 'Set password for authentication' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l media-enc -r -d 'Sets media encryption for outbound call' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create' -f -l help -s h -d 'show help' complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from create; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command' complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'update' -d 'Update an inbound SIP Trunk' @@ -643,6 +645,9 @@ complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_f complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l numbers -r -d 'Sets a new list of numbers for the trunk' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l auth-user -r -d 'Set username for authentication' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l auth-pass -r -d 'Set password for authentication' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l media-enc -r -d 'Sets media encryption for outbound call' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update' -f -l help -s h -d 'show help' complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command' complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from inbound in inbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'delete' -d 'Delete a SIP Trunk' @@ -660,10 +665,12 @@ complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_f complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l address -r -d 'Sets a destination address for the trunk' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l transport -r -d 'Sets a transport for the trunk' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l destination-country -r -d 'Sets a destination country for the trunk as ISO 3166-1 alpha-2 (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)' -complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l media-enc -r -d 'Sets media encryption for outbound call' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l numbers -r -d 'Sets a list of numbers for the trunk' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l auth-user -r -d 'Set username for authentication' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l auth-pass -r -d 'Set password for authentication' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l media-enc -r -d 'Sets media encryption for outbound call' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create' -f -l help -s h -d 'show help' complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from create; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command' complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'update' -d 'Update an outbound SIP Trunk' @@ -675,6 +682,9 @@ complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_f complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l numbers -r -d 'Sets a new list of numbers for the trunk' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l auth-user -r -d 'Set username for authentication' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l auth-pass -r -d 'Set password for authentication' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l media-enc -r -d 'Sets media encryption for outbound call' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update' -f -l help -s h -d 'show help' complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and __fish_seen_subcommand_from update; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command' complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from outbound out outbound-trunk; and not __fish_seen_subcommand_from list create update delete help h' -a 'delete' -d 'Delete SIP Trunk' @@ -703,6 +713,9 @@ complete -x -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcomman complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l id -r -d 'ID for the rule to update' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l name -r -d 'Sets a new name for the rule' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l trunks -r -d 'Sets a new list of trunk IDs' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l media-enc -r -d 'Sets media encryption for outbound call' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l no-default-codecs -d 'Disables a builtin list of default SIP codecs' +complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l codecs -r -d 'Sets a list of SIP codecs for outbound call' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l help -s h -d 'show help' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l direct -r -d 'Sets a direct dispatch to a specified room' complete -c lk -n '__fish_seen_subcommand_from sip; and __fish_seen_subcommand_from dispatch dispatch-rule; and __fish_seen_subcommand_from update' -f -l caller -s individual -r -d 'Sets a individual caller dispatch to a new room with a specific prefix' diff --git a/cmd/lk/sip.go b/cmd/lk/sip.go index e7d8302ea..71d08241b 100644 --- a/cmd/lk/sip.go +++ b/cmd/lk/sip.go @@ -56,7 +56,7 @@ var ( Usage: "Create an inbound SIP Trunk", Action: createSIPInboundTrunk, ArgsUsage: RequestDesc[livekit.CreateSIPInboundTrunkRequest](), - Flags: []cli.Flag{ + Flags: appendSIPMediaFlags([]cli.Flag{ &cli.StringFlag{ Name: "name", Usage: "Sets a new name for the trunk", @@ -65,7 +65,6 @@ var ( Name: "numbers", Usage: "Sets a list of numbers for the trunk", }, - sipMediaEncFlag(), &cli.StringFlag{ Name: "auth-user", Usage: "Set username for authentication", @@ -74,14 +73,14 @@ var ( Name: "auth-pass", Usage: "Set password for authentication", }, - }, + }), }, { Name: "update", Usage: "Update an inbound SIP Trunk", Action: updateSIPInboundTrunk, ArgsUsage: RequestDesc[livekit.UpdateSIPInboundTrunkRequest](), - Flags: []cli.Flag{ + Flags: appendSIPMediaFlags([]cli.Flag{ &cli.StringFlag{ Name: "id", Usage: "ID for the trunk to update", @@ -102,7 +101,7 @@ var ( Name: "auth-pass", Usage: "Set password for authentication", }, - }, + }), }, { Name: "delete", @@ -128,7 +127,7 @@ var ( Usage: "Create an outbound SIP Trunk", Action: createSIPOutboundTrunk, ArgsUsage: RequestDesc[livekit.CreateSIPOutboundTrunkRequest](), - Flags: []cli.Flag{ + Flags: appendSIPMediaFlags([]cli.Flag{ &cli.StringFlag{ Name: "name", Usage: "Sets a new name for the trunk", @@ -145,7 +144,6 @@ var ( Name: "destination-country", Usage: "Sets a destination country for the trunk as ISO 3166-1 alpha-2 (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)", }, - sipMediaEncFlag(), &cli.StringSliceFlag{ Name: "numbers", Usage: "Sets a list of numbers for the trunk", @@ -158,14 +156,14 @@ var ( Name: "auth-pass", Usage: "Set password for authentication", }, - }, + }), }, { Name: "update", Usage: "Update an outbound SIP Trunk", Action: updateSIPOutboundTrunk, ArgsUsage: RequestDesc[livekit.UpdateSIPOutboundTrunkRequest](), - Flags: []cli.Flag{ + Flags: appendSIPMediaFlags([]cli.Flag{ &cli.StringFlag{ Name: "id", Usage: "ID for the trunk to update", @@ -198,7 +196,7 @@ var ( Name: "auth-pass", Usage: "Set password for authentication", }, - }, + }), }, { Name: "delete", @@ -269,7 +267,7 @@ var ( Usage: "Update a SIP Dispatch Rule", Action: updateSIPDispatchRule, ArgsUsage: RequestDesc[livekit.UpdateSIPDispatchRuleRequest](), - Flags: []cli.Flag{ + Flags: appendSIPMediaFlags([]cli.Flag{ &cli.StringFlag{ Name: "id", Usage: "ID for the rule to update", @@ -282,7 +280,7 @@ var ( Name: "trunks", Usage: "Sets a new list of trunk IDs", }, - }, + }), MutuallyExclusiveFlags: []cli.MutuallyExclusiveFlags{ { Flags: [][]cli.Flag{ @@ -484,16 +482,12 @@ func optBoolFlag(cmd *cli.Command, setName string) (bool, bool) { return cmd.Bool(setName), true } -func sipMediaEncFlag() cli.Flag { - return &cli.StringFlag{ - Name: "media-enc", - Usage: "Sets media encryption for outbound call", - } -} - func appendSIPMediaFlags(flags []cli.Flag) []cli.Flag { flags = append(flags, - sipMediaEncFlag(), + &cli.StringFlag{ + Name: "media-enc", + Usage: "Sets media encryption for outbound call", + }, &cli.BoolFlag{ Name: "no-default-codecs", Usage: "Disables a builtin list of default SIP codecs", @@ -600,6 +594,11 @@ func createSIPInboundTrunk(ctx context.Context, cmd *cli.Command) error { if val, ok := listSetFlag(cmd, "numbers"); ok { p.Numbers = val } + if m, err := parseSIPMediaConfig(cmd); err == nil { + p.Media = m + } else if err != nil { + return err + } if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil { p.MediaEncryption = *enc } else if err != nil { @@ -663,6 +662,16 @@ func updateSIPInboundTrunk(ctx context.Context, cmd *cli.Command) error { if val := cmd.String("auth-pass"); val != "" { req.AuthPassword = &val } + if m, err := parseSIPMediaConfig(cmd); err == nil { + req.Media = m + } else if err != nil { + return err + } + if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil { + req.MediaEncryption = enc + } else if err != nil { + return err + } req.Numbers = listUpdateFlag(cmd, "numbers") info, err := cli.UpdateSIPInboundTrunk(ctx, &livekit.UpdateSIPInboundTrunkRequest{ SipTrunkId: id, @@ -707,6 +716,11 @@ func createSIPOutboundTrunk(ctx context.Context, cmd *cli.Command) error { if val := cmd.String("destination-country"); val != "" { p.DestinationCountry = val } + if m, err := parseSIPMediaConfig(cmd); err == nil { + p.Media = m + } else if err != nil { + return err + } if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil { p.MediaEncryption = *enc } else if err != nil { @@ -791,6 +805,16 @@ func updateSIPOutboundTrunk(ctx context.Context, cmd *cli.Command) error { if val := cmd.String("auth-pass"); val != "" { req.AuthPassword = &val } + if m, err := parseSIPMediaConfig(cmd); err == nil { + req.Media = m + } else if err != nil { + return err + } + if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil { + req.MediaEncryption = enc + } else if err != nil { + return err + } req.Numbers = listUpdateFlag(cmd, "numbers") info, err := cli.UpdateSIPOutboundTrunk(ctx, &livekit.UpdateSIPOutboundTrunkRequest{ SipTrunkId: id, @@ -1083,6 +1107,16 @@ func updateSIPDispatchRule(ctx context.Context, cmd *cli.Command) error { req.Name = &val } req.TrunkIds = listUpdateFlag(cmd, "trunks") + if m, err := parseSIPMediaConfig(cmd); err == nil { + req.Media = m + } else if err != nil { + return err + } + if enc, err := parseSIPMediaEnc(cmd); err == nil && enc != nil { + req.MediaEncryption = enc + } else if err != nil { + return err + } if val := cmd.String("direct"); val != "" { if req.Rule != nil { return fmt.Errorf("only one dispatch rule type is allowed")