6
6
import requests
7
7
8
8
from edge_addons_api .exceptions import UploadException
9
- from edge_addons_api .responses import SubmitResponse
10
9
11
10
logger = logging .getLogger (__name__ )
12
11
@@ -32,18 +31,28 @@ class Client:
32
31
def __init__ (self , options : Options ):
33
32
self .options = options
34
33
35
- def submit (self , file_path : str , notes : str ) -> SubmitResponse :
34
+ def submit (self , file_path : str , notes : str ) -> str :
36
35
if not path .exists (file_path ):
37
36
raise FileNotFoundError (f"Unable to locate file at { file_path } " )
38
37
39
38
access_token = self ._get_access_token ()
40
39
operation_id = self ._upload (file_path , access_token )
41
40
self ._check_upload (operation_id , access_token )
42
- publish = self ._publish (notes , access_token )
41
+ return self ._publish (notes , access_token )
43
42
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
+ )
45
51
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 :
47
56
response = requests .post (
48
57
self ._publish_endpoint (),
49
58
data = {"notes" : notes },
@@ -56,7 +65,7 @@ def _publish(self, notes: str, access_token: str) -> dict:
56
65
57
66
logger .debug (f"Publish response: { response .content .decode ()} " )
58
67
59
- return response .json ()
68
+ return response .headers [ "Location" ]
60
69
61
70
def _upload (self , file_path : str , access_token : str ) -> str :
62
71
@@ -138,3 +147,6 @@ def _upload_endpoint(self) -> str:
138
147
139
148
def _status_endpoint (self , operation_id : str ) -> str :
140
149
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