Skip to content

Commit

Permalink
Added type hints where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi05 committed Mar 26, 2019
1 parent b49e825 commit 789c9e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ScoutSuite/providers/gcp/facade/cloudsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ class CloudSQLFacade(Facade):
def __init__(self):
super(CloudSQLFacade, self).__init__('sqladmin', 'v1beta4')

async def get_backups(self, project_id, instance_name):
async def get_backups(self, project_id: str, instance_name: str):
cloudsql_client = self._get_client()
backups_group = cloudsql_client.backupRuns()
request = backups_group.list(project=project_id, instance=instance_name)
return await GCPFacadeUtils.get_all('items', request, backups_group)

async def get_database_instances(self, project_id):
async def get_database_instances(self, project_id: str):
cloudsql_client = self._get_client()
instances_group = cloudsql_client.instances()
request = instances_group.list(project=project_id)
return await GCPFacadeUtils.get_all('items', request, instances_group)

async def get_users(self, project_id, instance_name):
async def get_users(self, project_id: str, instance_name: str):
cloudsql_client = self._get_client()
response = await run_concurrently(
lambda: cloudsql_client.users().list(project=project_id, instance=instance_name).execute()
Expand Down
6 changes: 3 additions & 3 deletions ScoutSuite/providers/gcp/facade/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
from ScoutSuite.providers.gcp.facade.utils import GCPFacadeUtils

class Facade:
def __init__(self, client_name, client_version):
def __init__(self, client_name: str, client_version: str):
self._client_name = client_name
self._client_version = client_version
self._client = None

def _build_client(self):
def _build_client(self) -> discovery.Resource:
return discovery.build(self._client_name, self._client_version,
cache_discovery=False, cache=MemoryCache())

# Since the HTTP library used by the Google API Client library is not
# thread-safe, we need to create a new client for each request.
def _get_client(self):
def _get_client(self) -> discovery.Resource:
return self._build_client()
1 change: 0 additions & 1 deletion ScoutSuite/providers/gcp/facade/gcp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ScoutSuite.providers.gcp.facade.facade import Facade
from ScoutSuite.providers.gcp.facade.cloudsql import CloudSQLFacade
from ScoutSuite.providers.gcp.facade.utils import GCPFacadeUtils
Expand Down

0 comments on commit 789c9e9

Please sign in to comment.