66import requests
77
88from edge_addons_api .exceptions import UploadException
9- from edge_addons_api .responses import SubmitResponse
109
1110logger = logging .getLogger (__name__ )
1211
@@ -32,18 +31,28 @@ class Client:
3231 def __init__ (self , options : Options ):
3332 self .options = options
3433
35- def submit (self , file_path : str , notes : str ) -> SubmitResponse :
34+ def submit (self , file_path : str , notes : str ) -> str :
3635 if not path .exists (file_path ):
3736 raise FileNotFoundError (f"Unable to locate file at { file_path } " )
3837
3938 access_token = self ._get_access_token ()
4039 operation_id = self ._upload (file_path , access_token )
4140 self ._check_upload (operation_id , access_token )
42- publish = self ._publish (notes , access_token )
41+ return self ._publish (notes , access_token )
4342
44- return SubmitResponse ({}, publish )
43+ def fetch_publish_status (self , operation_id : str ) -> dict :
44+ access_token = self ._get_access_token ()
45+ response = requests .get (
46+ self ._publish_status_endpoint (operation_id ),
47+ headers = {
48+ "Authorization" : f"Bearer { access_token } " ,
49+ },
50+ )
4551
46- def _publish (self , notes : str , access_token : str ) -> dict :
52+ response .raise_for_status ()
53+ return response .json ()
54+
55+ def _publish (self , notes : str , access_token : str ) -> str :
4756 response = requests .post (
4857 self ._publish_endpoint (),
4958 data = {"notes" : notes },
@@ -56,7 +65,7 @@ def _publish(self, notes: str, access_token: str) -> dict:
5665
5766 logger .debug (f"Publish response: { response .content .decode ()} " )
5867
59- return response .json ()
68+ return response .headers [ "Location" ]
6069
6170 def _upload (self , file_path : str , access_token : str ) -> str :
6271
@@ -138,3 +147,6 @@ def _upload_endpoint(self) -> str:
138147
139148 def _status_endpoint (self , operation_id : str ) -> str :
140149 return f"{ self ._upload_endpoint ()} /operations/{ operation_id } "
150+
151+ def _publish_status_endpoint (self , operation_id : str ) -> str :
152+ return f"{ self ._publish_endpoint ()} /operations/{ operation_id } "
0 commit comments