mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
GCP MagicModules bug fixes (#47285)
Closes: #46930 #46929 #46928 #46927 #46926 #46925 #46924 #46923 #46922 #46921 #46920 #46919 #46918 #46917 #46916 #46915 #46914 #46913 #46912 #46911 #46910 #46909 #46908 #46907 #46906 #46905 #46903 #46902 #46901 #46900 #46899 #46898 #46897 #46896 #46895 #46894 #46893 #46892 #46891 #46890 #46889 #46888 #46887 #46886 #46885 #46884 #46883 #46882 #46881 #46880 #46879 #46878 #46877 #46876 #46875 #46874 #46873 #46872 #46871 #46870 #46869 #46868 #46867 #46866 #46865 #46864 #46863 #46862 #46861 #46860 #46859 #46858 #46857 #46856 #46855 #46854 #46853 #46852
This commit is contained in:
parent
3b5471a734
commit
18a088c64e
78 changed files with 2452 additions and 1095 deletions
|
@ -59,6 +59,11 @@ options:
|
|||
bucket:
|
||||
description:
|
||||
- The name of the bucket.
|
||||
- 'This field represents a link to a Bucket resource in GCP. It can be specified in
|
||||
two ways. You can add `register: name-of-resource` to a gcp_storage_bucket task
|
||||
and then set this bucket field to "{{ name-of-resource }}" Alternatively, you can
|
||||
set this bucket to a dictionary with the name key where the value is the name of
|
||||
your Bucket.'
|
||||
required: true
|
||||
domain:
|
||||
description:
|
||||
|
@ -139,6 +144,11 @@ options:
|
|||
bucket:
|
||||
description:
|
||||
- The name of the bucket.
|
||||
- 'This field represents a link to a Bucket resource in GCP. It can be specified in
|
||||
two ways. You can add `register: name-of-resource` to a gcp_storage_bucket task
|
||||
and then set this bucket field to "{{ name-of-resource }}" Alternatively, you can
|
||||
set this bucket to a dictionary with the name key where the value is the name of
|
||||
your Bucket.'
|
||||
required: true
|
||||
domain:
|
||||
description:
|
||||
|
@ -358,7 +368,7 @@ EXAMPLES = '''
|
|||
gcp_storage_bucket:
|
||||
name: ansible-storage-module
|
||||
project: "test_project"
|
||||
auth_kind: "service_account"
|
||||
auth_kind: "serviceaccount"
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
state: present
|
||||
'''
|
||||
|
@ -396,7 +406,7 @@ RETURN = '''
|
|||
entity would be domain-example.com.
|
||||
returned: success
|
||||
type: str
|
||||
entity_id:
|
||||
entityId:
|
||||
description:
|
||||
- The ID for the entity.
|
||||
returned: success
|
||||
|
@ -406,13 +416,13 @@ RETURN = '''
|
|||
- The ID of the access-control entry.
|
||||
returned: success
|
||||
type: str
|
||||
project_team:
|
||||
projectTeam:
|
||||
description:
|
||||
- The project team associated with the entity.
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
project_number:
|
||||
projectNumber:
|
||||
description:
|
||||
- The project team associated with the entity.
|
||||
returned: success
|
||||
|
@ -433,7 +443,7 @@ RETURN = '''
|
|||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
max_age_seconds:
|
||||
maxAgeSeconds:
|
||||
description:
|
||||
- The value, in seconds, to return in the Access-Control-Max-Age header used in preflight
|
||||
responses.
|
||||
|
@ -451,13 +461,13 @@ RETURN = '''
|
|||
- 'Note: "*" is permitted in the list of origins, and means "any Origin".'
|
||||
returned: success
|
||||
type: list
|
||||
response_header:
|
||||
responseHeader:
|
||||
description:
|
||||
- The list of HTTP headers other than the simple response headers to give permission
|
||||
for the user-agent to share across domains.
|
||||
returned: success
|
||||
type: list
|
||||
default_object_acl:
|
||||
defaultObjectAcl:
|
||||
description:
|
||||
- Default access controls to apply to new objects when no ACL is provided.
|
||||
returned: success
|
||||
|
@ -489,7 +499,7 @@ RETURN = '''
|
|||
entity would be domain-example.com.
|
||||
returned: success
|
||||
type: str
|
||||
entity_id:
|
||||
entityId:
|
||||
description:
|
||||
- The ID for the entity.
|
||||
returned: success
|
||||
|
@ -509,13 +519,13 @@ RETURN = '''
|
|||
- The name of the object, if applied to an object.
|
||||
returned: success
|
||||
type: str
|
||||
project_team:
|
||||
projectTeam:
|
||||
description:
|
||||
- The project team associated with the entity.
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
project_number:
|
||||
projectNumber:
|
||||
description:
|
||||
- The project team associated with the entity.
|
||||
returned: success
|
||||
|
@ -555,7 +565,7 @@ RETURN = '''
|
|||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
storage_class:
|
||||
storageClass:
|
||||
description:
|
||||
- Target storage class. Required iff the type of the action is SetStorageClass.
|
||||
returned: success
|
||||
|
@ -571,32 +581,32 @@ RETURN = '''
|
|||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
age_days:
|
||||
ageDays:
|
||||
description:
|
||||
- Age of an object (in days). This condition is satisfied when an object reaches the
|
||||
specified age.
|
||||
returned: success
|
||||
type: int
|
||||
created_before:
|
||||
createdBefore:
|
||||
description:
|
||||
- A date in RFC 3339 format with only the date part (for instance, "2013-01-15").
|
||||
This condition is satisfied when an object is created before midnight of the specified
|
||||
date in UTC.
|
||||
returned: success
|
||||
type: str
|
||||
is_live:
|
||||
isLive:
|
||||
description:
|
||||
- Relevant only for versioned objects. If the value is true, this condition matches
|
||||
live objects; if the value is false, it matches archived objects.
|
||||
returned: success
|
||||
type: bool
|
||||
matches_storage_class:
|
||||
matchesStorageClass:
|
||||
description:
|
||||
- Objects having any of the storage classes specified by this condition will be matched.
|
||||
Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY.
|
||||
returned: success
|
||||
type: list
|
||||
num_newer_versions:
|
||||
numNewerVersions:
|
||||
description:
|
||||
- Relevant only for versioned objects. If the value is N, this condition is satisfied
|
||||
when there are at least N versions (including the live version) newer than this
|
||||
|
@ -617,12 +627,12 @@ RETURN = '''
|
|||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
log_bucket:
|
||||
logBucket:
|
||||
description:
|
||||
- The destination bucket where the current bucket's logs should be placed.
|
||||
returned: success
|
||||
type: str
|
||||
log_object_prefix:
|
||||
logObjectPrefix:
|
||||
description:
|
||||
- A prefix for log object names.
|
||||
returned: success
|
||||
|
@ -648,17 +658,17 @@ RETURN = '''
|
|||
- The entity, in the form project-owner-projectId.
|
||||
returned: success
|
||||
type: str
|
||||
entity_id:
|
||||
entityId:
|
||||
description:
|
||||
- The ID for the entity.
|
||||
returned: success
|
||||
type: str
|
||||
project_number:
|
||||
projectNumber:
|
||||
description:
|
||||
- The project number of the project the bucket belongs to.
|
||||
returned: success
|
||||
type: int
|
||||
storage_class:
|
||||
storageClass:
|
||||
description:
|
||||
- The bucket's default storage class, used whenever no storageClass is specified for
|
||||
a newly-created object. This defines how objects in the bucket are stored and determines
|
||||
|
@ -668,7 +678,7 @@ RETURN = '''
|
|||
For more information, see storage classes.
|
||||
returned: success
|
||||
type: str
|
||||
time_created:
|
||||
timeCreated:
|
||||
description:
|
||||
- The creation time of the bucket in RFC 3339 format.
|
||||
returned: success
|
||||
|
@ -696,14 +706,14 @@ RETURN = '''
|
|||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
main_page_suffix:
|
||||
mainPageSuffix:
|
||||
description:
|
||||
- If the requested object path is missing, the service will ensure the path has a
|
||||
trailing '/', append this suffix, and attempt to retrieve the resulting object.
|
||||
This allows the creation of index.html objects to represent directory pages.
|
||||
returned: success
|
||||
type: str
|
||||
not_found_page:
|
||||
notFoundPage:
|
||||
description:
|
||||
- If the requested object path is missing, and any mainPageSuffix object is missing,
|
||||
if applicable, the service will return the named object from this bucket as the
|
||||
|
@ -715,7 +725,7 @@ RETURN = '''
|
|||
- A valid API project identifier.
|
||||
returned: success
|
||||
type: str
|
||||
predefined_default_object_acl:
|
||||
predefinedDefaultObjectAcl:
|
||||
description:
|
||||
- Apply a predefined set of default object access controls to this bucket.
|
||||
- 'Acceptable values are: - "authenticatedRead": Object owner gets OWNER access,
|
||||
|
@ -840,7 +850,8 @@ def main():
|
|||
if fetch:
|
||||
if state == 'present':
|
||||
if is_different(module, fetch):
|
||||
fetch = update(module, self_link(module), kind)
|
||||
update(module, self_link(module), kind)
|
||||
fetch = fetch_resource(module, self_link(module), kind)
|
||||
changed = True
|
||||
else:
|
||||
delete(module, self_link(module), kind)
|
||||
|
@ -899,9 +910,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, 'storage')
|
||||
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):
|
||||
|
@ -912,9 +923,9 @@ def collection(module):
|
|||
return "https://www.googleapis.com/storage/v1/b?project={project}".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.
|
||||
|
@ -929,8 +940,6 @@ def return_if_object(module, response, kind):
|
|||
|
||||
if navigate_hash(result, ['error', 'errors']):
|
||||
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
|
||||
if result['kind'] != kind:
|
||||
module.fail_json(msg="Incorrect result: {kind}".format(**result))
|
||||
|
||||
return result
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue