mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-04 09:50:27 -07:00
149 lines
5.1 KiB
YAML
149 lines
5.1 KiB
YAML
---
|
|
# ----------------------------------------------------------------------------
|
|
#
|
|
# *** AUTO GENERATED CODE *** Type: MMv1 ***
|
|
#
|
|
# ----------------------------------------------------------------------------
|
|
#
|
|
# 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: Create a dataset
|
|
google.cloud.gcp_bigquery_dataset:
|
|
name: example_dataset
|
|
dataset_reference:
|
|
dataset_id: example_dataset
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
state: present
|
|
register: dataset
|
|
- name: Delete a table
|
|
google.cloud.gcp_bigquery_table:
|
|
name: example_table
|
|
dataset: example_dataset
|
|
table_reference:
|
|
dataset_id: example_dataset
|
|
project_id: "{{ gcp_project }}"
|
|
table_id: example_table
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
state: absent
|
|
# ----------------------------------------------------------
|
|
- name: Create a table
|
|
google.cloud.gcp_bigquery_table:
|
|
name: example_table
|
|
dataset: example_dataset
|
|
table_reference:
|
|
dataset_id: example_dataset
|
|
project_id: "{{ gcp_project }}"
|
|
table_id: example_table
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
state: present
|
|
register: result
|
|
- name: Assert changed is true
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result.changed == true
|
|
- name: Verify that table was created
|
|
google.cloud.gcp_bigquery_table_info:
|
|
dataset: example_dataset
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
scopes:
|
|
- https://www.googleapis.com/auth/bigquery
|
|
register: results
|
|
- name: Verify that command succeeded
|
|
ansible.builtin.assert:
|
|
that:
|
|
- results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 1
|
|
# ----------------------------------------------------------------------------
|
|
- name: Create a table that already exists
|
|
google.cloud.gcp_bigquery_table:
|
|
name: example_table
|
|
dataset: example_dataset
|
|
table_reference:
|
|
dataset_id: example_dataset
|
|
project_id: "{{ gcp_project }}"
|
|
table_id: example_table
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
state: present
|
|
register: result
|
|
- name: Assert changed is false
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result.changed == false
|
|
# ----------------------------------------------------------
|
|
- name: Delete a table
|
|
google.cloud.gcp_bigquery_table:
|
|
name: example_table
|
|
dataset: example_dataset
|
|
table_reference:
|
|
dataset_id: example_dataset
|
|
project_id: "{{ gcp_project }}"
|
|
table_id: example_table
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
state: absent
|
|
register: result
|
|
- name: Assert changed is true
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result.changed == true
|
|
- name: Verify that table was deleted
|
|
google.cloud.gcp_bigquery_table_info:
|
|
dataset: example_dataset
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
scopes:
|
|
- https://www.googleapis.com/auth/bigquery
|
|
register: results
|
|
- name: Verify that command succeeded
|
|
ansible.builtin.assert:
|
|
that:
|
|
- results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 0
|
|
# ----------------------------------------------------------------------------
|
|
- name: Delete a table that does not exist
|
|
google.cloud.gcp_bigquery_table:
|
|
name: example_table
|
|
dataset: example_dataset
|
|
table_reference:
|
|
dataset_id: example_dataset
|
|
project_id: "{{ gcp_project }}"
|
|
table_id: example_table
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
state: absent
|
|
register: result
|
|
- name: Assert changed is false
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result.changed == false
|
|
# ---------------------------------------------------------
|
|
# Post-test teardown
|
|
# If errors happen, don't crash the playbook!
|
|
- name: Delete a dataset
|
|
google.cloud.gcp_bigquery_dataset:
|
|
name: example_dataset
|
|
dataset_reference:
|
|
dataset_id: example_dataset
|
|
project: "{{ gcp_project }}"
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
|
state: absent
|
|
register: dataset
|
|
ignore_errors: true
|