Skip to content

Commit f2e5070

Browse files
CopilotOhYee
andcommitted
Add auth() calls to post_file and get_file methods
Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
1 parent 38bd9a2 commit f2e5070

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

agentrun/utils/__data_api_async_template.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,9 @@ async def post_file_async(
604604
url = self.with_path(path, query=query)
605605
req_headers = self.config.get_headers()
606606
req_headers.update(headers or {})
607+
# Apply authentication (may modify URL, headers, and query)
608+
cfg = Config.with_configs(self.config, config)
609+
url, req_headers, query = self.auth(url, req_headers, query, config=cfg)
607610

608611
try:
609612
with open(local_file_path, "rb") as f:
@@ -654,6 +657,9 @@ async def get_file_async(
654657
url = self.with_path(path, query=query)
655658
req_headers = self.config.get_headers()
656659
req_headers.update(headers or {})
660+
# Apply authentication (may modify URL, headers, and query)
661+
cfg = Config.with_configs(self.config, config)
662+
url, req_headers, query = self.auth(url, req_headers, query, config=cfg)
657663

658664
try:
659665
async with httpx.AsyncClient(

agentrun/utils/data_api.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,9 @@ def _make_request(
447447
)
448448

449449
try:
450-
with httpx.Client(timeout=self.config.get_timeout()) as client:
450+
with httpx.Client(
451+
timeout=self.config.get_timeout()
452+
) as client:
451453
response = client.request(
452454
method,
453455
url,
@@ -856,6 +858,9 @@ async def post_file_async(
856858
url = self.with_path(path, query=query)
857859
req_headers = self.config.get_headers()
858860
req_headers.update(headers or {})
861+
# Apply authentication (may modify URL, headers, and query)
862+
cfg = Config.with_configs(self.config, config)
863+
url, req_headers, query = self.auth(url, req_headers, query, config=cfg)
859864

860865
try:
861866
with open(local_file_path, "rb") as f:
@@ -915,6 +920,9 @@ def post_file(
915920
url = self.with_path(path, query=query)
916921
req_headers = self.config.get_headers()
917922
req_headers.update(headers or {})
923+
# Apply authentication (may modify URL, headers, and query)
924+
cfg = Config.with_configs(self.config, config)
925+
url, req_headers, query = self.auth(url, req_headers, query, config=cfg)
918926

919927
try:
920928
with open(local_file_path, "rb") as f:
@@ -923,7 +931,9 @@ def post_file(
923931
data = form_data or {}
924932
data["path"] = target_file_path
925933

926-
with httpx.Client(timeout=self.config.get_timeout()) as client:
934+
with httpx.Client(
935+
timeout=self.config.get_timeout()
936+
) as client:
927937
response = client.post(
928938
url, files=files, data=data, headers=req_headers
929939
)
@@ -963,6 +973,9 @@ async def get_file_async(
963973
url = self.with_path(path, query=query)
964974
req_headers = self.config.get_headers()
965975
req_headers.update(headers or {})
976+
# Apply authentication (may modify URL, headers, and query)
977+
cfg = Config.with_configs(self.config, config)
978+
url, req_headers, query = self.auth(url, req_headers, query, config=cfg)
966979

967980
try:
968981
async with httpx.AsyncClient(
@@ -1009,9 +1022,14 @@ def get_file(
10091022
url = self.with_path(path, query=query)
10101023
req_headers = self.config.get_headers()
10111024
req_headers.update(headers or {})
1025+
# Apply authentication (may modify URL, headers, and query)
1026+
cfg = Config.with_configs(self.config, config)
1027+
url, req_headers, query = self.auth(url, req_headers, query, config=cfg)
10121028

10131029
try:
1014-
with httpx.Client(timeout=self.config.get_timeout()) as client:
1030+
with httpx.Client(
1031+
timeout=self.config.get_timeout()
1032+
) as client:
10151033
response = client.get(url, headers=req_headers)
10161034
response.raise_for_status()
10171035

@@ -1107,7 +1125,9 @@ def get_video(
11071125
url, req_headers, query = self.auth(url, req_headers, query, config=cfg)
11081126

11091127
try:
1110-
with httpx.Client(timeout=self.config.get_timeout()) as client:
1128+
with httpx.Client(
1129+
timeout=self.config.get_timeout()
1130+
) as client:
11111131
response = client.get(url, headers=req_headers)
11121132
response.raise_for_status()
11131133

0 commit comments

Comments
 (0)