Skip to content

Commit

Permalink
Cleanup headers and imports (ansible-collections#1738)
Browse files Browse the repository at this point in the history
Cleanup headers and imports

SUMMARY
Mass update of imports, docs fragments and file headers

Many of the amazon.aws module_utils and docs fragments got moved about, update community.aws to reflect this.
Consistently apply the comment headers as documented at https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html#python-shebang-utf-8-coding

ISSUE TYPE

Docs Pull Request
Feature Pull Request

COMPONENT NAME
ADDITIONAL INFORMATION
Header cleanup based upon:
https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html#python-shebang-utf-8-coding

Begin your Ansible module with #!/usr/bin/python - this “shebang” allows ansible_python_interpreter to work. Follow the shebang immediately with # -*- coding: utf-8 -*- to clarify that the file is UTF-8 encoded.

and
https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html#copyright-and-license

After the shebang and UTF-8 coding, add a copyright line with the original copyright holder and a license declaration. The license declaration should be ONLY one line, not the full GPL prefix.
...
Additions to the module (for instance, rewrites) are not permitted to add additional copyright lines other than the default copyright statement if missing:

Reviewed-by: Alina Buzachis

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@a4f20bf
  • Loading branch information
tremble authored and alinabuzachis committed Oct 24, 2024
1 parent 2097fb0 commit e8552b7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 41 deletions.
42 changes: 22 additions & 20 deletions plugins/modules/ec2_vpc_vpn.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


DOCUMENTATION = r'''
DOCUMENTATION = r"""
---
module: ec2_vpc_vpn
version_added: 1.0.0
short_description: Create, modify, and delete EC2 VPN connections
description:
- This module creates, modifies, and deletes VPN connections. Idempotence is achieved by using the filters
option or specifying the VPN connection identifier.
extends_documentation_fragment:
- amazon.aws.ec2
- amazon.aws.aws
- amazon.aws.boto3
- amazon.aws.tags
author:
- "Sloane Hertel (@s-hertel)"
options:
Expand Down Expand Up @@ -135,7 +128,12 @@
required: false
type: int
default: 15
'''
extends_documentation_fragment:
- amazon.aws.region.modules
- amazon.aws.common.modules
- amazon.aws.tags
- amazon.aws.boto3
"""

EXAMPLES = r"""
# Note: None of these examples set aws_access_key, aws_secret_key, or region.
Expand Down Expand Up @@ -293,19 +291,23 @@
vpn_connection_id: vpn-781e0e19
"""

from ansible.module_utils._text import to_text
from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ansible_dict_to_boto3_tag_list
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import camel_dict_to_snake_dict
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import compare_aws_tags

try:
from botocore.exceptions import BotoCoreError, ClientError, WaiterError
from botocore.exceptions import BotoCoreError
from botocore.exceptions import ClientError
from botocore.exceptions import WaiterError
except ImportError:
pass # Handled by AnsibleAWSModule

from ansible.module_utils._text import to_text
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule


class VPNConnectionException(Exception):
def __init__(self, msg, exception=None):
Expand Down
43 changes: 22 additions & 21 deletions plugins/modules/ec2_vpc_vpn_info.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


DOCUMENTATION = r'''
DOCUMENTATION = r"""
---
module: ec2_vpc_vpn_info
version_added: 1.0.0
short_description: Gather information about VPN Connections in AWS.
description:
- Gather information about VPN Connections in AWS.
author: Madhura Naniwadekar (@Madhura-CSI)
- Gather information about VPN Connections in AWS.
author:
- Madhura Naniwadekar (@Madhura-CSI)
options:
filters:
description:
Expand All @@ -30,13 +29,12 @@
elements: str
default: []
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.boto3
'''
- amazon.aws.common.modules
- amazon.aws.region.modules
- amazon.aws.boto3
"""

EXAMPLES = r'''
EXAMPLES = r"""
# # Note: These examples do not set authentication details, see the AWS Guide for details.
- name: Gather information about all vpn connections
community.aws.ec2_vpc_vpn_info:
Expand All @@ -52,9 +50,9 @@
filters:
vpn-gateway-id: vgw-cbe66beb
register: vpn_conn_info
'''
"""

RETURN = r'''
RETURN = r"""
vpn_connections:
description: List of one or more VPN Connections.
returned: always
Expand Down Expand Up @@ -158,19 +156,22 @@
returned: always
type: str
sample: vgw-cbe56bfb
'''
"""

import json

try:
from botocore.exceptions import ClientError, BotoCoreError
from botocore.exceptions import BotoCoreError
from botocore.exceptions import ClientError
except ImportError:
pass # caught by AnsibleAWSModule

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import (ansible_dict_to_boto3_filter_list,
boto3_tag_list_to_ansible_dict,
camel_dict_to_snake_dict,
)


def date_handler(obj):
Expand Down

0 comments on commit e8552b7

Please sign in to comment.