Skip to content

Commit 1ee854e

Browse files
committed
feat(SipClient): add updateSipDispatchRuleFields method
1 parent 37866a6 commit 1ee854e

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

packages/livekit-server-sdk/src/SipClient.ts

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export interface CreateSipParticipantOptions {
150150
timeout?: number;
151151
}
152152

153-
export interface ListSIPDispatchRuleOptions {
153+
export interface ListSipDispatchRuleOptions {
154154
/** Pagination options. */
155155
page?: Pagination;
156156
/** Rule IDs to list. If this option is set, the response will contains rules in the same order. If any of the rules is missing, a nil item in that position will be sent in the response. */
@@ -168,7 +168,15 @@ export interface ListSipTrunkOptions {
168168
numbers?: string[];
169169
}
170170

171-
export interface SIPTrunkUpdateOptions {
171+
export interface SipDispatchRuleUpdateOptions {
172+
trunkIds?: ListUpdate;
173+
rule?: SIPDispatchRule;
174+
name?: string;
175+
metadata?: string;
176+
attributes?: { [key: string]: string };
177+
}
178+
179+
export interface SipTrunkUpdateOptions {
172180
numbers?: ListUpdate;
173181
allowedAddresses?: ListUpdate;
174182
allowedNumbers?: ListUpdate;
@@ -485,6 +493,36 @@ export class SipClient extends ServiceBase {
485493
return SIPDispatchRuleInfo.fromJson(data, { ignoreUnknownFields: true });
486494
}
487495

496+
/**
497+
* Updates specific fields of an existing SIP dispatch rule.
498+
* Only provided fields will be updated.
499+
*
500+
* @param sipDispatchRuleId - ID of the SIP dispatch rule to update
501+
* @param fields - Fields of the dispatch rule to update
502+
* @returns Updated SIP dispatch rule
503+
*/
504+
async updateSipDispatchRuleFields(
505+
sipDispatchRuleId: string,
506+
fields: SipDispatchRuleUpdateOptions = {},
507+
): Promise<SIPDispatchRuleInfo> {
508+
const req = new UpdateSIPDispatchRuleRequest({
509+
sipDispatchRuleId: sipDispatchRuleId,
510+
action: {
511+
case: 'update',
512+
value: fields,
513+
},
514+
}).toJson();
515+
516+
const data = await this.rpc.request(
517+
svc,
518+
'UpdateSIPDispatchRule',
519+
req,
520+
await this.authHeader({}, { admin: true }),
521+
);
522+
523+
return SIPDispatchRuleInfo.fromJson(data, { ignoreUnknownFields: true });
524+
}
525+
488526
/**
489527
* Updates an existing SIP inbound trunk by replacing it entirely.
490528
*
@@ -524,7 +562,7 @@ export class SipClient extends ServiceBase {
524562
*/
525563
async updateSipInboundTrunkFields(
526564
sipTrunkId: string,
527-
fields: SIPTrunkUpdateOptions,
565+
fields: SipTrunkUpdateOptions,
528566
): Promise<SIPInboundTrunkInfo> {
529567
const req = new UpdateSIPInboundTrunkRequest({
530568
sipTrunkId,
@@ -583,7 +621,7 @@ export class SipClient extends ServiceBase {
583621
*/
584622
async updateSipOutboundTrunkFields(
585623
sipTrunkId: string,
586-
fields: SIPTrunkUpdateOptions,
624+
fields: SipTrunkUpdateOptions,
587625
): Promise<SIPOutboundTrunkInfo> {
588626
const req = new UpdateSIPOutboundTrunkRequest({
589627
sipTrunkId,
@@ -610,7 +648,7 @@ export class SipClient extends ServiceBase {
610648
* @returns Response containing list of SIP dispatch rules
611649
*/
612650
async listSipDispatchRule(
613-
list: ListSIPDispatchRuleOptions = {},
651+
list: ListSipDispatchRuleOptions = {},
614652
): Promise<Array<SIPDispatchRuleInfo>> {
615653
const req = new ListSIPDispatchRuleRequest(list).toJson();
616654
const data = await this.rpc.request(

0 commit comments

Comments
 (0)