Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate module_utils.urls #1146

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/DEPRECATE-module_utils-urls.yml
Original file line number Diff line number Diff line change
@@ -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.
26 changes: 26 additions & 0 deletions plugins/module_utils/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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 ""

Expand All @@ -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()


Expand All @@ -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)
Expand All @@ -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")

Expand Down Expand Up @@ -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")

Expand Down