mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-06-04 07:59:10 -07:00
Partial updates (#63)
This commit is contained in:
parent
3382f7f7b2
commit
2837b2f836
13 changed files with 1165 additions and 877 deletions
|
@ -102,54 +102,54 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
RETURN = '''
|
||||
address:
|
||||
description:
|
||||
- The static external IP address represented by this resource.
|
||||
returned: success
|
||||
type: str
|
||||
creationTimestamp:
|
||||
description:
|
||||
- Creation timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
description:
|
||||
description:
|
||||
- An optional description of this resource.
|
||||
returned: success
|
||||
type: str
|
||||
id:
|
||||
description:
|
||||
- The unique identifier for the resource. This identifier is defined by the server.
|
||||
returned: success
|
||||
type: int
|
||||
name:
|
||||
description:
|
||||
- Name of the resource. Provided by the client when the resource is created. The
|
||||
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
|
||||
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||
which means the first character must be a lowercase letter, and all following
|
||||
characters must be a dash, lowercase letter, or digit, except the last character,
|
||||
which cannot be a dash.
|
||||
returned: success
|
||||
type: str
|
||||
ipVersion:
|
||||
description:
|
||||
- The IP Version that will be used by this address. Valid options are `IPV4` or
|
||||
`IPV6`. The default value is `IPV4`.
|
||||
returned: success
|
||||
type: str
|
||||
region:
|
||||
description:
|
||||
- A reference to the region where the regional address resides.
|
||||
returned: success
|
||||
type: str
|
||||
addressType:
|
||||
description:
|
||||
- The type of the address to reserve, default is EXTERNAL.
|
||||
- "* EXTERNAL indicates public/external single IP address."
|
||||
- "* INTERNAL indicates internal IP ranges belonging to some network."
|
||||
returned: success
|
||||
type: str
|
||||
address:
|
||||
description:
|
||||
- The static external IP address represented by this resource.
|
||||
returned: success
|
||||
type: str
|
||||
creation_timestamp:
|
||||
description:
|
||||
- Creation timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
description:
|
||||
description:
|
||||
- An optional description of this resource.
|
||||
- Provide this property when you create the resource.
|
||||
returned: success
|
||||
type: str
|
||||
id:
|
||||
description:
|
||||
- The unique identifier for the resource. This identifier is defined by the server.
|
||||
returned: success
|
||||
type: int
|
||||
name:
|
||||
description:
|
||||
- Name of the resource. Provided by the client when the resource is created. The name
|
||||
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
||||
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||
which means the first character must be a lowercase letter, and all following characters
|
||||
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
||||
be a dash.
|
||||
returned: success
|
||||
type: str
|
||||
label_fingerprint:
|
||||
description:
|
||||
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||
updates.
|
||||
returned: success
|
||||
type: str
|
||||
ip_version:
|
||||
description:
|
||||
- The IP Version that will be used by this address. Valid options are IPV4 or IPV6.
|
||||
The default value is IPV4.
|
||||
returned: success
|
||||
type: str
|
||||
region:
|
||||
description:
|
||||
- A reference to the region where the regional address resides.
|
||||
returned: success
|
||||
type: str
|
||||
'''
|
||||
|
||||
################################################################################
|
||||
|
@ -192,8 +192,7 @@ def main():
|
|||
if fetch:
|
||||
if state == 'present':
|
||||
if is_different(module, fetch):
|
||||
update(module, self_link(module), kind)
|
||||
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)
|
||||
|
@ -216,8 +215,27 @@ def create(module, link, kind):
|
|||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||
|
||||
|
||||
def update(module, link, kind):
|
||||
module.fail_json(msg="GlobalAddress cannot be edited")
|
||||
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):
|
||||
pass
|
||||
|
||||
|
||||
def label_fingerprint_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/addresses/{name}/setLabels"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'labelFingerprint': response.get('labelFingerprint')
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def delete(module, link, kind):
|
||||
|
@ -303,6 +321,7 @@ def response_to_hash(module, response):
|
|||
u'description': response.get(u'description'),
|
||||
u'id': response.get(u'id'),
|
||||
u'name': response.get(u'name'),
|
||||
u'labelFingerprint': response.get(u'labelFingerprint'),
|
||||
u'ipVersion': response.get(u'ipVersion'),
|
||||
u'region': response.get(u'region'),
|
||||
u'addressType': response.get(u'addressType'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue