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
  • Loading branch information
tremble authored and abikouo committed Sep 18, 2023
1 parent a1d0dc1 commit 1da55da
Show file tree
Hide file tree
Showing 159 changed files with 2,595 additions and 2,792 deletions.
25 changes: 12 additions & 13 deletions accessanalyzer_validate_policy_info.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/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: accessanalyzer_validate_policy_info
version_added: 5.0.0
Expand Down Expand Up @@ -63,19 +61,19 @@
author:
- Mark Chappell (@tremble)
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.common.modules
- amazon.aws.region.modules
- amazon.aws.boto3
'''
"""

EXAMPLES = r'''
EXAMPLES = r"""
# Validate a policy
- name: Validate a simple IAM policy
community.aws.accessanalyzer_validate_policy_info:
policy: "{{ lookup('template', 'managed_policy.json.j2') }}"
'''
"""

RETURN = r'''
RETURN = r"""
findings:
description: The list of findings in a policy returned by IAM Access Analyzer based on its suite of policy checks.
returned: success
Expand Down Expand Up @@ -160,7 +158,7 @@
description: The offset within the policy that corresponds to the position, starting from C(0).
type: int
returned: success
'''
"""

try:
import botocore
Expand All @@ -169,8 +167,9 @@

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.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry


def filter_findings(findings, type_filter):
Expand Down
53 changes: 18 additions & 35 deletions acm_certificate.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#

# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
#

# Author:
# - Matthew Davis <[email protected]>
# on behalf of Telstra Corporation Limited

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


DOCUMENTATION = r'''
DOCUMENTATION = r"""
---
module: acm_certificate
short_description: Upload and delete certificates in the AWS Certificate Manager service
Expand Down Expand Up @@ -175,13 +158,13 @@
author:
- Matthew Davis (@matt-telstra) on behalf of Telstra Corporation Limited
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.boto3
- amazon.aws.common.modules
- amazon.aws.region.modules
- amazon.aws.tags
'''
- amazon.aws.boto3
"""

EXAMPLES = '''
EXAMPLES = r"""
- name: upload a self-signed certificate
community.aws.aws_acm:
Expand Down Expand Up @@ -230,9 +213,9 @@
Application: search
Environment: development
purge_tags: true
'''
"""

RETURN = '''
RETURN = r"""
certificate:
description: Information about the certificate which was uploaded
type: complex
Expand All @@ -255,7 +238,7 @@
returned: when I(state=absent)
sample:
- "arn:aws:acm:ap-southeast-2:123456789012:certificate/01234567-abcd-abcd-abcd-012345678901"
'''
"""


import base64
Expand All @@ -267,15 +250,15 @@
except ImportError:
pass # handled by AnsibleAWSModule

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.acm import ACMServiceManager
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import compare_aws_tags
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import (
boto3_tag_list_to_ansible_dict,
ansible_dict_to_boto3_tag_list,
)
from ansible.module_utils._text import to_text

from ansible_collections.amazon.aws.plugins.module_utils.acm import ACMServiceManager
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


def ensure_tags(client, module, resource_arn, existing_tags, tags, purge_tags):
if tags is None:
Expand Down
25 changes: 12 additions & 13 deletions acm_certificate_info.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/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: acm_certificate_info
short_description: Retrieve certificate information from AWS Certificate Manager service
version_added: 1.0.0
Expand Down Expand Up @@ -43,12 +41,12 @@
author:
- Will Thames (@willthames)
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.common.modules
- amazon.aws.region.modules
- amazon.aws.boto3
'''
"""

EXAMPLES = r'''
EXAMPLES = r"""
- name: obtain all ACM certificates
community.aws.aws_acm_info:
Expand All @@ -73,9 +71,9 @@
community.aws.aws_acm_info:
certificate_arn: "arn:aws:acm:ap-southeast-2:123456789012:certificate/abcdeabc-abcd-1234-4321-abcdeabcde12"
'''
"""

RETURN = r'''
RETURN = r"""
certificates:
description: A list of certificates
returned: always
Expand Down Expand Up @@ -257,11 +255,12 @@
returned: always
sample: AMAZON_ISSUED
type: str
'''
"""

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

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


def main():
argument_spec = dict(
Expand Down
28 changes: 12 additions & 16 deletions api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
# 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 = '''
DOCUMENTATION = r"""
---
module: api_gateway
version_added: 1.0.0
Expand Down Expand Up @@ -104,19 +100,18 @@
default: EDGE
author:
- 'Michael De La Rue (@mikedlr)'
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.boto3
notes:
- A future version of this module will probably use tags or another
ID so that an API can be created only once.
- As an early work around an intermediate version will probably do
the same using a tag embedded in the API name.
'''
extends_documentation_fragment:
- amazon.aws.common.modules
- amazon.aws.region.modules
- amazon.aws.boto3
"""

EXAMPLES = '''
EXAMPLES = r"""
- name: Setup AWS API Gateway setup on AWS and deploy API definition
community.aws.api_gateway:
swagger_file: my_api.yml
Expand Down Expand Up @@ -145,9 +140,9 @@
cache_size: '6.1'
canary_settings: { percentTraffic: 50.0, deploymentId: '123', useStageCache: True }
state: present
'''
"""

RETURN = '''
RETURN = r"""
api_id:
description: API id of the API endpoint created
returned: success
Expand All @@ -168,7 +163,7 @@
returned: always
type: list
sample: ["apigateway:CreateRestApi", "apigateway:CreateDeployment", "apigateway:PutRestApi"]
'''
"""

import json
import traceback
Expand All @@ -180,8 +175,9 @@

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.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry


def main():
Expand Down
41 changes: 22 additions & 19 deletions api_gateway_domain.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/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 = '''
DOCUMENTATION = r"""
---
module: api_gateway_domain
short_description: Manage AWS API Gateway custom domains
Expand Down Expand Up @@ -57,17 +55,17 @@
default: present
choices: [ 'present', 'absent' ]
type: str
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.boto3
notes:
- Does not create a DNS entry on Route53, for that use the M(community.aws.route53) module.
- Only supports TLS certificates from AWS ACM that can just be referenced by the ARN, while the AWS API still offers (deprecated)
options to add own Certificates.
'''
extends_documentation_fragment:
- amazon.aws.common.modules
- amazon.aws.region.modules
- amazon.aws.boto3
"""

EXAMPLES = '''
EXAMPLES = r"""
- name: Setup endpoint for a custom domain for your API Gateway HTTP API
community.aws.api_gateway_domain:
domain_name: myapi.foobar.com
Expand All @@ -88,9 +86,9 @@
zone: foobar.com
alias_hosted_zone_id: "{{ api_gw_domain_result.response.domain.distribution_hosted_zone_id }}"
command: create
'''
"""

RETURN = '''
RETURN = r"""
response:
description: The data returned by create_domain_name (or update and delete) and create_base_path_mapping methods by boto3.
returned: success
Expand All @@ -110,19 +108,24 @@
path_mappings: [
{ base_path: '(empty)', rest_api_id: 'abcd123', stage: 'production' }
]
'''
"""

import copy

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

import copy
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict

from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict, snake_dict_to_camel_dict


def get_domain(module, client):
Expand Down
Loading

0 comments on commit 1da55da

Please sign in to comment.