We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, how to stop certian Compute Cloud from Yandex functions using this sdk?
The text was updated successfully, but these errors were encountered:
You can use InstanceService::stop and OperationService::get (to track operation completion).
Example code:
const yc = require('yandex-cloud'); const {InstanceService} = require('yandex-cloud/api/compute/v1'); const {OperationService} = require('yandex-cloud/api/operation'); const session = new yc.Session(); const instanceService = new InstanceService(session); const operationService = new OperationService(session); module.exports.handler = async function (event, context) { const instanceId = 'xxxxx'; let op = await instanceService.stop({ instanceId }); console.log(`op ${op.id} started`) while (!op.done) { op = await operationService.get({ operationId: op.id }); } console.log(`op ${op.id} finished, spent ${op.timeSpent()}ms`); if (op.error) { throw new Exception(`op ${op.id} failed: ${JSON.stringify(op)}`); } return op; }
Don't forget to assign service account for the functions and grant editor role to this service account in required folder.
editor
Sorry, something went wrong.
No branches or pull requests
Hello, how to stop certian Compute Cloud from Yandex functions using this sdk?
The text was updated successfully, but these errors were encountered: