capo-sagemaker-runtime-http2 0.1.0__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.
Files changed (46) hide show
  1. capo_sagemaker_runtime_http2/__init__.py +74 -0
  2. capo_sagemaker_runtime_http2/_async.py +25 -0
  3. capo_sagemaker_runtime_http2/_auth/_identity.py +16 -0
  4. capo_sagemaker_runtime_http2/_auth/_providers.py +886 -0
  5. capo_sagemaker_runtime_http2/_auth/_signers.py +88 -0
  6. capo_sagemaker_runtime_http2/_auth/_sigv4.py +434 -0
  7. capo_sagemaker_runtime_http2/_auth/_zapros_handler.py +80 -0
  8. capo_sagemaker_runtime_http2/_iter.py +113 -0
  9. capo_sagemaker_runtime_http2/_operations/amazon_sage_maker_runtime_http2/invoke_endpoint_with_bidirectional_stream.py +264 -0
  10. capo_sagemaker_runtime_http2/_pagination.py +21 -0
  11. capo_sagemaker_runtime_http2/_protocol/__init__.py +1 -0
  12. capo_sagemaker_runtime_http2/_protocol/errors.py +93 -0
  13. capo_sagemaker_runtime_http2/_protocol/eventstream.py +238 -0
  14. capo_sagemaker_runtime_http2/_protocol/serialize.py +47 -0
  15. capo_sagemaker_runtime_http2/_protocol/xml.py +33 -0
  16. capo_sagemaker_runtime_http2/_rule_engine/__init__.py +0 -0
  17. capo_sagemaker_runtime_http2/_rule_engine/_aws_partition.py +160 -0
  18. capo_sagemaker_runtime_http2/_rule_engine/_endpoint_rule_set.py +560 -0
  19. capo_sagemaker_runtime_http2/_rule_engine/_endpoint_runtime.py +389 -0
  20. capo_sagemaker_runtime_http2/_services/_aws_config.py +160 -0
  21. capo_sagemaker_runtime_http2/_services/_pipeline.py +198 -0
  22. capo_sagemaker_runtime_http2/_services/async_sage_maker_runtime_http2.py +204 -0
  23. capo_sagemaker_runtime_http2/_services/sage_maker_runtime_http2.py +203 -0
  24. capo_sagemaker_runtime_http2/errors/__init__.py +31 -0
  25. capo_sagemaker_runtime_http2/errors/_base.py +94 -0
  26. capo_sagemaker_runtime_http2/errors/input_validation_error.py +53 -0
  27. capo_sagemaker_runtime_http2/errors/internal_server_error.py +51 -0
  28. capo_sagemaker_runtime_http2/errors/internal_stream_failure.py +61 -0
  29. capo_sagemaker_runtime_http2/errors/model_error.py +69 -0
  30. capo_sagemaker_runtime_http2/errors/model_stream_error.py +65 -0
  31. capo_sagemaker_runtime_http2/errors/service_unavailable_error.py +53 -0
  32. capo_sagemaker_runtime_http2/py.typed +0 -0
  33. capo_sagemaker_runtime_http2/types/_prelude/blob.py +12 -0
  34. capo_sagemaker_runtime_http2/types/_prelude/timestamp.py +17 -0
  35. capo_sagemaker_runtime_http2/types/invoke_endpoint_with_bidirectional_stream_input.py +21 -0
  36. capo_sagemaker_runtime_http2/types/invoke_endpoint_with_bidirectional_stream_output.py +15 -0
  37. capo_sagemaker_runtime_http2/types/request_payload_part.py +62 -0
  38. capo_sagemaker_runtime_http2/types/request_stream_event.py +52 -0
  39. capo_sagemaker_runtime_http2/types/response_payload_part.py +62 -0
  40. capo_sagemaker_runtime_http2/types/response_stream_event.py +100 -0
  41. capo_sagemaker_runtime_http2/types/sensitive_blob.py +15 -0
  42. capo_sagemaker_runtime_http2-0.1.0.dist-info/METADATA +108 -0
  43. capo_sagemaker_runtime_http2-0.1.0.dist-info/RECORD +46 -0
  44. capo_sagemaker_runtime_http2-0.1.0.dist-info/WHEEL +5 -0
  45. capo_sagemaker_runtime_http2-0.1.0.dist-info/licenses/LICENSE +21 -0
  46. capo_sagemaker_runtime_http2-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,560 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from ._aws_partition import aws_partition
