Skip to content

Commit ecc769c

Browse files
committed
fix(examples): use credentials_and_ip instead of ip_only for trunk creation
ip_only authentication is read-only and can only be configured by DIDWW staff. The example now creates trunks with credentials_and_ip, which is settable via the API. Added docstring to IpOnlyAuthenticationMethod documenting its read-only nature.
1 parent cc146a5 commit ecc769c

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

examples/voice_out_trunks.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434
print(f" RTP Timeout: {t.rtp_timeout}")
3535
print()
3636

37-
# Create a voice out trunk with ip_only authentication
38-
print("=== Creating Voice Out Trunk (ip_only) ===")
37+
# Create a voice out trunk with credentials_and_ip authentication
38+
# Note: ip_only authentication can only be configured by DIDWW staff.
39+
print("=== Creating Voice Out Trunk (credentials_and_ip) ===")
3940
trunk = VoiceOutTrunk()
4041
trunk.name = f"My Outbound Trunk {suffix}"
41-
trunk.authentication_method = IpOnlyAuthenticationMethod(
42+
trunk.authentication_method = CredentialsAndIpAuthenticationMethod(
4243
allowed_sip_ips=["203.0.113.0/24"],
4344
tech_prefix="",
4445
)
@@ -51,11 +52,13 @@
5152
print(f" Name: {created.name}")
5253
auth = created.authentication_method
5354
print(f" Auth type: {auth.type if auth else None}")
55+
if isinstance(auth, CredentialsAndIpAuthenticationMethod):
56+
print(f" Username: {auth.username}")
5457
print(f" Status: {created.status}")
5558
print(f" External Reference: {created.external_reference_id}")
5659

57-
# Update - switch to credentials_and_ip
58-
print("\n=== Updating Voice Out Trunk (switch to credentials_and_ip) ===")
60+
# Update - change name and tech_prefix
61+
print("\n=== Updating Voice Out Trunk ===")
5962
update = VoiceOutTrunk.build(created.id)
6063
update.name = f"Updated Outbound Trunk {suffix}"
6164
update.authentication_method = CredentialsAndIpAuthenticationMethod(

src/didww/resources/authentication_method.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ def _plain(key):
4646

4747

4848
class IpOnlyAuthenticationMethod(AuthenticationMethod):
49+
"""Read-only authentication method for VoiceOutTrunk.
50+
51+
ip_only authentication can only be configured manually by DIDWW staff
52+
upon request. It cannot be set via the API on create or update.
53+
Trunks with ip_only authentication can still be read and their
54+
non-authentication attributes updated via the API.
55+
"""
4956
_type = "ip_only"
5057

5158
allowed_sip_ips = _plain("allowed_sip_ips")

0 commit comments

Comments
 (0)