| 80 | }; |
| 81 | |
| 82 | const createDiskSnapshot = async (projectId, zone, diskName, snapshotName) => { |
| 83 | const [response] = await disksClient.createSnapshot({ |
| 84 | project: projectId, |
| 85 | zone, |
| 86 | disk: diskName, |
| 87 | snapshotResource: { |
| 88 | name: snapshotName, |
| 89 | }, |
| 90 | }); |
| 91 | let operation = response.latestResponse; |
| 92 | const operationsClient = new compute.ZoneOperationsClient(); |
| 93 | |
| 94 | while (operation.status !== 'DONE') { |
| 95 | [operation] = await operationsClient.wait({ |
| 96 | operation: operation.name, |
| 97 | project: projectId, |
| 98 | zone: operation.zone.split('/').pop(), |
| 99 | }); |
| 100 | } |
| 101 | }; |
| 102 | |
| 103 | const deleteDiskSnapshot = async (projectId, snapshotName) => { |
| 104 | const [response] = await snapshotsClient.delete({ |