---
# ----------------------------------------------------------------------------
#
#     ***     AUTO GENERATED CODE    ***    AUTO GENERATED CODE     ***
#
# ----------------------------------------------------------------------------
#
#     This file is automatically generated by Magic Modules and manual
#     changes will be clobbered when the file is regenerated.
#
#     Please read more about how to change this file at
#     https://www.github.com/GoogleCloudPlatform/magic-modules
#
# ----------------------------------------------------------------------------
# Pre-test setup
- name: delete a external vpn gateway
  google.cloud.gcp_compute_external_vpn_gateway:
    name: "{{ resource_name }}"
    redundancy_type: SINGLE_IP_INTERNALLY_REDUNDANT
    descrpition: An externalyl managed VPN gateway
    interfaces:
    - id: 0
      ip_address: 8.8.8.8
    project: "{{ gcp_project }}"
    auth_kind: "{{ gcp_cred_kind }}"
    service_account_file: "{{ gcp_cred_file }}"
    state: absent
#----------------------------------------------------------
- name: create a external vpn gateway
  google.cloud.gcp_compute_external_vpn_gateway:
    name: "{{ resource_name }}"
    redundancy_type: SINGLE_IP_INTERNALLY_REDUNDANT
    descrpition: An externalyl managed VPN gateway
    interfaces:
    - id: 0
      ip_address: 8.8.8.8
    project: "{{ gcp_project }}"
    auth_kind: "{{ gcp_cred_kind }}"
    service_account_file: "{{ gcp_cred_file }}"
    state: present
  register: result
- name: assert changed is true
  assert:
    that:
      - result.changed == true
- name: verify that external_vpn_gateway was created
  google.cloud.gcp_compute_external_vpn_gateway_info:
      filters:
         - name = {{ resource_name }}
      project: "{{ gcp_project }}"
      auth_kind: "{{ gcp_cred_kind }}"
      service_account_file: "{{ gcp_cred_file }}"
      scopes:
        - https://www.googleapis.com/auth/compute
  register: results
- name: verify that command succeeded
  assert:
    that:
      - results['resources'] | length == 1
# ----------------------------------------------------------------------------
- name: create a external vpn gateway that already exists
  google.cloud.gcp_compute_external_vpn_gateway:
    name: "{{ resource_name }}"
    redundancy_type: SINGLE_IP_INTERNALLY_REDUNDANT
    descrpition: An externalyl managed VPN gateway
    interfaces:
    - id: 0
      ip_address: 8.8.8.8
    project: "{{ gcp_project }}"
    auth_kind: "{{ gcp_cred_kind }}"
    service_account_file: "{{ gcp_cred_file }}"
    state: present
  register: result
- name: assert changed is false
  assert:
    that:
      - result.changed == false
#----------------------------------------------------------
- name: delete a external vpn gateway
  google.cloud.gcp_compute_external_vpn_gateway:
    name: "{{ resource_name }}"
    redundancy_type: SINGLE_IP_INTERNALLY_REDUNDANT
    descrpition: An externalyl managed VPN gateway
    interfaces:
    - id: 0
      ip_address: 8.8.8.8
    project: "{{ gcp_project }}"
    auth_kind: "{{ gcp_cred_kind }}"
    service_account_file: "{{ gcp_cred_file }}"
    state: absent
  register: result
- name: assert changed is true
  assert:
    that:
      - result.changed == true
- name: verify that external_vpn_gateway was deleted
  google.cloud.gcp_compute_external_vpn_gateway_info:
      filters:
         - name = {{ resource_name }}
      project: "{{ gcp_project }}"
      auth_kind: "{{ gcp_cred_kind }}"
      service_account_file: "{{ gcp_cred_file }}"
      scopes:
        - https://www.googleapis.com/auth/compute
  register: results
- name: verify that command succeeded
  assert:
    that:
      - results['resources'] | length == 0
# ----------------------------------------------------------------------------
- name: delete a external vpn gateway that does not exist
  google.cloud.gcp_compute_external_vpn_gateway:
    name: "{{ resource_name }}"
    redundancy_type: SINGLE_IP_INTERNALLY_REDUNDANT
    descrpition: An externalyl managed VPN gateway
    interfaces:
    - id: 0
      ip_address: 8.8.8.8
    project: "{{ gcp_project }}"
    auth_kind: "{{ gcp_cred_kind }}"
    service_account_file: "{{ gcp_cred_file }}"
    state: absent
  register: result
- name: assert changed is false
  assert:
    that:
      - result.changed == false
