File tree Expand file tree Collapse file tree
libcloudforensics/providers/gcp/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -237,6 +237,33 @@ def ListInstances(self) -> Dict[str, 'GoogleComputeInstance']:
237237
238238 return instances
239239
240+ def ListSnapshots (self , filter_string : str | None = None ) -> Dict [str , Any ]:
241+ """List snapshots in project.
242+
243+ Args:
244+ filter_string: Filter for the snapshot query.
245+
246+ Returns:
247+ Dict[str, Any]: Dictionary mapping snapshot IDs (str)
248+ to their respective snapshot description.
249+ See:
250+ https://docs.cloud.google.com/compute/docs/reference/rest/v1/snapshots/list
251+ """
252+ snapshots = {}
253+ gce_snapshot_client = self .GceApi ().snapshots () # pylint: disable=no-member
254+ responses = common .ExecuteRequest (
255+ gce_snapshot_client ,
256+ 'list' ,
257+ {'project' : self .project_id , 'filter' : filter_string },
258+ )
259+
260+ for response in responses :
261+ for snapshot in response .get ('items' , []):
262+ name = snapshot ['name' ]
263+ snapshots [name ] = snapshot
264+
265+ return snapshots
266+
240267 def ListMIGSByInstanceName (self , location : str ) -> Dict [str , str ]:
241268 """Gets a mapping from instance names to their managed instance group.
242269
You can’t perform that action at this time.
0 commit comments