(primaryDiskName, primaryLocation)
| 17 | 'use strict'; |
| 18 | |
| 19 | async function main(primaryDiskName, primaryLocation) { |
| 20 | // [START compute_disk_stop_replication] |
| 21 | // Import the Compute library |
| 22 | const computeLib = require('@google-cloud/compute'); |
| 23 | |
| 24 | // Instantiate a diskClient |
| 25 | const disksClient = new computeLib.DisksClient(); |
| 26 | // Instantiate a zoneOperationsClient |
| 27 | const zoneOperationsClient = new computeLib.ZoneOperationsClient(); |
| 28 | |
| 29 | /** |
| 30 | * TODO(developer): Update/uncomment these variables before running the sample. |
| 31 | */ |
| 32 | // The project that contains the primary disk. |
| 33 | const primaryProjectId = await disksClient.getProjectId(); |
| 34 | |
| 35 | // The zone of the primary disk. |
| 36 | // primaryLocation = 'us-central1-a'; |
| 37 | |
| 38 | // The name of the primary disk. |
| 39 | // primaryDiskName = 'primary-disk-name'; |
| 40 | |
| 41 | // Stop replication |
| 42 | async function callStopReplication() { |
| 43 | const [response] = await disksClient.stopAsyncReplication({ |
| 44 | project: primaryProjectId, |
| 45 | zone: primaryLocation, |
| 46 | disk: primaryDiskName, |
| 47 | }); |
| 48 | |
| 49 | let operation = response.latestResponse; |
| 50 | |
| 51 | // Wait for the operation to complete. |
| 52 | while (operation.status !== 'DONE') { |
| 53 | [operation] = await zoneOperationsClient.wait({ |
| 54 | operation: operation.name, |
| 55 | project: primaryProjectId, |
| 56 | zone: operation.zone.split('/').pop(), |
| 57 | }); |
| 58 | } |
| 59 | |
| 60 | console.log(`Replication for primary disk: ${primaryDiskName} stopped.`); |
| 61 | } |
| 62 | |
| 63 | await callStopReplication(); |
| 64 | // [END compute_disk_stop_replication] |
| 65 | } |
| 66 | |
| 67 | main(...process.argv.slice(2)).catch(err => { |
| 68 | console.error(err); |
no test coverage detected