in source/ecs/workspaces_helper.py [0:0]
def get_workspaces_for_directory(self, directory_id):
"""
:param: AWS region
:return: List of workspaces for a given directory.
This method returns the list of AWS directories in the given region.
"""
log.debug("Getting the workspace for the directory {}".format(directory_id))
list_workspaces = []
try:
response = self.workspaces_client.describe_workspaces(
DirectoryId=directory_id
)
list_workspaces = response.get('Workspaces', [])
next_token = response.get('NextToken', None)
while next_token is not None:
response = self.workspaces_client.describe_workspaces(
DirectoryId=directory_id,
NextToken=next_token
)
list_workspaces.extend(response.get('Workspaces', []))
next_token = response.get('NextToken', None)
except botocore.exceptions.ClientError as e:
log.error(
"Error while getting the list of workspace for directory ID {}. Error: {}".format(directory_id, e))
log.debug("Returning the list of directories as {}".format(list_workspaces))
return list_workspaces