Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
return_if_object should only allow 404 on certain situations (#93)
Browse files Browse the repository at this point in the history
<!-- This change is generated by MagicModules. -->
/cc @rambleraptor
  • Loading branch information
modular-magician authored and rambleraptor committed Sep 21, 2018
1 parent aed81a8 commit 6c32e1f
Show file tree
Hide file tree
Showing 43 changed files with 169 additions and 169 deletions.
8 changes: 4 additions & 4 deletions lib/ansible/modules/cloud/google/gcp_compute_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -271,9 +271,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -240,9 +240,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendBuckets".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -716,9 +716,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/cloud/google/gcp_compute_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -536,9 +536,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/cloud/google/gcp_compute_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -498,9 +498,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -494,9 +494,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -251,9 +251,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/addresses".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -489,9 +489,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/cloud/google/gcp_compute_health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -608,9 +608,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -302,9 +302,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -300,9 +300,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/cloud/google/gcp_compute_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -528,9 +528,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/images".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/cloud/google/gcp_compute_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -982,9 +982,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -320,9 +320,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -420,9 +420,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,9 +932,9 @@ def resource_to_request(module):
return return_vals


def fetch_resource(module, link, kind):
def fetch_resource(module, link, kind, allow_not_found=True):
auth = GcpSession(module, 'compute')
return return_if_object(module, auth.get(link), kind)
return return_if_object(module, auth.get(link), kind, allow_not_found)


def self_link(module):
Expand All @@ -945,9 +945,9 @@ def collection(module):
return "https://www.googleapis.com/compute/v1/projects/{project}/global/instanceTemplates".format(**module.params)


def return_if_object(module, response, kind):
def return_if_object(module, response, kind, allow_not_found=False):
# If not found, return nothing.
if response.status_code == 404:
if allow_not_found and response.status_code == 404:
return None

# If no content, return nothing.
Expand Down
Loading

0 comments on commit 6c32e1f

Please sign in to comment.