1414from prefect .cli .root import app , is_interactive
1515from prefect .client .cloud import get_cloud_client
1616from prefect .exceptions import ObjectNotFound
17- from prefect .settings import PREFECT_API_URL
17+ from prefect .settings import get_current_settings
1818
1919webhook_app : PrefectTyper = PrefectTyper (
2020 name = "webhook" , help = "Manage Prefect Cloud Webhooks"
@@ -49,7 +49,7 @@ async def ls():
4949 confirm_logged_in ()
5050
5151 # The /webhooks API lives inside the /accounts/{id}/workspaces/{id} routing tree
52- async with get_cloud_client (host = PREFECT_API_URL . value () ) as client :
52+ async with get_cloud_client (host = get_current_settings (). api . url ) as client :
5353 retrieved_webhooks = await client .request ("POST" , "/webhooks/filter" )
5454 display_table = _render_webhooks_into_table (retrieved_webhooks )
5555 app .console .print (display_table )
@@ -63,7 +63,7 @@ async def get(webhook_id: UUID):
6363 confirm_logged_in ()
6464
6565 # The /webhooks API lives inside the /accounts/{id}/workspaces/{id} routing tree
66- async with get_cloud_client (host = PREFECT_API_URL . value () ) as client :
66+ async with get_cloud_client (host = get_current_settings (). api . url ) as client :
6767 webhook = await client .request ("GET" , f"/webhooks/{ webhook_id } " )
6868 display_table = _render_webhooks_into_table ([webhook ])
6969 app .console .print (display_table )
@@ -94,7 +94,7 @@ async def create(
9494 confirm_logged_in ()
9595
9696 # The /webhooks API lives inside the /accounts/{id}/workspaces/{id} routing tree
97- async with get_cloud_client (host = PREFECT_API_URL . value () ) as client :
97+ async with get_cloud_client (host = get_current_settings (). api . url ) as client :
9898 response = await client .request (
9999 "POST" ,
100100 "/webhooks/" ,
@@ -122,7 +122,7 @@ async def rotate(webhook_id: UUID):
122122 return
123123
124124 # The /webhooks API lives inside the /accounts/{id}/workspaces/{id} routing tree
125- async with get_cloud_client (host = PREFECT_API_URL . value () ) as client :
125+ async with get_cloud_client (host = get_current_settings (). api . url ) as client :
126126 response = await client .request ("POST" , f"/webhooks/{ webhook_id } /rotate" )
127127 app .console .print (f"Successfully rotated webhook URL to { response ['slug' ]} " )
128128
@@ -138,7 +138,7 @@ async def toggle(
138138
139139 status_lookup = {True : "enabled" , False : "disabled" }
140140
141- async with get_cloud_client (host = PREFECT_API_URL . value () ) as client :
141+ async with get_cloud_client (host = get_current_settings (). api . url ) as client :
142142 response = await client .request ("GET" , f"/webhooks/{ webhook_id } " )
143143 current_status = response ["enabled" ]
144144 new_status = not current_status
@@ -166,7 +166,7 @@ async def update(
166166 confirm_logged_in ()
167167
168168 # The /webhooks API lives inside the /accounts/{id}/workspaces/{id} routing tree
169- async with get_cloud_client (host = PREFECT_API_URL . value () ) as client :
169+ async with get_cloud_client (host = get_current_settings (). api . url ) as client :
170170 response = await client .request ("GET" , f"/webhooks/{ webhook_id } " )
171171 update_payload = {
172172 "name" : webhook_name or response ["name" ],
@@ -192,7 +192,7 @@ async def delete(webhook_id: UUID):
192192 exit_with_error ("Deletion aborted." )
193193
194194 # The /webhooks API lives inside the /accounts/{id}/workspaces/{id} routing tree
195- async with get_cloud_client (host = PREFECT_API_URL . value () ) as client :
195+ async with get_cloud_client (host = get_current_settings (). api . url ) as client :
196196 try :
197197 await client .request ("DELETE" , f"/webhooks/{ webhook_id } " )
198198 app .console .print (f"Successfully deleted webhook { webhook_id } " )
0 commit comments