mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-06 10:50:28 -07:00
* support compute reservations resize * remove if custom encoder * review comments Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
parent
947007da82
commit
872d3daf12
1 changed files with 18 additions and 5 deletions
|
@ -410,7 +410,7 @@ def main():
|
|||
if fetch:
|
||||
if state == 'present':
|
||||
if is_different(module, fetch):
|
||||
update(module, self_link(module))
|
||||
update(module, self_link(module), fetch)
|
||||
fetch = fetch_resource(module, self_link(module))
|
||||
changed = True
|
||||
else:
|
||||
|
@ -434,9 +434,22 @@ def create(module, link):
|
|||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||
|
||||
|
||||
def update(module, link):
|
||||
delete(module, self_link(module))
|
||||
create(module, collection(module))
|
||||
def update(module, link, fetch):
|
||||
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
|
||||
return fetch_resource(module, self_link(module))
|
||||
|
||||
|
||||
def update_fields(module, request, response):
|
||||
if response.get('specificReservation') != request.get('specificReservation'):
|
||||
specific_reservation_update(module, request, response)
|
||||
|
||||
|
||||
def specific_reservation_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/reservations/{name}/resize"]).format(**module.params),
|
||||
{u'specificReservation': ReservationSpecificreservation(module.params.get('specific_reservation', {}), module).to_request()},
|
||||
)
|
||||
|
||||
|
||||
def delete(module, link):
|
||||
|
@ -582,7 +595,7 @@ class ReservationSpecificreservation(object):
|
|||
return remove_nones_from_dict(
|
||||
{
|
||||
u'count': self.request.get(u'count'),
|
||||
u'instanceProperties': ReservationInstanceproperties(self.request.get(u'instanceProperties', {}), self.module).from_response(),
|
||||
u'instanceProperties': ReservationInstanceproperties(self.module.params.get('instance_properties', {}), self.module).to_request(),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue