### Install and run example scripts (Bash) Source: https://github.com/yandex-cloud/nodejs-sdk/blob/master/README.md Provides instructions on how to set up and execute example scripts for the Yandex.Cloud Node.js SDK. It involves navigating to the examples directory, installing dependencies, and running a script with necessary environment variables like YC_OAUTH_TOKEN and YC_FOLDER_ID. ```bash cd examples npm i YC_OAUTH_TOKEN=... YC_FOLDER_ID=... npm run start path/to/example.ts ``` -------------------------------- ### Initialize and use CloudServiceClient with OAuth Token (TypeScript) Source: https://github.com/yandex-cloud/nodejs-sdk/blob/master/README.md Demonstrates how to initialize the Yandex.Cloud SDK using an OAuth token for authentication. It shows creating a Session with the token, instantiating a service client (e.g., CloudServiceClient), and making an API request, such as listing clouds. ```typescript import { Session, cloudApi, serviceClients } from '@yandex-cloud/nodejs-sdk'; const { resourcemanager: { cloud_service: { ListCloudsRequest } } } = cloudApi; // Initialize SDK with your token const session = new Session({ oauthToken: 'YOUR_TOKEN' }); // Create service client const cloudService = session.client(serviceClients.CloudServiceClient); // Issue request (returns Promise) const response = await cloudService.list(ListCloudsRequest.fromPartial({ pageSize: 100, })); ``` -------------------------------- ### Initialize and use CloudServiceClient with IAM Token (TypeScript) Source: https://github.com/yandex-cloud/nodejs-sdk/blob/master/README.md Shows how to initialize the Yandex.Cloud SDK using an IAM token for authentication. This involves creating a Session with the provided IAM token, obtaining a service client, and executing an API call, such as listing clouds. ```typescript import { Session, cloudApi, serviceClients } from '@yandex-cloud/nodejs-sdk'; const { resourcemanager: { cloud_service: { ListCloudsRequest } } } = cloudApi; // Initialize SDK with your token const session = new Session({ iamToken: 'YOUR_TOKEN' }); // Create service client const cloudService = session.client(serviceClients.CloudServiceClient); // Issue request (returns Promise) const response = await cloudService.list(ListCloudsRequest.fromPartial({ pageSize: 100, })); ``` -------------------------------- ### Initialize and use CloudServiceClient with Metadata Service (TypeScript) Source: https://github.com/yandex-cloud/nodejs-sdk/blob/master/README.md Illustrates how to initialize the Yandex.Cloud SDK using the Metadata Service, typically when running code within Yandex.Cloud compute instances or functions. It shows creating a Session without explicit credentials, which defaults to using the metadata service, and then making an API request. ```typescript import { Session, cloudApi, serviceClients } from '@yandex-cloud/nodejs-sdk'; const { resourcemanager: { cloud_service: { ListCloudsRequest } } } = cloudApi; // Initialize SDK with your token const session = new Session(); // Create service client const cloudService = session.client(serviceClients.CloudServiceClient); // Issue request (returns Promise) const response = await cloudService.list(ListCloudsRequest.fromPartial({ pageSize: 100, })); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.