Skip to content

Commit cc3fe15

Browse files
committed
deprecation placeholder tags to connection builder functions
1 parent b7b112d commit cc3fe15

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

awsiot/mqtt_connection_builder.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@
125125
import awscrt.mqtt
126126
import urllib.parse
127127

128+
# TYPE_CHECKING is used to exclusively execute code by static analysers. Never at runtime.
129+
from typing import TYPE_CHECKING
130+
if TYPE_CHECKING:
131+
# Static analysers will always attempt to import deprecated from typing_extensions and
132+
# fall back to known interpretation of `deprecated` if it fails and appropriately handle
133+
# the `@deprecated` tags.
134+
from typing_extensions import deprecated
135+
else:
136+
try:
137+
# preferred import of deprecated
138+
from typing_extensions import deprecated
139+
except ModuleNotFoundError:
140+
try:
141+
# Python 3.12+
142+
from typing import deprecated
143+
except ImportError:
144+
# shim if both are unavailable that turn `deprecated` into a no-op
145+
def deprecated(msg=None, *, since=None):
146+
def wrapper(obj): return obj
147+
return wrapper
148+
128149

129150
def _check_required_kwargs(**kwargs):
130151
for required in ['endpoint', 'client_id']:
@@ -258,6 +279,14 @@ def _builder(
258279
)
259280

260281

282+
@deprecated(
283+
"""
284+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
285+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
286+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
287+
management. More details can be found here: <URL>
288+
""",
289+
since="9.9.9")
261290
def mtls_from_path(cert_filepath, pri_key_filepath, **kwargs) -> awscrt.mqtt.Connection:
262291
"""
263292
This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT.
@@ -276,6 +305,14 @@ def mtls_from_path(cert_filepath, pri_key_filepath, **kwargs) -> awscrt.mqtt.Con
276305
return _builder(tls_ctx_options, **kwargs)
277306

278307

308+
@deprecated(
309+
"""
310+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
311+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
312+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
313+
management. More details can be found here: <URL>
314+
""",
315+
since="9.9.9")
279316
def mtls_from_bytes(cert_bytes, pri_key_bytes, **kwargs) -> awscrt.mqtt.Connection:
280317
"""
281318
This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT.
@@ -294,6 +331,14 @@ def mtls_from_bytes(cert_bytes, pri_key_bytes, **kwargs) -> awscrt.mqtt.Connecti
294331
return _builder(tls_ctx_options, **kwargs)
295332

296333

334+
@deprecated(
335+
"""
336+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
337+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
338+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
339+
management. More details can be found here: <URL>
340+
""",
341+
since="9.9.9")
297342
def mtls_with_pkcs11(*,
298343
pkcs11_lib: awscrt.io.Pkcs11Lib,
299344
user_pin: str,
@@ -350,6 +395,15 @@ def mtls_with_pkcs11(*,
350395

351396
return _builder(tls_ctx_options, **kwargs)
352397

398+
399+
@deprecated(
400+
"""
401+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
402+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
403+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
404+
management. More details can be found here: <URL>
405+
""",
406+
since="9.9.9")
353407
def mtls_with_pkcs12(*,
354408
pkcs12_filepath: str,
355409
pkcs12_password: str,
@@ -376,6 +430,14 @@ def mtls_with_pkcs12(*,
376430
return _builder(tls_ctx_options, **kwargs)
377431

378432

433+
@deprecated(
434+
"""
435+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
436+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
437+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
438+
management. More details can be found here: <URL>
439+
""",
440+
since="9.9.9")
379441
def mtls_with_windows_cert_store_path(*,
380442
cert_store_path: str,
381443
**kwargs) -> awscrt.mqtt.Connection:
@@ -400,6 +462,14 @@ def mtls_with_windows_cert_store_path(*,
400462
return _builder(tls_ctx_options, **kwargs)
401463

402464

465+
@deprecated(
466+
"""
467+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
468+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
469+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
470+
management. More details can be found here: <URL>
471+
""",
472+
since="9.9.9")
403473
def websockets_with_default_aws_signing(
404474
region,
405475
credentials_provider,
@@ -444,6 +514,14 @@ def _sign_websocket_handshake_request(transform_args, **kwargs):
444514
return websockets_with_custom_handshake(_sign_websocket_handshake_request, websocket_proxy_options, **kwargs)
445515

446516

517+
@deprecated(
518+
"""
519+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
520+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
521+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
522+
management. More details can be found here: <URL>
523+
""",
524+
since="9.9.9")
447525
def websockets_with_custom_handshake(
448526
websocket_handshake_transform,
449527
websocket_proxy_options=None,
@@ -498,6 +576,14 @@ def _add_to_username_parameter(input_string, parameter_value, parameter_pretext)
498576
return return_string + parameter_pretext + parameter_value
499577

500578

579+
@deprecated(
580+
"""
581+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
582+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
583+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
584+
management. More details can be found here: <URL>
585+
""",
586+
since="9.9.9")
501587
def direct_with_custom_authorizer(
502588
auth_username=None,
503589
auth_authorizer_name=None,
@@ -552,6 +638,15 @@ def direct_with_custom_authorizer(
552638
use_websockets=False,
553639
**kwargs)
554640

641+
642+
@deprecated(
643+
"""
644+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
645+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
646+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
647+
management. More details can be found here: <URL>
648+
""",
649+
since="9.9.9")
555650
def websockets_with_custom_authorizer(
556651
region=None,
557652
credentials_provider=None,
@@ -615,6 +710,14 @@ def websockets_with_custom_authorizer(
615710
**kwargs)
616711

617712

713+
@deprecated(
714+
"""
715+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
716+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
717+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
718+
management. More details can be found here: <URL>
719+
""",
720+
since="9.9.9")
618721
def _with_custom_authorizer(auth_username=None,
619722
auth_authorizer_name=None,
620723
auth_authorizer_signature=None,
@@ -675,6 +778,14 @@ def _sign_websocket_handshake_request(transform_args, **kwargs):
675778
**kwargs)
676779

677780

781+
@deprecated(
782+
"""
783+
Deprecated tag: Please use MQTT5 Client for new code. There are no current plans to
784+
fully deprecate the MQTT 3.1.1 client but it is highly recommended customers migrate
785+
to the MQTT5 Client to have access to a more robust feature set, clearer error handling, and lifetime
786+
management. More details can be found here: <URL>
787+
""",
788+
since="9.9.9")
678789
def new_default_builder(**kwargs) -> awscrt.mqtt.Connection:
679790
"""
680791
This builder creates an :class:`awscrt.mqtt.Connection`, without any configuration besides the default TLS context options.

0 commit comments

Comments
 (0)