| 1 |
--- |
| 2 |
# ---------------------------------------------------------------------------- |
| 3 |
# |
| 4 |
# *** AUTO GENERATED CODE *** Type: MMv1 *** |
| 5 |
# |
| 6 |
# ---------------------------------------------------------------------------- |
| 7 |
# |
| 8 |
# This file is automatically generated by Magic Modules and manual |
| 9 |
# changes will be clobbered when the file is regenerated. |
| 10 |
# |
| 11 |
# Please read more about how to change this file at |
| 12 |
# https://www.github.com/GoogleCloudPlatform/magic-modules |
| 13 |
# |
| 14 |
# ---------------------------------------------------------------------------- |
| 15 |
# Pre-test setup |
| 16 |
- name: Delete a model |
| 17 |
google.cloud.gcp_mlengine_model: |
| 18 |
name: "{{ resource_name | replace('-', '_') }}" |
| 19 |
description: My model |
| 20 |
regions: |
| 21 |
- us-central1 |
| 22 |
project: "{{ gcp_project }}" |
| 23 |
auth_kind: "{{ gcp_cred_kind }}" |
| 24 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 25 |
state: absent |
| 26 |
# ---------------------------------------------------------- |
| 27 |
- name: Create a model |
| 28 |
google.cloud.gcp_mlengine_model: |
| 29 |
name: "{{ resource_name | replace('-', '_') }}" |
| 30 |
description: My model |
| 31 |
regions: |
| 32 |
- us-central1 |
| 33 |
project: "{{ gcp_project }}" |
| 34 |
auth_kind: "{{ gcp_cred_kind }}" |
| 35 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 36 |
state: present |
| 37 |
register: result |
| 38 |
- name: Assert changed is true |
| 39 |
ansible.builtin.assert: |
| 40 |
that: |
| 41 |
- result.changed == true |
| 42 |
- name: Verify that model was created |
| 43 |
google.cloud.gcp_mlengine_model_info: |
| 44 |
project: "{{ gcp_project }}" |
| 45 |
auth_kind: "{{ gcp_cred_kind }}" |
| 46 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 47 |
scopes: |
| 48 |
- https://www.googleapis.com/auth/cloud-platform |
| 49 |
register: results |
| 50 |
- name: Verify that command succeeded |
| 51 |
ansible.builtin.assert: |
| 52 |
that: |
| 53 |
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 1 |
| 54 |
# ---------------------------------------------------------------------------- |
| 55 |
- name: Create a model that already exists |
| 56 |
google.cloud.gcp_mlengine_model: |
| 57 |
name: "{{ resource_name | replace('-', '_') }}" |
| 58 |
description: My model |
| 59 |
regions: |
| 60 |
- us-central1 |
| 61 |
project: "{{ gcp_project }}" |
| 62 |
auth_kind: "{{ gcp_cred_kind }}" |
| 63 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 64 |
state: present |
| 65 |
register: result |
| 66 |
- name: Assert changed is false |
| 67 |
ansible.builtin.assert: |
| 68 |
that: |
| 69 |
- result.changed == false |
| 70 |
# ---------------------------------------------------------- |
| 71 |
- name: Delete a model |
| 72 |
google.cloud.gcp_mlengine_model: |
| 73 |
name: "{{ resource_name | replace('-', '_') }}" |
| 74 |
description: My model |
| 75 |
regions: |
| 76 |
- us-central1 |
| 77 |
project: "{{ gcp_project }}" |
| 78 |
auth_kind: "{{ gcp_cred_kind }}" |
| 79 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 80 |
state: absent |
| 81 |
register: result |
| 82 |
- name: Assert changed is true |
| 83 |
ansible.builtin.assert: |
| 84 |
that: |
| 85 |
- result.changed == true |
| 86 |
- name: Verify that model was deleted |
| 87 |
google.cloud.gcp_mlengine_model_info: |
| 88 |
project: "{{ gcp_project }}" |
| 89 |
auth_kind: "{{ gcp_cred_kind }}" |
| 90 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 91 |
scopes: |
| 92 |
- https://www.googleapis.com/auth/cloud-platform |
| 93 |
register: results |
| 94 |
- name: Verify that command succeeded |
| 95 |
ansible.builtin.assert: |
| 96 |
that: |
| 97 |
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 0 |
| 98 |
# ---------------------------------------------------------------------------- |
| 99 |
- name: Delete a model that does not exist |
| 100 |
google.cloud.gcp_mlengine_model: |
| 101 |
name: "{{ resource_name | replace('-', '_') }}" |
| 102 |
description: My model |
| 103 |
regions: |
| 104 |
- us-central1 |
| 105 |
project: "{{ gcp_project }}" |
| 106 |
auth_kind: "{{ gcp_cred_kind }}" |
| 107 |
service_account_file: "{{ gcp_cred_file | default(omit) }}" |
| 108 |
state: absent |
| 109 |
register: result |
| 110 |
- name: Assert changed is false |
| 111 |
ansible.builtin.assert: |
| 112 |
that: |
| 113 |
- result.changed == false |