2
2
3
3
from .sdkconfiguration import SDKConfiguration
4
4
from speakeasy import utils
5
- from speakeasy .models import operations , shared
5
+ from speakeasy .models import errors , operations , shared
6
6
from typing import Optional
7
7
8
8
class APIEndpoints :
@@ -37,6 +37,8 @@ def delete_api_endpoint(self, request: operations.DeleteAPIEndpointRequest) -> o
37
37
if utils .match_content_type (content_type , 'application/json' ):
38
38
out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
39
39
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 )
40
42
41
43
return res
42
44
@@ -64,10 +66,14 @@ def find_api_endpoint(self, request: operations.FindAPIEndpointRequest) -> opera
64
66
if utils .match_content_type (content_type , 'application/json' ):
65
67
out = utils .unmarshal_json (http_res .text , Optional [shared .APIEndpoint ])
66
68
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 )
67
71
else :
68
72
if utils .match_content_type (content_type , 'application/json' ):
69
73
out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
70
74
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 )
71
77
72
78
return res
73
79
@@ -95,10 +101,14 @@ def generate_open_api_spec_for_api_endpoint(self, request: operations.GenerateOp
95
101
if utils .match_content_type (content_type , 'application/json' ):
96
102
out = utils .unmarshal_json (http_res .text , Optional [shared .GenerateOpenAPISpecDiff ])
97
103
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 )
98
106
else :
99
107
if utils .match_content_type (content_type , 'application/json' ):
100
108
out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
101
109
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 )
102
112
103
113
return res
104
114
@@ -124,10 +134,14 @@ def generate_postman_collection_for_api_endpoint(self, request: operations.Gener
124
134
if http_res .status_code == 200 :
125
135
if utils .match_content_type (content_type , 'application/octet-stream' ):
126
136
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 )
127
139
else :
128
140
if utils .match_content_type (content_type , 'application/json' ):
129
141
out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
130
142
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 )
131
145
132
146
return res
133
147
@@ -152,10 +166,14 @@ def get_all_api_endpoints(self, request: operations.GetAllAPIEndpointsRequest) -
152
166
if utils .match_content_type (content_type , 'application/json' ):
153
167
out = utils .unmarshal_json (http_res .text , Optional [list [shared .APIEndpoint ]])
154
168
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 )
155
171
else :
156
172
if utils .match_content_type (content_type , 'application/json' ):
157
173
out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
158
174
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 )
159
177
160
178
return res
161
179
@@ -180,10 +198,14 @@ def get_all_for_version_api_endpoints(self, request: operations.GetAllForVersion
180
198
if utils .match_content_type (content_type , 'application/json' ):
181
199
out = utils .unmarshal_json (http_res .text , Optional [list [shared .APIEndpoint ]])
182
200
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 )
183
203
else :
184
204
if utils .match_content_type (content_type , 'application/json' ):
185
205
out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
186
206
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 )
187
209
188
210
return res
189
211
@@ -208,10 +230,14 @@ def get_api_endpoint(self, request: operations.GetAPIEndpointRequest) -> operati
208
230
if utils .match_content_type (content_type , 'application/json' ):
209
231
out = utils .unmarshal_json (http_res .text , Optional [shared .APIEndpoint ])
210
232
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 )
211
235
else :
212
236
if utils .match_content_type (content_type , 'application/json' ):
213
237
out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
214
238
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 )
215
241
216
242
return res
217
243
@@ -243,10 +269,14 @@ def upsert_api_endpoint(self, request: operations.UpsertAPIEndpointRequest) -> o
243
269
if utils .match_content_type (content_type , 'application/json' ):
244
270
out = utils .unmarshal_json (http_res .text , Optional [shared .APIEndpoint ])
245
271
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 )
246
274
else :
247
275
if utils .match_content_type (content_type , 'application/json' ):
248
276
out = utils .unmarshal_json (http_res .text , Optional [shared .Error ])
249
277
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 )
250
280
251
281
return res
252
282
0 commit comments