Skip to content

Commit

Permalink
route53_info: Add snake_cased return key,values and a deprecation mes…
Browse files Browse the repository at this point in the history
…sage (#1236) (#1237)

[PR #1236/3df423ac backport][stable-3] route53_info: Add snake_cased return key,values and a deprecation message

This is a backport of PR #1236 as merged into main (3df423a).
Depends-On: ansible/ansible-zuul-jobs#1564
SUMMARY

Add snake_case return values and a deprecation message for existing CamelCase return values.
Route53_info currently returns CamelCase values, to have uniformity along all *_info modules in terms of return values, it should return snake_case values instead.
Proposed change should make addition of snake_case return values and the deprecation message provides time for users to upgrade their playbooks to avoid breaking existing playbooks due to the proposed change.

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

route53_info
ADDITIONAL INFORMATION


This PR is relation to the initiative for having updated developer guidelines for *_info modules specifically related to guidelines for deprecating return values.

Reviewed-by: Mark Chappell <None>
  • Loading branch information
patchback[bot] authored Jun 14, 2022
1 parent 9e84535 commit ed9d794
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
deprecated_features:
- route53_info - The CamelCase return values for ```HostedZones```, ```ResourceRecordSets```, and ```HealthChecks```
have been deprecated, in the future release you must use snake_case return values ```hosted_zones```, ```resource_record_sets```,
and ```health_checks``` instead respectively".
22 changes: 22 additions & 0 deletions plugins/modules/route53_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@

from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import camel_dict_to_snake_dict


# Split out paginator to allow for the backoff decorator to function
Expand Down Expand Up @@ -270,10 +271,17 @@ def list_hosted_zones():
params['DelegationSetId'] = module.params.get('delegation_set_id')

zones = _paginated_result('list_hosted_zones', **params)['HostedZones']
snaked_zones = [camel_dict_to_snake_dict(zone) for zone in zones]

module.deprecate("The 'CamelCase' return values with key 'HostedZones' and 'list' are deprecated and \
will be replaced by 'snake_case' return values with key 'hosted_zones'. \
Both case values are returned for now.",
date='2025-01-01', collection_name='community.aws')

return {
"HostedZones": zones,
"list": zones,
"hosted_zones": snaked_zones,
}


Expand Down Expand Up @@ -367,10 +375,17 @@ def list_health_checks():
)

health_checks = _paginated_result('list_health_checks', **params)['HealthChecks']
snaked_health_checks = [camel_dict_to_snake_dict(health_check) for health_check in health_checks]

module.deprecate("The 'CamelCase' return values with key 'HealthChecks' and 'list' are deprecated and \
will be replaced by 'snake_case' return values with key 'health_checks'. \
Both case values are returned for now.",
date='2025-01-01', collection_name='community.aws')

return {
"HealthChecks": health_checks,
"list": health_checks,
"health_checks": snaked_health_checks,
}


Expand Down Expand Up @@ -399,10 +414,17 @@ def record_sets_details():
)

record_sets = _paginated_result('list_resource_record_sets', **params)['ResourceRecordSets']
snaked_record_sets = [camel_dict_to_snake_dict(record_set) for record_set in record_sets]

module.deprecate("The 'CamelCase' return values with key 'ResourceRecordSets' and 'list' are deprecated and \
will be replaced by 'snake_case' return values with key 'resource_record_sets'. \
Both case values are returned for now.",
date='2025-01-01', collection_name='community.aws')

return {
"ResourceRecordSets": record_sets,
"list": record_sets,
"resource_record_sets": snaked_record_sets,
}


Expand Down

0 comments on commit ed9d794

Please sign in to comment.