iam checks + storage checks
This commit is contained in:
@@ -14,7 +14,7 @@ from googleapiclient.errors import HttpError
|
||||
|
||||
|
||||
# [START iam_list_keys]
|
||||
def gcp_iam_list_keys(service_account_email,service):
|
||||
def gcp_iam_list_keys(service_account_email, service):
|
||||
"""Lists all keys for a service account."""
|
||||
|
||||
# pylint: disable=no-member
|
||||
@@ -27,7 +27,7 @@ def gcp_iam_list_keys(service_account_email,service):
|
||||
|
||||
|
||||
# [START iam_list_service_accounts]
|
||||
def gcp_iam_list_service_accounts(project_id):
|
||||
def gcp_iam_list_service_accounts(project_id, service):
|
||||
"""Lists all service accounts for the current project."""
|
||||
|
||||
# pylint: disable=no-member
|
||||
|
||||
39
libs/gcp/gcp_storage.py
Normal file
39
libs/gcp/gcp_storage.py
Normal file
@@ -0,0 +1,39 @@
|
||||
'''
|
||||
GCP Storage functions for WeirdAAL
|
||||
'''
|
||||
|
||||
import google.auth
|
||||
import googleapiclient.discovery
|
||||
import os
|
||||
import sys
|
||||
|
||||
from google.oauth2 import service_account
|
||||
|
||||
from googleapiclient.errors import HttpError
|
||||
|
||||
from google.cloud import storage, exceptions
|
||||
from google.cloud.exceptions import *
|
||||
|
||||
|
||||
|
||||
def gcp_storage_list_buckets(credentials):
|
||||
list_of_buckets = []
|
||||
'''list Google storage buckets for account'''
|
||||
storage_client = storage.Client()
|
||||
buckets = storage_client.list_buckets()
|
||||
for buck in buckets:
|
||||
print(buck.name)
|
||||
list_of_buckets.append(buck.name)
|
||||
return list_of_buckets
|
||||
|
||||
|
||||
def gcp_storage_list_blobs(credentials, bucket_name):
|
||||
'''Lists all the blobs in the bucket.'''
|
||||
storage_client = storage.Client()
|
||||
bucket = storage_client.get_bucket(bucket_name)
|
||||
|
||||
blobs = bucket.list_blobs()
|
||||
|
||||
for blob in blobs:
|
||||
print(blob.name)
|
||||
print('\n')
|
||||
Reference in New Issue
Block a user