From e9edd446c49d28a41be39da8b18f4845f4b7dfc2 Mon Sep 17 00:00:00 2001 From: Ivan Zuev Date: Fri, 24 Dec 2021 19:07:08 +0300 Subject: [PATCH 1/4] ci: do not run build on npm install (cherry picked from commit ad72226fe7a2dcf7c0011d83bc52fd5eb8c97ce0) --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c29930c..183f2471 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,8 @@ "lint": "eslint src config", "build": "tsc -p .", "generate-code": "ts-node scripts/generate-code.ts", - "prepare": "husky install && npm run build" + "prepare": "husky install", + "prepublishOnly": "npm run build" }, "engines": { "node": ">=10.0.0" From dd54f4a0b1da37cd99f16acc42f0e2fb89c0f9c7 Mon Sep 17 00:00:00 2001 From: Ivan Zuev Date: Mon, 27 Dec 2021 16:06:18 +0300 Subject: [PATCH 2/4] docs: update Readme --- README.md | 106 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 74 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 36dc3180..e9e6e2df 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,125 @@ # Yandex.Cloud SDK (node.js) [![npm](https://img.shields.io/npm/v/yandex-cloud.svg)](https://www.npmjs.com/package/yandex-cloud) -[![CircleCI](https://img.shields.io/circleci/build/gh/yandex-cloud/nodejs-sdk/master)](https://circleci.com/gh/yandex-cloud/nodejs-sdk/tree/master) [![License](https://img.shields.io/github/license/yandex-cloud/nodejs-sdk.svg)](https://github.com/yandex-cloud/nodejs-sdk/blob/master/LICENSE) Need to automate your infrastructure or use services provided by Yandex.Cloud? We've got you covered. -Installation: +## Requirements +- nodejs >= 10 - npm install yandex-cloud - -Library requires at least node.js 10 and provides TypeScript declarations. +## Installation +`npm install yandex-cloud` ## Getting started -There are two options for authorization your requests - OAuth Token -and Metadata Service (if you're executing code inside VMs or Functions +There are three options for authorization your requests: +- [OAuth Token](https://cloud.yandex.com/en-ru/docs/iam/concepts/authorization/oauth-token) +- [IAM token](https://cloud.yandex.com/en-ru/docs/iam/operations/iam-token/create) +- [Metadata Service](https://cloud.yandex.com/en-ru/docs/compute/concepts/vm-metadata) (if you're executing code inside VMs or Functions running in Yandex.Cloud) ### OAuth Token -```javascript -const {Session} = require('yandex-cloud'); -const {CloudService} = require('yandex-cloud/api/resourcemanager/v1'); +```typescript +import { Session, cloudApi, serviceClients } from 'yandex-cloud'; + +const { resourcemanager: { cloud_service: { ListCloudsRequest } } } = cloudApi; // Initialize SDK with your token const session = new Session({ oauthToken: 'YOUR_TOKEN' }); // Create service client -const cloudService = new CloudService(session); +const cloudService = session.client(serviceClients.CloudServiceClient); // Issue request (returns Promise) -let response = await cloudService.list({}); +const response = await cloudService.list(ListCloudsRequest.fromPartial({ + pageSize: 100, +})); ``` ### Metadata Service Don't forget to assign Service Account for your Instance or Function. -```javascript -const {CloudService} = require('yandex-cloud/api/resourcemanager/v1'); +```typescript +import { Session, cloudApi, serviceClients } from 'yandex-cloud'; -// Create service client (auth token will be fetched from metadata service -const cloudService = new CloudService(); +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) -let response = await cloudService.list({}); +const response = await cloudService.list(ListCloudsRequest.fromPartial({ + pageSize: 100, +})); ``` ### IAM Token -```javascript -const {Session} = require('yandex-cloud'); -const {CloudService} = require('yandex-cloud/api/resourcemanager/v1'); +```typescript +import { Session, cloudApi, serviceClients } from 'yandex-cloud'; + +const { resourcemanager: { cloud_service: { ListCloudsRequest } } } = cloudApi; // Initialize SDK with your token const session = new Session({ iamToken: 'YOUR_TOKEN' }); // Create service client -const cloudService = new CloudService(session); +const cloudService = session.client(serviceClients.CloudServiceClient); // Issue request (returns Promise) -let response = await cloudService.list({}); +const response = await cloudService.list(ListCloudsRequest.fromPartial({ + pageSize: 100, +})); ``` -Check `examples` directory for more examples. +Check [examples](./examples) directory for more examples. ## Services -* Resource Manager; -* Identity and Access Management (IAM); -* Compute Cloud; -* Container Registry; -* Managed Services for Kubernetes; -* Key Management Service (KMS); -* Load Balancer; -* Cloud Functions; -* Virtual Private Cloud (VPC); * AI Translate; * AI Vision. +* Application Load Balancer +* Billing +* Cloud CDN +* Certificate Manager +* Compute Cloud +* Container Registry +* Data Proc +* DataSphere +* Data Transfer +* DNS +* Identity and Access Management (IAM) +* IoT Core +* Managed Service for Kubernetes +* Key Management Service (KMS) +* Load Balancer +* Lockbox +* Logging +* Managed DataBase + * ClickHouse + * ElasticSearch + * Greenplum + * Kafka + * MongoDB + * MySQL + * PostgreSQL + * Redis + * MS SQL Server +* Organization Manager +* Resource Manager +* Serverless + * Functions + * API Gateway + * Containers + * Triggers + * MDB Proxy +* Virtual Private Cloud (VPC) +* Yandex Database (YDB) If you need generated client for other Yandex.Cloud services, just open an issue. From ba00fbc616c29ddba32459b5f744634cac78100d Mon Sep 17 00:00:00 2001 From: Ivan Zuev Date: Mon, 27 Dec 2021 16:08:42 +0300 Subject: [PATCH 3/4] fixup! docs: update Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9e6e2df..a1c660c1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Yandex.Cloud SDK (node.js) +# Yandex.Cloud SDK (nodejs) [![npm](https://img.shields.io/npm/v/yandex-cloud.svg)](https://www.npmjs.com/package/yandex-cloud) [![License](https://img.shields.io/github/license/yandex-cloud/nodejs-sdk.svg)](https://github.com/yandex-cloud/nodejs-sdk/blob/master/LICENSE) From a8c7c00c1dc9be883263e26e3f1a53cc0ca41504 Mon Sep 17 00:00:00 2001 From: Ivan Zuev Date: Mon, 27 Dec 2021 16:32:09 +0300 Subject: [PATCH 4/4] ci: allow to run checks in alpha/beta branches --- .github/workflows/pr-checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index b1ee1cc0..cf181166 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -3,6 +3,8 @@ on: pull_request: branches: - master + - alpha + - beta jobs: install: runs-on: ubuntu-20.04