22
33from .sdkconfiguration import SDKConfiguration
44from speakeasy import utils
5- from speakeasy .models import operations , shared
5+ from speakeasy .models import errors , operations , shared
66from typing import Optional
77
88class APIEndpoints :
@@ -37,6 +37,8 @@ def delete_api_endpoint(self, request: operations.DeleteAPIEndpointRequest) -> o
3737 if utils .match_content_type (content_type , 'application/json' ):
3838 out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
3939 res .error = out
40+ else :
41+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
4042
4143 return res
4244
@@ -64,10 +66,14 @@ def find_api_endpoint(self, request: operations.FindAPIEndpointRequest) -> opera
6466 if utils .match_content_type (content_type , 'application/json' ):
6567 out = utils .unmarshal_json (http_res .text , Optional [shared .APIEndpoint ])
6668 res .api_endpoint = out
69+ else :
70+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
6771 else :
6872 if utils .match_content_type (content_type , 'application/json' ):
6973 out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
7074 res .error = out
75+ else :
76+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
7177
7278 return res
7379
@@ -95,10 +101,14 @@ def generate_open_api_spec_for_api_endpoint(self, request: operations.GenerateOp
95101 if utils .match_content_type (content_type , 'application/json' ):
96102 out = utils .unmarshal_json (http_res .text , Optional [shared .GenerateOpenAPISpecDiff ])
97103 res .generate_open_api_spec_diff = out
104+ else :
105+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
98106 else :
99107 if utils .match_content_type (content_type , 'application/json' ):
100108 out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
101109 res .error = out
110+ else :
111+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
102112
103113 return res
104114
@@ -124,10 +134,14 @@ def generate_postman_collection_for_api_endpoint(self, request: operations.Gener
124134 if http_res .status_code == 200 :
125135 if utils .match_content_type (content_type , 'application/octet-stream' ):
126136 res .postman_collection = http_res .content
137+ else :
138+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
127139 else :
128140 if utils .match_content_type (content_type , 'application/json' ):
129141 out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
130142 res .error = out
143+ else :
144+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
131145
132146 return res
133147
@@ -152,10 +166,14 @@ def get_all_api_endpoints(self, request: operations.GetAllAPIEndpointsRequest) -
152166 if utils .match_content_type (content_type , 'application/json' ):
153167 out = utils .unmarshal_json (http_res .text , Optional [list [shared .APIEndpoint ]])
154168 res .api_endpoints = out
169+ else :
170+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
155171 else :
156172 if utils .match_content_type (content_type , 'application/json' ):
157173 out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
158174 res .error = out
175+ else :
176+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
159177
160178 return res
161179
@@ -180,10 +198,14 @@ def get_all_for_version_api_endpoints(self, request: operations.GetAllForVersion
180198 if utils .match_content_type (content_type , 'application/json' ):
181199 out = utils .unmarshal_json (http_res .text , Optional [list [shared .APIEndpoint ]])
182200 res .api_endpoints = out
201+ else :
202+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
183203 else :
184204 if utils .match_content_type (content_type , 'application/json' ):
185205 out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
186206 res .error = out
207+ else :
208+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
187209
188210 return res
189211
@@ -208,10 +230,14 @@ def get_api_endpoint(self, request: operations.GetAPIEndpointRequest) -> operati
208230 if utils .match_content_type (content_type , 'application/json' ):
209231 out = utils .unmarshal_json (http_res .text , Optional [shared .APIEndpoint ])
210232 res .api_endpoint = out
233+ else :
234+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
211235 else :
212236 if utils .match_content_type (content_type , 'application/json' ):
213237 out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
214238 res .error = out
239+ else :
240+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
215241
216242 return res
217243
@@ -243,10 +269,14 @@ def upsert_api_endpoint(self, request: operations.UpsertAPIEndpointRequest) -> o
243269 if utils .match_content_type (content_type , 'application/json' ):
244270 out = utils .unmarshal_json (http_res .text , Optional [shared .APIEndpoint ])
245271 res .api_endpoint = out
272+ else :
273+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
246274 else :
247275 if utils .match_content_type (content_type , 'application/json' ):
248276 out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
249277 res .error = out
278+ else :
279+ raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
250280
251281 return res
252282
0 commit comments