in enableDetective.py [0:0]
def get_graphs(d_client: botocore.client.BaseClient) -> typing.List[str]:
"""
Get graphs in a specified region.
Args:
- d_client: Detective boto3 client generated from the master session.
Returns:
List of graph Arns.
"""
try:
response = d_client.list_graphs()
except botocore.exceptions.EndpointConnectionError:
logging.exception(f'exception: {e}')
return []
# use .get function to avoid KeyErrors when a dictionary key doesn't exist
# it returns an empty list instead.
# map iterates over all elements under a list and applied a function to them,
# in this specific case, the element 'Arn' is extracted from the dictionary
# (graphlist is a list of dictionaries)
return [x['Arn'] for x in response.get('GraphList', [])]