diff --git a/changelogs/fragments/DEPRECATE-module_utils-urls.yml b/changelogs/fragments/DEPRECATE-module_utils-urls.yml new file mode 100644 index 00000000000..4cea0c1c43e --- /dev/null +++ b/changelogs/fragments/DEPRECATE-module_utils-urls.yml @@ -0,0 +1,2 @@ +deprecated_features: +- module_utils.url - ``ansible_collections.amazon.aws.module_utils.urls`` is believed to be unused and has been deprecated and will be removed in release 7.0.0. diff --git a/plugins/module_utils/urls.py b/plugins/module_utils/urls.py index e00f485c5d2..8011a1be9ef 100644 --- a/plugins/module_utils/urls.py +++ b/plugins/module_utils/urls.py @@ -20,12 +20,18 @@ from .ec2 import HAS_BOTO3 from .ec2 import get_aws_connection_info +import ansible.module_utils.common.warnings as ansible_warnings + def hexdigest(s): """ Returns the sha256 hexdigest of a string after encoding. """ + ansible_warnings.deprecate( + 'amazon.aws.module_utils.urls.hexdigest is unused and has been deprecated.', + version='7.0.0', collection_name='amazon.aws') + return hashlib.sha256(s.encode("utf-8")).hexdigest() @@ -36,6 +42,10 @@ def format_querystring(params=None): It's specially sorted for cannonical requests """ + ansible_warnings.deprecate( + 'amazon.aws.module_utils.urls.format_querystring is unused and has been deprecated.', + version='7.0.0', collection_name='amazon.aws') + if not params: return "" @@ -50,6 +60,10 @@ def sign(key, msg): Return digest for key applied to msg ''' + ansible_warnings.deprecate( + 'amazon.aws.module_utils.urls.sign is unused and has been deprecated.', + version='7.0.0', collection_name='amazon.aws') + return hmac.new(key, msg.encode("utf-8"), hashlib.sha256).digest() @@ -58,6 +72,10 @@ def get_signature_key(key, dateStamp, regionName, serviceName): Returns signature key for AWS resource ''' + ansible_warnings.deprecate( + 'amazon.aws.module_utils.urls.get_signature_key is unused and has been deprecated.', + version='7.0.0', collection_name='amazon.aws') + kDate = sign(("AWS4" + key).encode("utf-8"), dateStamp) kRegion = sign(kDate, regionName) kService = sign(kRegion, serviceName) @@ -70,6 +88,10 @@ def get_aws_credentials_object(module): Returns aws_access_key_id, aws_secret_access_key, session_token for a module. ''' + ansible_warnings.deprecate( + 'amazon.aws.module_utils.urls.get_aws_credentials_object is unused and has been deprecated.', + version='7.0.0', collection_name='amazon.aws') + if not HAS_BOTO3: module.fail_json("get_aws_credentials_object requires boto3") @@ -114,6 +136,10 @@ def signed_request( :returns: HTTPResponse """ + module.deprecate( + 'amazon.aws.module_utils.urls.signed_request is unused and has been deprecated.', + version='7.0.0', collection_name='amazon.aws') + if not HAS_BOTO3: module.fail_json("A sigv4 signed_request requires boto3")