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

Commit

Permalink
Add bigtable app profile resource
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
megan07 authored and modular-magician committed Aug 16, 2019
1 parent e93ab8f commit 6be6248
Show file tree
Hide file tree
Showing 61 changed files with 480 additions and 144 deletions.
24 changes: 0 additions & 24 deletions lib/ansible/module_utils/gcp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,6 @@ def patch(self, url, body=None, **kwargs):
kwargs.update({'json': body})
return self.full_patch(url, **kwargs)

def list(self, url, callback, params=None, array_name='items',
pageToken='nextPageToken', **kwargs):
"""
This should be used for calling the GCP list APIs. It will return
an array of items
This takes a callback to a `return_if_object(module, response)`
function that will decode the response + return a dictionary. Some
modules handle the decode + error processing differently, so we should
defer to the module to handle this.
"""
resp = callback(self.module, self.full_get(url, params, **kwargs))
items = resp.get(array_name) if resp.get(array_name) else []
while resp.get(pageToken):
if params:
params['pageToken'] = resp.get(pageToken)
else:
params = {'pageToken': resp[pageToken]}

resp = callback(self.module, self.full_get(url, params, **kwargs))
if resp.get(array_name):
items = items + resp.get(array_name)
return items

# The following methods fully mimic the requests API and should be used.
def full_get(self, url, params=None, **kwargs):
kwargs['headers'] = self._set_headers(kwargs.get('headers'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']

return_value = {'resources': fetch_list(module, collection(module))}
items = fetch_list(module, collection(module))
if items.get('ingressRules'):
items = items.get('ingressRules')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -111,7 +116,8 @@ def collection(module):

def fetch_list(module, link):
auth = GcpSession(module, 'appengine')
return auth.list(link, return_if_object, array_name='ingressRules')
response = auth.get(link)
return return_if_object(module, response)


def return_if_object(module, response):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_bigquery_dataset_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']

return_value = {'resources': fetch_list(module, collection(module))}
items = fetch_list(module, collection(module))
if items.get('datasets'):
items = items.get('datasets')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -218,7 +223,8 @@ def collection(module):

def fetch_list(module, link):
auth = GcpSession(module, 'bigquery')
return auth.list(link, return_if_object, array_name='datasets')
response = auth.get(link)
return return_if_object(module, response)


def return_if_object(module, response):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_bigquery_table_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']

return_value = {'resources': fetch_list(module, collection(module))}
items = fetch_list(module, collection(module))
if items.get('tables'):
items = items.get('tables')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -556,7 +561,8 @@ def collection(module):

def fetch_list(module, link):
auth = GcpSession(module, 'bigquery')
return auth.list(link, return_if_object, array_name='tables')
response = auth.get(link)
return return_if_object(module, response)


def return_if_object(module, response):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']

return_value = {'resources': fetch_list(module, collection(module))}
items = fetch_list(module, collection(module))
if items.get('triggers'):
items = items.get('triggers')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -334,7 +339,8 @@ def collection(module):

def fetch_list(module, link):
auth = GcpSession(module, 'cloudbuild')
return auth.list(link, return_if_object, array_name='triggers')
response = auth.get(link)
return return_if_object(module, response)


def return_if_object(module, response):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']

return_value = {'resources': fetch_list(module, collection(module))}
items = fetch_list(module, collection(module))
if items.get('functions'):
items = items.get('functions')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -234,7 +239,8 @@ def collection(module):

def fetch_list(module, link):
auth = GcpSession(module, 'cloudfunctions')
return auth.list(link, return_if_object, array_name='functions')
response = auth.get(link)
return return_if_object(module, response)


def return_if_object(module, response):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_cloudscheduler_job_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']

return_value = {'resources': fetch_list(module, collection(module))}
items = fetch_list(module, collection(module))
if items.get('jobs'):
items = items.get('jobs')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -321,7 +326,8 @@ def collection(module):

def fetch_list(module, link):
auth = GcpSession(module, 'cloudscheduler')
return auth.list(link, return_if_object, array_name='jobs')
response = auth.get(link)
return return_if_object(module, response)


def return_if_object(module, response):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_cloudtasks_queue_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']

return_value = {'resources': fetch_list(module, collection(module))}
items = fetch_list(module, collection(module))
if items.get('queues'):
items = items.get('queues')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -226,7 +231,8 @@ def collection(module):

def fetch_list(module, link):
auth = GcpSession(module, 'cloudtasks')
return auth.list(link, return_if_object, array_name='queues')
response = auth.get(link)
return return_if_object(module, response)


def return_if_object(module, response):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_compute_address_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
items = fetch_list(module, collection(module), query_options(module.params['filters']))
if items.get('items'):
items = items.get('items')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -169,7 +174,8 @@ def collection(module):

def fetch_list(module, link, query):
auth = GcpSession(module, 'compute')
return auth.list(link, return_if_object, array_name='items', params={'filter': query})
response = auth.get(link, params={'filter': query})
return return_if_object(module, response)


def query_options(filters):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_compute_autoscaler_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
items = fetch_list(module, collection(module), query_options(module.params['filters']))
if items.get('items'):
items = items.get('items')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -234,7 +239,8 @@ def collection(module):

def fetch_list(module, link, query):
auth = GcpSession(module, 'compute')
return auth.list(link, return_if_object, array_name='items', params={'filter': query})
response = auth.get(link, params={'filter': query})
return return_if_object(module, response)


def query_options(filters):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
items = fetch_list(module, collection(module), query_options(module.params['filters']))
if items.get('items'):
items = items.get('items')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -152,7 +157,8 @@ def collection(module):

def fetch_list(module, link, query):
auth = GcpSession(module, 'compute')
return auth.list(link, return_if_object, array_name='items', params={'filter': query})
response = auth.get(link, params={'filter': query})
return return_if_object(module, response)


def query_options(filters):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
items = fetch_list(module, collection(module), query_options(module.params['filters']))
if items.get('items'):
items = items.get('items')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -389,7 +394,8 @@ def collection(module):

def fetch_list(module, link, query):
auth = GcpSession(module, 'compute')
return auth.list(link, return_if_object, array_name='items', params={'filter': query})
response = auth.get(link, params={'filter': query})
return return_if_object(module, response)


def query_options(filters):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_compute_disk_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
items = fetch_list(module, collection(module), query_options(module.params['filters']))
if items.get('items'):
items = items.get('items')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -312,7 +317,8 @@ def collection(module):

def fetch_list(module, link, query):
auth = GcpSession(module, 'compute')
return auth.list(link, return_if_object, array_name='items', params={'filter': query})
response = auth.get(link, params={'filter': query})
return return_if_object(module, response)


def query_options(filters):
Expand Down
10 changes: 8 additions & 2 deletions lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
items = fetch_list(module, collection(module), query_options(module.params['filters']))
if items.get('items'):
items = items.get('items')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -268,7 +273,8 @@ def collection(module):

def fetch_list(module, link, query):
auth = GcpSession(module, 'compute')
return auth.list(link, return_if_object, array_name='items', params={'filter': query})
response = auth.get(link, params={'filter': query})
return return_if_object(module, response)


def query_options(filters):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
items = fetch_list(module, collection(module), query_options(module.params['filters']))
if items.get('items'):
items = items.get('items')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -270,7 +275,8 @@ def collection(module):

def fetch_list(module, link, query):
auth = GcpSession(module, 'compute')
return auth.list(link, return_if_object, array_name='items', params={'filter': query})
response = auth.get(link, params={'filter': query})
return return_if_object(module, response)


def query_options(filters):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ def main():
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
items = fetch_list(module, collection(module), query_options(module.params['filters']))
if items.get('items'):
items = items.get('items')
else:
items = []
return_value = {'resources': items}
module.exit_json(**return_value)


Expand All @@ -169,7 +174,8 @@ def collection(module):

def fetch_list(module, link, query):
auth = GcpSession(module, 'compute')
return auth.list(link, return_if_object, array_name='items', params={'filter': query})
response = auth.get(link, params={'filter': query})
return return_if_object(module, response)


def query_options(filters):
Expand Down
Loading

0 comments on commit 6be6248

Please sign in to comment.