6
+ from ._endpoint_runtime import (
7
+ Endpoint,
8
+ EndpointError,
9
+ get_attr,
10
+ interpolate,
11
+ string_equals,
12
+ )
13
+
14
+
15
+ class EndpointParams:
16
+ def __init__(
17
+ self,
18
+ *,
19
+ UseDualStack: bool | None = None,
20
+ UseFIPS: bool | None = None,
21
+ Endpoint: str | None = None,
22
+ Region: str | None = None,
23
+ ):
24
+ self.UseDualStack = UseDualStack if UseDualStack is not None else False
25
+ self.UseFIPS = UseFIPS if UseFIPS is not None else False
26
+ self.Endpoint = Endpoint if Endpoint is not None else None
27
+ self.Region = Region if Region is not None else None
28
+
29
+
30
+ def resolve(p: EndpointParams) -> Endpoint: # type: ignore
31
+ """Resolve endpoint from parameters using generated ruleset."""
32
+ _locals: dict[str, Any] = {}
33
+ if p.Endpoint is not None:
34
+ if p.UseFIPS is True:
35
+ raise EndpointError(
36
+ interpolate(
37
+ "Invalid Configuration: FIPS and custom endpoint are not supported",
38
+ p,
39
+ _locals,
40
+ )
41
+ )
42
+ if p.UseDualStack is True:
43
+ raise EndpointError(
44
+ interpolate(
45
+ "Invalid Configuration: Dualstack and custom endpoint are not supported",
46
+ p,
47
+ _locals,
48
+ )
49
+ )
50
+ return Endpoint(url=p.Endpoint, properties={}, headers={})
51
+ _locals: dict[str, Any] = {}
52
+ if p.Region is not None:
53
+ _locals["PartitionResult"] = aws_partition(p.Region)
54
+ if _locals["PartitionResult"] is not None:
55
+ if string_equals(
56
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
57
+ interpolate("aws", p, _locals),
58
+ ):
59
+ if p.UseFIPS is False:
60
+ if p.UseDualStack is False:
61
+ return Endpoint(
62
+ url=interpolate(
63
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
64
+ p,
65
+ _locals,
66
+ ),
67
+ properties={},
68
+ headers={},
69
+ )
70
+ if string_equals(
71
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
72
+ interpolate("aws", p, _locals),
73
+ ):
74
+ if p.UseFIPS is False:
75
+ if p.UseDualStack is True:
76
+ return Endpoint(
77
+ url=interpolate(
78
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
79
+ p,
80
+ _locals,
81
+ ),
82
+ properties={},
83
+ headers={},
84
+ )
85
+ if string_equals(
86
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
87
+ interpolate("aws", p, _locals),
88
+ ):
89
+ if p.UseFIPS is True:
90
+ if p.UseDualStack is False:
91
+ return Endpoint(
92
+ url=interpolate(
93
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
94
+ p,
95
+ _locals,
96
+ ),
97
+ properties={},
98
+ headers={},
99
+ )
100
+ if string_equals(
101
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
102
+ interpolate("aws", p, _locals),
103
+ ):
104
+ if p.UseFIPS is True:
105
+ if p.UseDualStack is True:
106
+ return Endpoint(
107
+ url=interpolate(
108
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
109
+ p,
110
+ _locals,
111
+ ),
112
+ properties={},
113
+ headers={},
114
+ )
115
+ if string_equals(
116
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
117
+ interpolate("aws-cn", p, _locals),
118
+ ):
119
+ if p.UseFIPS is False:
120
+ if p.UseDualStack is False:
121
+ return Endpoint(
122
+ url=interpolate(
123
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
124
+ p,
125
+ _locals,
126
+ ),
127
+ properties={},
128
+ headers={},
129
+ )
130
+ if string_equals(
131
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
132
+ interpolate("aws-cn", p, _locals),
133
+ ):
134
+ if p.UseFIPS is False:
135
+ if p.UseDualStack is True:
136
+ return Endpoint(
137
+ url=interpolate(
138
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
139
+ p,
140
+ _locals,
141
+ ),
142
+ properties={},
143
+ headers={},
144
+ )
145
+ if string_equals(
146
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
147
+ interpolate("aws-cn", p, _locals),
148
+ ):
149
+ if p.UseFIPS is True:
150
+ if p.UseDualStack is False:
151
+ return Endpoint(
152
+ url=interpolate(
153
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
154
+ p,
155
+ _locals,
156
+ ),
157
+ properties={},
158
+ headers={},
159
+ )
160
+ if string_equals(
161
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
162
+ interpolate("aws-cn", p, _locals),
163
+ ):
164
+ if p.UseFIPS is True:
165
+ if p.UseDualStack is True:
166
+ return Endpoint(
167
+ url=interpolate(
168
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
169
+ p,
170
+ _locals,
171
+ ),
172
+ properties={},
173
+ headers={},
174
+ )
175
+ if string_equals(
176
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
177
+ interpolate("aws-us-gov", p, _locals),
178
+ ):
179
+ if p.UseFIPS is False:
180
+ if p.UseDualStack is False:
181
+ return Endpoint(
182
+ url=interpolate(
183
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
184
+ p,
185
+ _locals,
186
+ ),
187
+ properties={},
188
+ headers={},
189
+ )
190
+ if string_equals(
191
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
192
+ interpolate("aws-us-gov", p, _locals),
193
+ ):
194
+ if p.UseFIPS is False:
195
+ if p.UseDualStack is True:
196
+ return Endpoint(
197
+ url=interpolate(
198
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
199
+ p,
200
+ _locals,
201
+ ),
202
+ properties={},
203
+ headers={},
204
+ )
205
+ if string_equals(
206
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
207
+ interpolate("aws-us-gov", p, _locals),
208
+ ):
209
+ if p.UseFIPS is True:
210
+ if p.UseDualStack is False:
211
+ return Endpoint(
212
+ url=interpolate(
213
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
214
+ p,
215
+ _locals,
216
+ ),
217
+ properties={},
218
+ headers={},
219
+ )
220
+ if string_equals(
221
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
222
+ interpolate("aws-us-gov", p, _locals),
223
+ ):
224
+ if p.UseFIPS is True:
225
+ if p.UseDualStack is True:
226
+ return Endpoint(
227
+ url=interpolate(
228
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
229
+ p,
230
+ _locals,
231
+ ),
232
+ properties={},
233
+ headers={},
234
+ )
235
+ if string_equals(
236
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
237
+ interpolate("aws-iso", p, _locals),
238
+ ):
239
+ if p.UseFIPS is False:
240
+ if p.UseDualStack is False:
241
+ return Endpoint(
242
+ url=interpolate(
243
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
244
+ p,
245
+ _locals,
246
+ ),
247
+ properties={},
248
+ headers={},
249
+ )
250
+ if string_equals(
251
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
252
+ interpolate("aws-iso", p, _locals),
253
+ ):
254
+ if p.UseFIPS is False:
255
+ if p.UseDualStack is True:
256
+ return Endpoint(
257
+ url=interpolate(
258
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
259
+ p,
260
+ _locals,
261
+ ),
262
+ properties={},
263
+ headers={},
264
+ )
265
+ if string_equals(
266
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
267
+ interpolate("aws-iso", p, _locals),
268
+ ):
269
+ if p.UseFIPS is True:
270
+ if p.UseDualStack is False:
271
+ return Endpoint(
272
+ url=interpolate(
273
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
274
+ p,
275
+ _locals,
276
+ ),
277
+ properties={},
278
+ headers={},
279
+ )
280
+ if string_equals(
281
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
282
+ interpolate("aws-iso", p, _locals),
283
+ ):
284
+ if p.UseFIPS is True:
285
+ if p.UseDualStack is True:
286
+ return Endpoint(
287
+ url=interpolate(
288
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
289
+ p,
290
+ _locals,
291
+ ),
292
+ properties={},
293
+ headers={},
294
+ )
295
+ if string_equals(
296
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
297
+ interpolate("aws-iso-b", p, _locals),
298
+ ):
299
+ if p.UseFIPS is False:
300
+ if p.UseDualStack is False:
301
+ return Endpoint(
302
+ url=interpolate(
303
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
304
+ p,
305
+ _locals,
306
+ ),
307
+ properties={},
308
+ headers={},
309
+ )
310
+ if string_equals(
311
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
312
+ interpolate("aws-iso-b", p, _locals),
313
+ ):
314
+ if p.UseFIPS is False:
315
+ if p.UseDualStack is True:
316
+ return Endpoint(
317
+ url=interpolate(
318
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
319
+ p,
320
+ _locals,
321
+ ),
322
+ properties={},
323
+ headers={},
324
+ )
325
+ if string_equals(
326
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
327
+ interpolate("aws-iso-b", p, _locals),
328
+ ):
329
+ if p.UseFIPS is True:
330
+ if p.UseDualStack is False:
331
+ return Endpoint(
332
+ url=interpolate(
333
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
334
+ p,
335
+ _locals,
336
+ ),
337
+ properties={},
338
+ headers={},
339
+ )
340
+ if string_equals(
341
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
342
+ interpolate("aws-iso-b", p, _locals),
343
+ ):
344
+ if p.UseFIPS is True:
345
+ if p.UseDualStack is True:
346
+ return Endpoint(
347
+ url=interpolate(
348
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
349
+ p,
350
+ _locals,
351
+ ),
352
+ properties={},
353
+ headers={},
354
+ )
355
+ if string_equals(
356
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
357
+ interpolate("aws-iso-f", p, _locals),
358
+ ):
359
+ if p.UseFIPS is False:
360
+ if p.UseDualStack is False:
361
+ return Endpoint(
362
+ url=interpolate(
363
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
364
+ p,
365
+ _locals,
366
+ ),
367
+ properties={},
368
+ headers={},
369
+ )
370
+ if string_equals(
371
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
372
+ interpolate("aws-iso-f", p, _locals),
373
+ ):
374
+ if p.UseFIPS is False:
375
+ if p.UseDualStack is True:
376
+ return Endpoint(
377
+ url=interpolate(
378
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
379
+ p,
380
+ _locals,
381
+ ),
382
+ properties={},
383
+ headers={},
384
+ )
385
+ if string_equals(
386
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
387
+ interpolate("aws-iso-f", p, _locals),
388
+ ):
389
+ if p.UseFIPS is True:
390
+ if p.UseDualStack is False:
391
+ return Endpoint(
392
+ url=interpolate(
393
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
394
+ p,
395
+ _locals,
396
+ ),
397
+ properties={},
398
+ headers={},
399
+ )
400
+ if string_equals(
401
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
402
+ interpolate("aws-iso-f", p, _locals),
403
+ ):
404
+ if p.UseFIPS is True:
405
+ if p.UseDualStack is True:
406
+ return Endpoint(
407
+ url=interpolate(
408
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
409
+ p,
410
+ _locals,
411
+ ),
412
+ properties={},
413
+ headers={},
414
+ )
415
+ if string_equals(
416
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
417
+ interpolate("aws-eusc", p, _locals),
418
+ ):
419
+ if p.UseFIPS is False:
420
+ if p.UseDualStack is False:
421
+ return Endpoint(
422
+ url=interpolate(
423
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
424
+ p,
425
+ _locals,
426
+ ),
427
+ properties={},
428
+ headers={},
429
+ )
430
+ if string_equals(
431
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
432
+ interpolate("aws-eusc", p, _locals),
433
+ ):
434
+ if p.UseFIPS is False:
435
+ if p.UseDualStack is True:
436
+ return Endpoint(
437
+ url=interpolate(
438
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
439
+ p,
440
+ _locals,
441
+ ),
442
+ properties={},
443
+ headers={},
444
+ )
445
+ if string_equals(
446
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
447
+ interpolate("aws-eusc", p, _locals),
448
+ ):
449
+ if p.UseFIPS is True:
450
+ if p.UseDualStack is False:
451
+ return Endpoint(
452
+ url=interpolate(
453
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dnsSuffix}:8443",
454
+ p,
455
+ _locals,
456
+ ),
457
+ properties={},
458
+ headers={},
459
+ )
460
+ if string_equals(
461
+ get_attr(_locals["PartitionResult"], interpolate("name", p, _locals)),
462
+ interpolate("aws-eusc", p, _locals),
463
+ ):
464
+ if p.UseFIPS is True:
465
+ if p.UseDualStack is True:
466
+ return Endpoint(
467
+ url=interpolate(
468
+ "https://runtime-fips.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}:8443",
469
+ p,
470
+ _locals,
471
+ ),
472
+ properties={},
473
+ headers={},
474
+ )
475
+ if p.UseFIPS is True:
476
+ if p.UseDualStack is True:
477
+ if True is get_attr(
478
+ _locals["PartitionResult"],
479
+ interpolate("supportsFIPS", p, _locals),
480
+ ):
481
+ if True is get_attr(
482
+ _locals["PartitionResult"],
483
+ interpolate("supportsDualStack", p, _locals),
484
+ ):
485
+ return Endpoint(
486
+ url=interpolate(
487
+ "https://runtime.sagemaker-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",
488
+ p,
489
+ _locals,
490
+ ),
491
+ properties={},
492
+ headers={},
493
+ )
494
+ raise EndpointError(
495
+ interpolate(
496
+ "FIPS and DualStack are enabled, but this partition does not support one or both",
497
+ p,
498
+ _locals,
499
+ )
500
+ )
501
+ if p.UseFIPS is True:
502
+ if p.UseDualStack is False:
503
+ if (
504
+ get_attr(
505
+ _locals["PartitionResult"],
506
+ interpolate("supportsFIPS", p, _locals),
507
+ )
508
+ is True
509
+ ):
510
+ return Endpoint(
511
+ url=interpolate(
512
+ "https://runtime.sagemaker-fips.{Region}.{PartitionResult#dnsSuffix}",
513
+ p,
514
+ _locals,
515
+ ),
516
+ properties={},
517
+ headers={},
518
+ )
519
+ raise EndpointError(
520
+ interpolate(
521
+ "FIPS is enabled but this partition does not support FIPS",
522
+ p,
523
+ _locals,
524
+ )
525
+ )
526
+ if p.UseFIPS is False:
527
+ if p.UseDualStack is True:
528
+ if True is get_attr(
529
+ _locals["PartitionResult"],
530
+ interpolate("supportsDualStack", p, _locals),
531
+ ):
532
+ return Endpoint(
533
+ url=interpolate(
534
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dualStackDnsSuffix}",
535
+ p,
536
+ _locals,
537
+ ),
538
+ properties={},
539
+ headers={},
540
+ )
541
+ raise EndpointError(
542
+ interpolate(
543
+ "DualStack is enabled but this partition does not support DualStack",
544
+ p,
545
+ _locals,
546
+ )
547
+ )
548
+ return Endpoint(
549
+ url=interpolate(
550
+ "https://runtime.sagemaker.{Region}.{PartitionResult#dnsSuffix}",
551
+ p,
552
+ _locals,
553
+ ),
554
+ properties={},
555
+ headers={},
556
+ )
557
+ raise EndpointError(
558
+ interpolate("Invalid Configuration: Missing Region", p, _locals)
559
+ )
560
+ raise EndpointError("No endpoint rules matched")