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

Commit

Permalink
Ansible support on the Magician. (#7)
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 5, 2019
1 parent 3d30542 commit 98fbacb
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions plugins/modules/gcp_compute_target_tcp_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,10 @@ def main():
if fetch:
if state == 'present':
if is_different(module, fetch):
update(module, self_link(module), kind, fetch)
fetch = fetch_resource(module, self_link(module), kind)
fetch = update(module, self_link(module), kind, fetch)
changed = True
else:
delete(module, self_link(module), kind)
delete(module, self_link(module), kind, fetch)
fetch = {}
changed = True
else:
Expand All @@ -239,34 +238,14 @@ def create(module, link, kind):


def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
return fetch_resource(module, self_link(module), kind)


def update_fields(module, request, response):
if response.get('proxyHeader') != request.get('proxyHeader'):
proxy_header_update(module, request, response)
if response.get('service') != request.get('service'):
service_update(module, request, response)


def proxy_header_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetTcpProxies/{name}/setProxyHeader"]).format(**module.params),
{u'proxyHeader': module.params.get('proxy_header')},
)


def service_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetTcpProxies/{name}/setBackendService"]).format(**module.params),
{u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')},
)


def delete(module, link, kind):
def delete(module, link, kind, fetch):
auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.delete(link))

Expand Down

0 comments on commit 98fbacb

Please sign in to comment.