<commit_before>#!/usr/bin/python
#
# Copyright (c) 2018 <NAME> <<EMAIL>>
#
# 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

ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}

DOCUMENTATION = '''
---
module: azure_rm_virtualnetworkpeering
version_added: "2.8"
short_description: Manage Azure Virtual Network Peering.
description:
    - Create, update and delete Azure Virtual Network Peering.

options:
    resource_group:
        description:
            - Name of a resource group where the vnet exists.
        required: true
    name:
        description:
            - Name of the virtual network peering.
        required: true
    virtual_network:
        description:
            - Virtual network to be peered.
            - It can be name of virtual network.
            - It can be virtual network resource id.
        required: true
    remote_virtual_network:
        description:
            - Remote virtual network to be peered.
            - It can be name of remote virtual network in same resource group.
            - It can be remote virtual network resource id.
            - It can be a dict which contains C(name) and C(resource_group) of remote virtual network.
            - Required when creating
    allow_virtual_network_access:
        description:
            - Allows VMs in the remote VNet to access all VMs in the local VNet.
        type: bool
        default: false
    allow_forwarded_traffic:
        description:
            - Allows forwarded traffic from the VMs in the remote VNet.
        type: bool
        default: false
    use_remote_gateways:
        description:
            - If remote gateways can be used on this virtual network.
        type: bool
        default: false
    allow_gateway_transit:
        description:
            - Allows VNet to use the remote VNet's gateway. Remote VNet gateway must have --allow-gateway-transit enabled for remote peering.
            - Only 1 peering can have this flag enabled. Cannot be set if the VNet already has a gateway.
        type: bool
        default: false
    state:
        description:
            - Assert the state of the virtual network peering. Use C(present) to create or update a peering and C(absent) to delete it.
        default: present
        choices:
            - absent
            - present

extends_documentation_fragment:
    - azure

author:
    - "<NAME> <<EMAIL>>"
'''

EXAMPLES = '''
    - name: Create virtual network peering
      azure_rm_virtualnetworkpeering:
        resource_group: myResourceGroup1
        name: vnet_peer1
        virtual_network: myVnet1
        remote_virtual_network:
          resource_group: myResourceGroup2
          name: myVnet2
        allow_virtual_network_access: false
        allow_forwarded_traffic: true

    - name: Delete the virtual network peering
      azure_rm_virtualnetworkpeering:
        resource_group: myResourceGroup1
        name: vnet_peer1
        virtual_network: myVnet1
        state: absent
'''
RETURN = '''
id:
    description: Id of the Azure virtual network peering
    returned: always
    type: dict
    example:<commit_msg>Fix author in azure_rm_virtualnetworkpeering.<commit_after>#!/usr/bin/python
#
# Copyright (c) 2018 <NAME> <<EMAIL>>
#
# 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

ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}

DOCUMENTATION = '''
---
module: azure_rm_virtualnetworkpeering
version_added: "2.8"
short_description: Manage Azure Virtual Network Peering.
description:
    - Create, update and delete Azure Virtual Network Peering.

options:
    resource_group:
        description:
            - Name of a resource group where the vnet exists.
        required: true
    name:
        description:
            - Name of the virtual network peering.
        required: true
    virtual_network:
        description:
            - Virtual network to be peered.
            - It can be name of virtual network.
            - It can be virtual network resource id.
        required: true
    remote_virtual_network:
        description:
            - Remote virtual network to be peered.
            - It can be name of remote virtual network in same resource group.
            - It can be remote virtual network resource id.
            - It can be a dict which contains C(name) and C(resource_group) of remote virtual network.
            - Required when creating
    allow_virtual_network_access:
        description:
            - Allows VMs in the remote VNet to access all VMs in the local VNet.
        type: bool
        default: false
    allow_forwarded_traffic:
        description:
            - Allows forwarded traffic from the VMs in the remote VNet.
        type: bool
        default: false
    use_remote_gateways:
        description:
            - If remote gateways can be used on this virtual network.
        type: bool
        default: false
    allow_gateway_transit:
        description:
            - Allows VNet to use the remote VNet's gateway. Remote VNet gateway must have --allow-gateway-transit enabled for remote peering.
            - Only 1 peering can have this flag enabled. Cannot be set if the VNet already has a gateway.
        type: bool
        default: false
    state:
        description:
            - Assert the state of the virtual network peering. Use C(present) to create or update a peering and C(absent) to delete it.
        default: present
        choices:
            - absent
            - present

extends_documentation_fragment:
    - azure

author:
    - <NAME> (@yungezz)
'''

EXAMPLES = '''
    - name: Create virtual network peering
      azure_rm_virtualnetworkpeering:
        resource_group: myResourceGroup1
        name: vnet_peer1
        virtual_network: myVnet1
        remote_virtual_network:
          resource_group: myResourceGroup2
          name: myVnet2
        allow_virtual_network_access: false
        allow_forwarded_traffic: true

    - name: Delete the virtual network peering
      azure_rm_virtualnetworkpeering:
        resource_group: myResourceGroup1
        name: vnet_peer1
        virtual_network: myVnet1
        state: absent
'''
RETURN = '''
id:
    description: Id of the Azure virtual network peering
    returned: always
    type: dict
    example:
{'fraction_non_alphanumeric': 0.06168976307554761, 'fraction_numerical': 0.006258381761287439, 'mean_word_length': 2.197713196760362, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4264035', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1767, 'n_words': 646}