mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-09-30 05:23:29 -07:00
Object.input should == noneditable (#62)
<!-- This change is generated by MagicModules. --> /cc @rambleraptor
This commit is contained in:
parent
fc87db420b
commit
7c4d1c582b
12 changed files with 169 additions and 375 deletions
|
@ -322,48 +322,8 @@ def create(module, link, kind):
|
|||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||
|
||||
|
||||
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('ipCidrRange') != request.get('ipCidrRange'):
|
||||
ip_cidr_range_update(module, request, response)
|
||||
if response.get('enableFlowLogs') != request.get('enableFlowLogs') or response.get('secondaryIpRanges') != request.get('secondaryIpRanges'):
|
||||
enable_flow_logs_update(module, request, response)
|
||||
if response.get('privateIpGoogleAccess') != request.get('privateIpGoogleAccess'):
|
||||
private_ip_google_access_update(module, request, response)
|
||||
|
||||
|
||||
def ip_cidr_range_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}/expandIpCidrRange"]).format(**module.params),
|
||||
{u'ipCidrRange': module.params.get('ip_cidr_range')},
|
||||
)
|
||||
|
||||
|
||||
def enable_flow_logs_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.patch(
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}"]).format(**module.params),
|
||||
{
|
||||
u'enableFlowLogs': module.params.get('enable_flow_logs'),
|
||||
u'fingerprint': response.get('fingerprint'),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def private_ip_google_access_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}/setPrivateIpGoogleAccess"]).format(
|
||||
**module.params
|
||||
),
|
||||
{u'privateIpGoogleAccess': module.params.get('private_ip_google_access')},
|
||||
)
|
||||
def update(module, link, kind):
|
||||
module.fail_json(msg="Subnetwork cannot be edited")
|
||||
|
||||
|
||||
def delete(module, link, kind):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue