Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions libcloudforensics/providers/gcp/internal/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,33 @@ def ListInstances(self) -> Dict[str, 'GoogleComputeInstance']:

return instances

def ListSnapshots(self, filter_string: str | None = None) -> Dict[str, Any]:
"""List snapshots in project.

Args:
filter_string: Filter for the snapshot query.

Returns:
Dict[str, Any]: Dictionary mapping snapshot IDs (str)
to their respective snapshot description.
See:
https://docs.cloud.google.com/compute/docs/reference/rest/v1/snapshots/list
"""
snapshots = {}
gce_snapshot_client = self.GceApi().snapshots() # pylint: disable=no-member
responses = common.ExecuteRequest(
gce_snapshot_client,
'list',
{'project': self.project_id, 'filter': filter_string},
)

for response in responses:
for snapshot in response.get('items', []):
name = snapshot['name']
snapshots[name] = snapshot

return snapshots

def ListMIGSByInstanceName(self, location: str) -> Dict[str, str]:
"""Gets a mapping from instance names to their managed instance group.

Expand Down
Loading