cribl-control-plane 0.0.13__py3-none-any.whl → 0.0.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cribl-control-plane might be problematic. Click here for more details.

@@ -0,0 +1,765 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from cribl_control_plane import errors, models, utils
5
+ from cribl_control_plane._hooks import HookContext
6
+ from cribl_control_plane.types import OptionalNullable, UNSET
7
+ from cribl_control_plane.utils import get_security_from_env
8
+ from cribl_control_plane.utils.unmarshal_json_response import unmarshal_json_response
9
+ from typing import Any, Dict, List, Mapping, Optional, Union
10
+
11
+
12
+ class RoutesSDK(BaseSDK):
13
+ r"""Actions related to Routes"""
14
+
15
+ def list_routes(
16
+ self,
17
+ *,
18
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
19
+ server_url: Optional[str] = None,
20
+ timeout_ms: Optional[int] = None,
21
+ http_headers: Optional[Mapping[str, str]] = None,
22
+ ) -> models.ListRoutesResponse:
23
+ r"""Get a list of Routes objects
24
+
25
+ Get a list of Routes objects
26
+
27
+ :param retries: Override the default retry configuration for this method
28
+ :param server_url: Override the default server URL for this method
29
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
30
+ :param http_headers: Additional headers to set or replace on requests.
31
+ """
32
+ base_url = None
33
+ url_variables = None
34
+ if timeout_ms is None:
35
+ timeout_ms = self.sdk_configuration.timeout_ms
36
+
37
+ if server_url is not None:
38
+ base_url = server_url
39
+ else:
40
+ base_url = self._get_url(base_url, url_variables)
41
+ req = self._build_request(
42
+ method="GET",
43
+ path="/routes",
44
+ base_url=base_url,
45
+ url_variables=url_variables,
46
+ request=None,
47
+ request_body_required=False,
48
+ request_has_path_params=False,
49
+ request_has_query_params=True,
50
+ user_agent_header="user-agent",
51
+ accept_header_value="application/json",
52
+ http_headers=http_headers,
53
+ security=self.sdk_configuration.security,
54
+ timeout_ms=timeout_ms,
55
+ )
56
+
57
+ if retries == UNSET:
58
+ if self.sdk_configuration.retry_config is not UNSET:
59
+ retries = self.sdk_configuration.retry_config
60
+
61
+ retry_config = None
62
+ if isinstance(retries, utils.RetryConfig):
63
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
64
+
65
+ http_res = self.do_request(
66
+ hook_ctx=HookContext(
67
+ config=self.sdk_configuration,
68
+ base_url=base_url or "",
69
+ operation_id="listRoutes",
70
+ oauth2_scopes=[],
71
+ security_source=get_security_from_env(
72
+ self.sdk_configuration.security, models.Security
73
+ ),
74
+ ),
75
+ request=req,
76
+ error_status_codes=["401", "4XX", "500", "5XX"],
77
+ retry_config=retry_config,
78
+ )
79
+
80
+ response_data: Any = None
81
+ if utils.match_response(http_res, "200", "application/json"):
82
+ return unmarshal_json_response(models.ListRoutesResponse, http_res)
83
+ if utils.match_response(http_res, "500", "application/json"):
84
+ response_data = unmarshal_json_response(errors.ErrorData, http_res)
85
+ raise errors.Error(response_data, http_res)
86
+ if utils.match_response(http_res, ["401", "4XX"], "*"):
87
+ http_res_text = utils.stream_to_text(http_res)
88
+ raise errors.APIError("API error occurred", http_res, http_res_text)
89
+ if utils.match_response(http_res, "5XX", "*"):
90
+ http_res_text = utils.stream_to_text(http_res)
91
+ raise errors.APIError("API error occurred", http_res, http_res_text)
92
+
93
+ raise errors.APIError("Unexpected response received", http_res)
94
+
95
+ async def list_routes_async(
96
+ self,
97
+ *,
98
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
99
+ server_url: Optional[str] = None,
100
+ timeout_ms: Optional[int] = None,
101
+ http_headers: Optional[Mapping[str, str]] = None,
102
+ ) -> models.ListRoutesResponse:
103
+ r"""Get a list of Routes objects
104
+
105
+ Get a list of Routes objects
106
+
107
+ :param retries: Override the default retry configuration for this method
108
+ :param server_url: Override the default server URL for this method
109
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
110
+ :param http_headers: Additional headers to set or replace on requests.
111
+ """
112
+ base_url = None
113
+ url_variables = None
114
+ if timeout_ms is None:
115
+ timeout_ms = self.sdk_configuration.timeout_ms
116
+
117
+ if server_url is not None:
118
+ base_url = server_url
119
+ else:
120
+ base_url = self._get_url(base_url, url_variables)
121
+ req = self._build_request_async(
122
+ method="GET",
123
+ path="/routes",
124
+ base_url=base_url,
125
+ url_variables=url_variables,
126
+ request=None,
127
+ request_body_required=False,
128
+ request_has_path_params=False,
129
+ request_has_query_params=True,
130
+ user_agent_header="user-agent",
131
+ accept_header_value="application/json",
132
+ http_headers=http_headers,
133
+ security=self.sdk_configuration.security,
134
+ timeout_ms=timeout_ms,
135
+ )
136
+
137
+ if retries == UNSET:
138
+ if self.sdk_configuration.retry_config is not UNSET:
139
+ retries = self.sdk_configuration.retry_config
140
+
141
+ retry_config = None
142
+ if isinstance(retries, utils.RetryConfig):
143
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
144
+
145
+ http_res = await self.do_request_async(
146
+ hook_ctx=HookContext(
147
+ config=self.sdk_configuration,
148
+ base_url=base_url or "",
149
+ operation_id="listRoutes",
150
+ oauth2_scopes=[],
151
+ security_source=get_security_from_env(
152
+ self.sdk_configuration.security, models.Security
153
+ ),
154
+ ),
155
+ request=req,
156
+ error_status_codes=["401", "4XX", "500", "5XX"],
157
+ retry_config=retry_config,
158
+ )
159
+
160
+ response_data: Any = None
161
+ if utils.match_response(http_res, "200", "application/json"):
162
+ return unmarshal_json_response(models.ListRoutesResponse, http_res)
163
+ if utils.match_response(http_res, "500", "application/json"):
164
+ response_data = unmarshal_json_response(errors.ErrorData, http_res)
165
+ raise errors.Error(response_data, http_res)
166
+ if utils.match_response(http_res, ["401", "4XX"], "*"):
167
+ http_res_text = await utils.stream_to_text_async(http_res)
168
+ raise errors.APIError("API error occurred", http_res, http_res_text)
169
+ if utils.match_response(http_res, "5XX", "*"):
170
+ http_res_text = await utils.stream_to_text_async(http_res)
171
+ raise errors.APIError("API error occurred", http_res, http_res_text)
172
+
173
+ raise errors.APIError("Unexpected response received", http_res)
174
+
175
+ def get_routes_by_id(
176
+ self,
177
+ *,
178
+ id: str,
179
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
180
+ server_url: Optional[str] = None,
181
+ timeout_ms: Optional[int] = None,
182
+ http_headers: Optional[Mapping[str, str]] = None,
183
+ ) -> models.GetRoutesByIDResponse:
184
+ r"""Get Routes by ID
185
+
186
+ Get Routes by ID
187
+
188
+ :param id: Unique ID to GET
189
+ :param retries: Override the default retry configuration for this method
190
+ :param server_url: Override the default server URL for this method
191
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
192
+ :param http_headers: Additional headers to set or replace on requests.
193
+ """
194
+ base_url = None
195
+ url_variables = None
196
+ if timeout_ms is None:
197
+ timeout_ms = self.sdk_configuration.timeout_ms
198
+
199
+ if server_url is not None:
200
+ base_url = server_url
201
+ else:
202
+ base_url = self._get_url(base_url, url_variables)
203
+
204
+ request = models.GetRoutesByIDRequest(
205
+ id=id,
206
+ )
207
+
208
+ req = self._build_request(
209
+ method="GET",
210
+ path="/routes/{id}",
211
+ base_url=base_url,
212
+ url_variables=url_variables,
213
+ request=request,
214
+ request_body_required=False,
215
+ request_has_path_params=True,
216
+ request_has_query_params=True,
217
+ user_agent_header="user-agent",
218
+ accept_header_value="application/json",
219
+ http_headers=http_headers,
220
+ security=self.sdk_configuration.security,
221
+ timeout_ms=timeout_ms,
222
+ )
223
+
224
+ if retries == UNSET:
225
+ if self.sdk_configuration.retry_config is not UNSET:
226
+ retries = self.sdk_configuration.retry_config
227
+
228
+ retry_config = None
229
+ if isinstance(retries, utils.RetryConfig):
230
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
231
+
232
+ http_res = self.do_request(
233
+ hook_ctx=HookContext(
234
+ config=self.sdk_configuration,
235
+ base_url=base_url or "",
236
+ operation_id="getRoutesById",
237
+ oauth2_scopes=[],
238
+ security_source=get_security_from_env(
239
+ self.sdk_configuration.security, models.Security
240
+ ),
241
+ ),
242
+ request=req,
243
+ error_status_codes=["401", "4XX", "500", "5XX"],
244
+ retry_config=retry_config,
245
+ )
246
+
247
+ response_data: Any = None
248
+ if utils.match_response(http_res, "200", "application/json"):
249
+ return unmarshal_json_response(models.GetRoutesByIDResponse, http_res)
250
+ if utils.match_response(http_res, "500", "application/json"):
251
+ response_data = unmarshal_json_response(errors.ErrorData, http_res)
252
+ raise errors.Error(response_data, http_res)
253
+ if utils.match_response(http_res, ["401", "4XX"], "*"):
254
+ http_res_text = utils.stream_to_text(http_res)
255
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
+ if utils.match_response(http_res, "5XX", "*"):
257
+ http_res_text = utils.stream_to_text(http_res)
258
+ raise errors.APIError("API error occurred", http_res, http_res_text)
259
+
260
+ raise errors.APIError("Unexpected response received", http_res)
261
+
262
+ async def get_routes_by_id_async(
263
+ self,
264
+ *,
265
+ id: str,
266
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
267
+ server_url: Optional[str] = None,
268
+ timeout_ms: Optional[int] = None,
269
+ http_headers: Optional[Mapping[str, str]] = None,
270
+ ) -> models.GetRoutesByIDResponse:
271
+ r"""Get Routes by ID
272
+
273
+ Get Routes by ID
274
+
275
+ :param id: Unique ID to GET
276
+ :param retries: Override the default retry configuration for this method
277
+ :param server_url: Override the default server URL for this method
278
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
279
+ :param http_headers: Additional headers to set or replace on requests.
280
+ """
281
+ base_url = None
282
+ url_variables = None
283
+ if timeout_ms is None:
284
+ timeout_ms = self.sdk_configuration.timeout_ms
285
+
286
+ if server_url is not None:
287
+ base_url = server_url
288
+ else:
289
+ base_url = self._get_url(base_url, url_variables)
290
+
291
+ request = models.GetRoutesByIDRequest(
292
+ id=id,
293
+ )
294
+
295
+ req = self._build_request_async(
296
+ method="GET",
297
+ path="/routes/{id}",
298
+ base_url=base_url,
299
+ url_variables=url_variables,
300
+ request=request,
301
+ request_body_required=False,
302
+ request_has_path_params=True,
303
+ request_has_query_params=True,
304
+ user_agent_header="user-agent",
305
+ accept_header_value="application/json",
306
+ http_headers=http_headers,
307
+ security=self.sdk_configuration.security,
308
+ timeout_ms=timeout_ms,
309
+ )
310
+
311
+ if retries == UNSET:
312
+ if self.sdk_configuration.retry_config is not UNSET:
313
+ retries = self.sdk_configuration.retry_config
314
+
315
+ retry_config = None
316
+ if isinstance(retries, utils.RetryConfig):
317
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
318
+
319
+ http_res = await self.do_request_async(
320
+ hook_ctx=HookContext(
321
+ config=self.sdk_configuration,
322
+ base_url=base_url or "",
323
+ operation_id="getRoutesById",
324
+ oauth2_scopes=[],
325
+ security_source=get_security_from_env(
326
+ self.sdk_configuration.security, models.Security
327
+ ),
328
+ ),
329
+ request=req,
330
+ error_status_codes=["401", "4XX", "500", "5XX"],
331
+ retry_config=retry_config,
332
+ )
333
+
334
+ response_data: Any = None
335
+ if utils.match_response(http_res, "200", "application/json"):
336
+ return unmarshal_json_response(models.GetRoutesByIDResponse, http_res)
337
+ if utils.match_response(http_res, "500", "application/json"):
338
+ response_data = unmarshal_json_response(errors.ErrorData, http_res)
339
+ raise errors.Error(response_data, http_res)
340
+ if utils.match_response(http_res, ["401", "4XX"], "*"):
341
+ http_res_text = await utils.stream_to_text_async(http_res)
342
+ raise errors.APIError("API error occurred", http_res, http_res_text)
343
+ if utils.match_response(http_res, "5XX", "*"):
344
+ http_res_text = await utils.stream_to_text_async(http_res)
345
+ raise errors.APIError("API error occurred", http_res, http_res_text)
346
+
347
+ raise errors.APIError("Unexpected response received", http_res)
348
+
349
+ def update_routes_by_id(
350
+ self,
351
+ *,
352
+ id_param: str,
353
+ routes: Union[
354
+ List[models.RoutesRouteInput], List[models.RoutesRouteInputTypedDict]
355
+ ],
356
+ id: Optional[str] = None,
357
+ groups: Optional[
358
+ Union[Dict[str, models.Groups], Dict[str, models.GroupsTypedDict]]
359
+ ] = None,
360
+ comments: Optional[
361
+ Union[List[models.Comment], List[models.CommentTypedDict]]
362
+ ] = None,
363
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
364
+ server_url: Optional[str] = None,
365
+ timeout_ms: Optional[int] = None,
366
+ http_headers: Optional[Mapping[str, str]] = None,
367
+ ) -> models.UpdateRoutesByIDResponse:
368
+ r"""Update Routes
369
+
370
+ Update Routes
371
+
372
+ :param id_param: Unique ID to PATCH
373
+ :param routes: Pipeline routing rules
374
+ :param id: Routes ID
375
+ :param groups:
376
+ :param comments: Comments
377
+ :param retries: Override the default retry configuration for this method
378
+ :param server_url: Override the default server URL for this method
379
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
380
+ :param http_headers: Additional headers to set or replace on requests.
381
+ """
382
+ base_url = None
383
+ url_variables = None
384
+ if timeout_ms is None:
385
+ timeout_ms = self.sdk_configuration.timeout_ms
386
+
387
+ if server_url is not None:
388
+ base_url = server_url
389
+ else:
390
+ base_url = self._get_url(base_url, url_variables)
391
+
392
+ request = models.UpdateRoutesByIDRequest(
393
+ id_param=id_param,
394
+ routes=models.RoutesInput(
395
+ id=id,
396
+ routes=utils.get_pydantic_model(routes, List[models.RoutesRouteInput]),
397
+ groups=utils.get_pydantic_model(
398
+ groups, Optional[Dict[str, models.Groups]]
399
+ ),
400
+ comments=utils.get_pydantic_model(
401
+ comments, Optional[List[models.Comment]]
402
+ ),
403
+ ),
404
+ )
405
+
406
+ req = self._build_request(
407
+ method="PATCH",
408
+ path="/routes/{id}",
409
+ base_url=base_url,
410
+ url_variables=url_variables,
411
+ request=request,
412
+ request_body_required=True,
413
+ request_has_path_params=True,
414
+ request_has_query_params=True,
415
+ user_agent_header="user-agent",
416
+ accept_header_value="application/json",
417
+ http_headers=http_headers,
418
+ security=self.sdk_configuration.security,
419
+ get_serialized_body=lambda: utils.serialize_request_body(
420
+ request.routes, False, False, "json", models.RoutesInput
421
+ ),
422
+ timeout_ms=timeout_ms,
423
+ )
424
+
425
+ if retries == UNSET:
426
+ if self.sdk_configuration.retry_config is not UNSET:
427
+ retries = self.sdk_configuration.retry_config
428
+
429
+ retry_config = None
430
+ if isinstance(retries, utils.RetryConfig):
431
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
432
+
433
+ http_res = self.do_request(
434
+ hook_ctx=HookContext(
435
+ config=self.sdk_configuration,
436
+ base_url=base_url or "",
437
+ operation_id="updateRoutesById",
438
+ oauth2_scopes=[],
439
+ security_source=get_security_from_env(
440
+ self.sdk_configuration.security, models.Security
441
+ ),
442
+ ),
443
+ request=req,
444
+ error_status_codes=["401", "4XX", "500", "5XX"],
445
+ retry_config=retry_config,
446
+ )
447
+
448
+ response_data: Any = None
449
+ if utils.match_response(http_res, "200", "application/json"):
450
+ return unmarshal_json_response(models.UpdateRoutesByIDResponse, http_res)
451
+ if utils.match_response(http_res, "500", "application/json"):
452
+ response_data = unmarshal_json_response(errors.ErrorData, http_res)
453
+ raise errors.Error(response_data, http_res)
454
+ if utils.match_response(http_res, ["401", "4XX"], "*"):
455
+ http_res_text = utils.stream_to_text(http_res)
456
+ raise errors.APIError("API error occurred", http_res, http_res_text)
457
+ if utils.match_response(http_res, "5XX", "*"):
458
+ http_res_text = utils.stream_to_text(http_res)
459
+ raise errors.APIError("API error occurred", http_res, http_res_text)
460
+
461
+ raise errors.APIError("Unexpected response received", http_res)
462
+
463
+ async def update_routes_by_id_async(
464
+ self,
465
+ *,
466
+ id_param: str,
467
+ routes: Union[
468
+ List[models.RoutesRouteInput], List[models.RoutesRouteInputTypedDict]
469
+ ],
470
+ id: Optional[str] = None,
471
+ groups: Optional[
472
+ Union[Dict[str, models.Groups], Dict[str, models.GroupsTypedDict]]
473
+ ] = None,
474
+ comments: Optional[
475
+ Union[List[models.Comment], List[models.CommentTypedDict]]
476
+ ] = None,
477
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
478
+ server_url: Optional[str] = None,
479
+ timeout_ms: Optional[int] = None,
480
+ http_headers: Optional[Mapping[str, str]] = None,
481
+ ) -> models.UpdateRoutesByIDResponse:
482
+ r"""Update Routes
483
+
484
+ Update Routes
485
+
486
+ :param id_param: Unique ID to PATCH
487
+ :param routes: Pipeline routing rules
488
+ :param id: Routes ID
489
+ :param groups:
490
+ :param comments: Comments
491
+ :param retries: Override the default retry configuration for this method
492
+ :param server_url: Override the default server URL for this method
493
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
494
+ :param http_headers: Additional headers to set or replace on requests.
495
+ """
496
+ base_url = None
497
+ url_variables = None
498
+ if timeout_ms is None:
499
+ timeout_ms = self.sdk_configuration.timeout_ms
500
+
501
+ if server_url is not None:
502
+ base_url = server_url
503
+ else:
504
+ base_url = self._get_url(base_url, url_variables)
505
+
506
+ request = models.UpdateRoutesByIDRequest(
507
+ id_param=id_param,
508
+ routes=models.RoutesInput(
509
+ id=id,
510
+ routes=utils.get_pydantic_model(routes, List[models.RoutesRouteInput]),
511
+ groups=utils.get_pydantic_model(
512
+ groups, Optional[Dict[str, models.Groups]]
513
+ ),
514
+ comments=utils.get_pydantic_model(
515
+ comments, Optional[List[models.Comment]]
516
+ ),
517
+ ),
518
+ )
519
+
520
+ req = self._build_request_async(
521
+ method="PATCH",
522
+ path="/routes/{id}",
523
+ base_url=base_url,
524
+ url_variables=url_variables,
525
+ request=request,
526
+ request_body_required=True,
527
+ request_has_path_params=True,
528
+ request_has_query_params=True,
529
+ user_agent_header="user-agent",
530
+ accept_header_value="application/json",
531
+ http_headers=http_headers,
532
+ security=self.sdk_configuration.security,
533
+ get_serialized_body=lambda: utils.serialize_request_body(
534
+ request.routes, False, False, "json", models.RoutesInput
535
+ ),
536
+ timeout_ms=timeout_ms,
537
+ )
538
+
539
+ if retries == UNSET:
540
+ if self.sdk_configuration.retry_config is not UNSET:
541
+ retries = self.sdk_configuration.retry_config
542
+
543
+ retry_config = None
544
+ if isinstance(retries, utils.RetryConfig):
545
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
546
+
547
+ http_res = await self.do_request_async(
548
+ hook_ctx=HookContext(
549
+ config=self.sdk_configuration,
550
+ base_url=base_url or "",
551
+ operation_id="updateRoutesById",
552
+ oauth2_scopes=[],
553
+ security_source=get_security_from_env(
554
+ self.sdk_configuration.security, models.Security
555
+ ),
556
+ ),
557
+ request=req,
558
+ error_status_codes=["401", "4XX", "500", "5XX"],
559
+ retry_config=retry_config,
560
+ )
561
+
562
+ response_data: Any = None
563
+ if utils.match_response(http_res, "200", "application/json"):
564
+ return unmarshal_json_response(models.UpdateRoutesByIDResponse, http_res)
565
+ if utils.match_response(http_res, "500", "application/json"):
566
+ response_data = unmarshal_json_response(errors.ErrorData, http_res)
567
+ raise errors.Error(response_data, http_res)
568
+ if utils.match_response(http_res, ["401", "4XX"], "*"):
569
+ http_res_text = await utils.stream_to_text_async(http_res)
570
+ raise errors.APIError("API error occurred", http_res, http_res_text)
571
+ if utils.match_response(http_res, "5XX", "*"):
572
+ http_res_text = await utils.stream_to_text_async(http_res)
573
+ raise errors.APIError("API error occurred", http_res, http_res_text)
574
+
575
+ raise errors.APIError("Unexpected response received", http_res)
576
+
577
+ def create_routes_append_by_id(
578
+ self,
579
+ *,
580
+ id: str,
581
+ request_body: Union[List[models.RouteConf], List[models.RouteConfTypedDict]],
582
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
583
+ server_url: Optional[str] = None,
584
+ timeout_ms: Optional[int] = None,
585
+ http_headers: Optional[Mapping[str, str]] = None,
586
+ ) -> models.CreateRoutesAppendByIDResponse:
587
+ r"""Appends routes to the end of the routing table
588
+
589
+ Appends routes to the end of the routing table
590
+
591
+ :param id: the route table to be appended to - currently default is the only supported value
592
+ :param request_body: RouteDefinitions object
593
+ :param retries: Override the default retry configuration for this method
594
+ :param server_url: Override the default server URL for this method
595
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
596
+ :param http_headers: Additional headers to set or replace on requests.
597
+ """
598
+ base_url = None
599
+ url_variables = None
600
+ if timeout_ms is None:
601
+ timeout_ms = self.sdk_configuration.timeout_ms
602
+
603
+ if server_url is not None:
604
+ base_url = server_url
605
+ else:
606
+ base_url = self._get_url(base_url, url_variables)
607
+
608
+ request = models.CreateRoutesAppendByIDRequest(
609
+ id=id,
610
+ request_body=utils.get_pydantic_model(request_body, List[models.RouteConf]),
611
+ )
612
+
613
+ req = self._build_request(
614
+ method="POST",
615
+ path="/routes/{id}/append",
616
+ base_url=base_url,
617
+ url_variables=url_variables,
618
+ request=request,
619
+ request_body_required=True,
620
+ request_has_path_params=True,
621
+ request_has_query_params=True,
622
+ user_agent_header="user-agent",
623
+ accept_header_value="application/json",
624
+ http_headers=http_headers,
625
+ security=self.sdk_configuration.security,
626
+ get_serialized_body=lambda: utils.serialize_request_body(
627
+ request.request_body, False, False, "json", List[models.RouteConf]
628
+ ),
629
+ timeout_ms=timeout_ms,
630
+ )
631
+
632
+ if retries == UNSET:
633
+ if self.sdk_configuration.retry_config is not UNSET:
634
+ retries = self.sdk_configuration.retry_config
635
+
636
+ retry_config = None
637
+ if isinstance(retries, utils.RetryConfig):
638
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
639
+
640
+ http_res = self.do_request(
641
+ hook_ctx=HookContext(
642
+ config=self.sdk_configuration,
643
+ base_url=base_url or "",
644
+ operation_id="createRoutesAppendById",
645
+ oauth2_scopes=[],
646
+ security_source=get_security_from_env(
647
+ self.sdk_configuration.security, models.Security
648
+ ),
649
+ ),
650
+ request=req,
651
+ error_status_codes=["401", "4XX", "500", "5XX"],
652
+ retry_config=retry_config,
653
+ )
654
+
655
+ response_data: Any = None
656
+ if utils.match_response(http_res, "200", "application/json"):
657
+ return unmarshal_json_response(
658
+ models.CreateRoutesAppendByIDResponse, http_res
659
+ )
660
+ if utils.match_response(http_res, "500", "application/json"):
661
+ response_data = unmarshal_json_response(errors.ErrorData, http_res)
662
+ raise errors.Error(response_data, http_res)
663
+ if utils.match_response(http_res, ["401", "4XX"], "*"):
664
+ http_res_text = utils.stream_to_text(http_res)
665
+ raise errors.APIError("API error occurred", http_res, http_res_text)
666
+ if utils.match_response(http_res, "5XX", "*"):
667
+ http_res_text = utils.stream_to_text(http_res)
668
+ raise errors.APIError("API error occurred", http_res, http_res_text)
669
+
670
+ raise errors.APIError("Unexpected response received", http_res)
671
+
672
+ async def create_routes_append_by_id_async(
673
+ self,
674
+ *,
675
+ id: str,
676
+ request_body: Union[List[models.RouteConf], List[models.RouteConfTypedDict]],
677
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
678
+ server_url: Optional[str] = None,
679
+ timeout_ms: Optional[int] = None,
680
+ http_headers: Optional[Mapping[str, str]] = None,
681
+ ) -> models.CreateRoutesAppendByIDResponse:
682
+ r"""Appends routes to the end of the routing table
683
+
684
+ Appends routes to the end of the routing table
685
+
686
+ :param id: the route table to be appended to - currently default is the only supported value
687
+ :param request_body: RouteDefinitions object
688
+ :param retries: Override the default retry configuration for this method
689
+ :param server_url: Override the default server URL for this method
690
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
691
+ :param http_headers: Additional headers to set or replace on requests.
692
+ """
693
+ base_url = None
694
+ url_variables = None
695
+ if timeout_ms is None:
696
+ timeout_ms = self.sdk_configuration.timeout_ms
697
+
698
+ if server_url is not None:
699
+ base_url = server_url
700
+ else:
701
+ base_url = self._get_url(base_url, url_variables)
702
+
703
+ request = models.CreateRoutesAppendByIDRequest(
704
+ id=id,
705
+ request_body=utils.get_pydantic_model(request_body, List[models.RouteConf]),
706
+ )
707
+
708
+ req = self._build_request_async(
709
+ method="POST",
710
+ path="/routes/{id}/append",
711
+ base_url=base_url,
712
+ url_variables=url_variables,
713
+ request=request,
714
+ request_body_required=True,
715
+ request_has_path_params=True,
716
+ request_has_query_params=True,
717
+ user_agent_header="user-agent",
718
+ accept_header_value="application/json",
719
+ http_headers=http_headers,
720
+ security=self.sdk_configuration.security,
721
+ get_serialized_body=lambda: utils.serialize_request_body(
722
+ request.request_body, False, False, "json", List[models.RouteConf]
723
+ ),
724
+ timeout_ms=timeout_ms,
725
+ )
726
+
727
+ if retries == UNSET:
728
+ if self.sdk_configuration.retry_config is not UNSET:
729
+ retries = self.sdk_configuration.retry_config
730
+
731
+ retry_config = None
732
+ if isinstance(retries, utils.RetryConfig):
733
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
734
+
735
+ http_res = await self.do_request_async(
736
+ hook_ctx=HookContext(
737
+ config=self.sdk_configuration,
738
+ base_url=base_url or "",
739
+ operation_id="createRoutesAppendById",
740
+ oauth2_scopes=[],
741
+ security_source=get_security_from_env(
742
+ self.sdk_configuration.security, models.Security
743
+ ),
744
+ ),
745
+ request=req,
746
+ error_status_codes=["401", "4XX", "500", "5XX"],
747
+ retry_config=retry_config,
748
+ )
749
+
750
+ response_data: Any = None
751
+ if utils.match_response(http_res, "200", "application/json"):
752
+ return unmarshal_json_response(
753
+ models.CreateRoutesAppendByIDResponse, http_res
754
+ )
755
+ if utils.match_response(http_res, "500", "application/json"):
756
+ response_data = unmarshal_json_response(errors.ErrorData, http_res)
757
+ raise errors.Error(response_data, http_res)
758
+ if utils.match_response(http_res, ["401", "4XX"], "*"):
759
+ http_res_text = await utils.stream_to_text_async(http_res)
760
+ raise errors.APIError("API error occurred", http_res, http_res_text)
761
+ if utils.match_response(http_res, "5XX", "*"):
762
+ http_res_text = await utils.stream_to_text_async(http_res)
763
+ raise errors.APIError("API error occurred", http_res, http_res_text)
764
+
765
+ raise errors.APIError("Unexpected response received", http_res)