Skip to content
New issue

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

V2.0 #63

Merged
merged 83 commits into from
Apr 1, 2022
Merged

V2.0 #63

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
4e90a92
fix: remove unused test module
Dec 15, 2021
55bf685
feat: restructure directories
Dec 15, 2021
99e8ba8
feat: rewrite index module in ts
Dec 15, 2021
7916612
feat: added git submodule with yandex cloud api specs
Dec 15, 2021
a5ecb33
feat: remove old generated code
Dec 15, 2021
e097134
fix: eslint rule
Dec 20, 2021
b463cf8
feat: tool for code generation
Dec 20, 2021
78c2355
feat: endpoints list for all available service clients
Dec 20, 2021
b38248c
fix: move legacy code to separate directory
Dec 21, 2021
8b730df
feat: token services
Dec 21, 2021
1e2dcc2
feat: regenerate code with new ts-proto
Dec 21, 2021
826e6de
feat: session class
Dec 22, 2021
e82e279
feat: operation utilities
Dec 22, 2021
9cbffe1
test: fix unit tests
Dec 22, 2021
3d3a6f2
feat: remove unused legacy code and dependencies
Dec 22, 2021
438f7c6
fix: move to axios
Dec 22, 2021
5136bb5
feat: generate exports for all entities in cloud api
Dec 23, 2021
2875275
feat: reworked examples
Dec 24, 2021
a20a650
fix: update ts-proto
Dec 24, 2021
718d836
style: conventional commits as pre-commit hooks
Dec 24, 2021
549c9aa
ci: semantic-release
Dec 24, 2021
4919d54
fix: disable husky hooks in CI
Dec 24, 2021
76cf6e7
fix: use bot's token for pushing release commits
Dec 24, 2021
3b2553a
fix: use bot's name/email for pushing release commits
Dec 24, 2021
90be359
ci: option to override persist-credentials in checkout action
Dec 24, 2021
8cae8f3
ci: do not persist credential during checkout
Dec 24, 2021
0dfcbba
Merge pull request #48 from yandex-cloud/CLOUD-86841
DavyJohnes Dec 24, 2021
ad72226
ci: do not run build on npm install
Dec 24, 2021
9846795
chore(release): 2.0.0-alpha.1 [skip ci]
yandex-cloud-bot Dec 24, 2021
e9edd44
ci: do not run build on npm install
Dec 24, 2021
dd54f4a
docs: update Readme
Dec 27, 2021
ba00fbc
fixup! docs: update Readme
Dec 27, 2021
a8c7c00
ci: allow to run checks in alpha/beta branches
Dec 27, 2021
ce2d49f
Merge pull request #49 from yandex-cloud/CLOUD-86841
DavyJohnes Dec 27, 2021
10c9409
fix: removed legacy example
Dec 27, 2021
fc61cf7
Merge pull request #51 from yandex-cloud/CLOUD-86841
DavyJohnes Dec 27, 2021
8968643
chore(release): 2.0.0-alpha.2 [skip ci]
yandex-cloud-bot Dec 27, 2021
f69248b
ci: install node_modules if cache miss
Dec 29, 2021
6d43e36
ci: install node_modules in checkout-and-install action
Dec 29, 2021
1805e9d
fixup! ci: install node_modules in checkout-and-install action
Dec 29, 2021
33e9e10
Merge pull request #52 from yandex-cloud/CLOUD-86841
DavyJohnes Dec 29, 2021
ab4ab37
ci: update checkout-and-install action in release workflow
Dec 29, 2021
2f424d6
fixup! ci: update checkout-and-install action in release workflow
Dec 29, 2021
a6dc0f4
Merge pull request #53 from yandex-cloud/CLOUD-86841
DavyJohnes Dec 29, 2021
bec2aca
feat: export generic type of wrapped service client
Jan 12, 2022
a712923
fix: correct logging service endpoints
Jan 12, 2022
12e118e
feat: allow to override endpoint in service factory
Jan 12, 2022
2c76c40
Merge pull request #54 from yandex-cloud/CLOUD-86841
DavyJohnes Jan 12, 2022
ad3408b
chore(release): 2.0.0-alpha.3 [skip ci]
yandex-cloud-bot Jan 12, 2022
7120858
fix: install long package
Jan 13, 2022
0ef6ca8
Merge pull request #57 from yandex-cloud/CLOUD-86841
DavyJohnes Jan 13, 2022
6e2c64b
chore(release): 2.0.0-alpha.4 [skip ci]
yandex-cloud-bot Jan 13, 2022
795d541
refactor: rename npm package to @yandex-cloud/nodejs-sdk
Jan 20, 2022
1a90dc6
Merge pull request #58 from yandex-cloud/CLOUD-86841
DavyJohnes Jan 20, 2022
e9ecf16
feat: change package description
Jan 20, 2022
9a90298
Merge pull request #59 from yandex-cloud/CLOUD-86841
DavyJohnes Jan 20, 2022
9deb1db
chore(release): 2.0.0-alpha.5 [skip ci]
yandex-cloud-bot Jan 20, 2022
a68360d
fix: set public access for npm package
Jan 20, 2022
ed5afb6
Merge pull request #60 from yandex-cloud/CLOUD-86841
DavyJohnes Jan 20, 2022
a30fcec
chore(release): 2.0.0-alpha.6 [skip ci]
yandex-cloud-bot Jan 20, 2022
6a462d9
refactor: update readme
Jan 20, 2022
b564178
fix: use exact versions of dependencies
Jan 20, 2022
ef3857e
Merge pull request #61 from yandex-cloud/CLOUD-86841
DavyJohnes Jan 20, 2022
a5ecdb7
chore(release): 2.0.0-alpha.7 [skip ci]
yandex-cloud-bot Jan 20, 2022
29fc31f
docs: update examples
Jan 20, 2022
280ce25
Merge pull request #62 from yandex-cloud/CLOUD-86841
DavyJohnes Jan 20, 2022
8dc3835
Merge pull request #50 from yandex-cloud/alpha
DavyJohnes Jan 20, 2022
4668978
chore(release): 2.0.0-beta.1 [skip ci]
yandex-cloud-bot Jan 20, 2022
22ea100
feat: update nice-grpc
Feb 16, 2022
19129f3
fix: use serviceName property of client ctor
Feb 16, 2022
9367aba
Merge pull request #67 from yandex-cloud/CLOUD-86841
DavyJohnes Feb 16, 2022
891b4b7
chore(release): 2.0.0-beta.2 [skip ci]
yandex-cloud-bot Feb 16, 2022
34d2592
docs(examples): add example of using the SDK with streaming endpoint
nikolaymatrosov Feb 8, 2022
a652267
docs(examples): update example of using the SDK with streaming endpoint
nikolaymatrosov Feb 28, 2022
2636b07
docs(examples): update sdk version in examples
nikolaymatrosov Feb 28, 2022
b968085
docs(examples): added instruction to `README.md` on how to run examples
nikolaymatrosov Feb 28, 2022
db7c199
Merge pull request #65 from nikolaymatrosov/example/stream-stt
DavyJohnes Feb 28, 2022
215fab1
feat: update @grpc/grpc-js
DavyJohnes Apr 1, 2022
835381c
feat: updated services definitions
DavyJohnes Apr 1, 2022
ad52e6f
feat: increase max memory level for build
DavyJohnes Apr 1, 2022
5ed9592
fixup! feat: increase max memory level for build
DavyJohnes Apr 1, 2022
60c9ffe
Merge pull request #70 from yandex-cloud/CLOUD-86841
DavyJohnes Apr 1, 2022
3143b4d
chore(release): 2.0.0-beta.3 [skip ci]
yandex-cloud-bot Apr 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@commitlint/config-conventional"
]
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/generated/**
13 changes: 11 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"unicorn/prefer-node-protocol": "off",
"class-methods-use-this": "off",
"@typescript-eslint/no-unused-vars": "off",
"import/no-extraneous-dependencies": "off",
"import/prefer-default-export": "off",
"comma-dangle": ["error", "always-multiline"],
"indent": "off",
Expand All @@ -41,6 +40,16 @@
"newline-after-var": "error",
"newline-before-return": "error",
"no-plusplus": "off",
"unicorn/import-style": "off"
"unicorn/import-style": "off",
"@typescript-eslint/no-var-requires": "off",
"no-underscore-dangle": ["error", {
"allowAfterThis": true,
"allowAfterSuper": false
}],
"unicorn/no-null": "off",
"import/no-extraneous-dependencies": ["error", {
"devDependencies": true
}],
"import/no-cycle": "off"
}
}
16 changes: 14 additions & 2 deletions .github/actions/checkout-and-install-node/action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
name: 'Checkout from VCS and install NodeJS from .nvmrc'
name: 'checkout-and-install-node'
description: 'Checkout from VCS and install NodeJS from .nvmrc'
inputs:
persist-credentials:
description: 'Whether to configure the token or SSH key with the local git config'
required: false
default: 'true'
runs:
using: 'composite'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: ${{ inputs.persist-credentials }}
- uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- uses: actions/cache@v2
id: cache
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Install Depencendies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
shell: bash
16 changes: 5 additions & 11 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,21 @@ on:
pull_request:
branches:
- master
- alpha
- beta
jobs:
install:
runs-on: ubuntu-20.04
steps:
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@4a0dbbde6b45cce08566abb9accace703f2a7a5d
- run: npm ci
tests:
runs-on: ubuntu-20.04
needs: install
steps:
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@4a0dbbde6b45cce08566abb9accace703f2a7a5d
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@f69248b52b7991214847e889f28ba0883ed0ca2c
- run: npm run test
lint:
runs-on: ubuntu-20.04
needs: install
steps:
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@4a0dbbde6b45cce08566abb9accace703f2a7a5d
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@f69248b52b7991214847e889f28ba0883ed0ca2c
- run: npm run lint
build:
runs-on: ubuntu-20.04
needs: install
steps:
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@4a0dbbde6b45cce08566abb9accace703f2a7a5d
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@f69248b52b7991214847e889f28ba0883ed0ca2c
- run: npm run build
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release
on:
push:
branches:
- master
- alpha
- beta
jobs:
release:
if: github.actor != 'yandex-cloud-bot'
name: Release
runs-on: ubuntu-20.04
steps:
- uses: yandex-cloud/nodejs-sdk/.github/actions/checkout-and-install-node@f69248b52b7991214847e889f28ba0883ed0ca2c
with:
persist-credentials: false
- env:
GITHUB_TOKEN: ${{ secrets.YANDEX_CLOUD_BOT_TOKEN }}
GIT_AUTHOR_NAME: yandex-cloud-bot
GIT_AUTHOR_EMAIL: ycloud-bot@yandex.ru
GIT_COMMITTER_NAME: yandex-cloud-bot
GIT_COMMITTER_EMAIL: ycloud-bot@yandex.ru
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx --no-install semantic-release
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cloudapi"]
path = cloudapi
url = git@github.com:yandex-cloud/cloudapi.git
6 changes: 6 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
[ -n "$CI" ] && exit 0

. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit "$1"
20 changes: 20 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"branches": [
"master",
{
"name": "beta",
"prerelease": "beta"
},
{
"name": "alpha",
"prerelease": "alpha"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
}
117 changes: 83 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,132 @@
# 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)
[![CircleCI](https://img.shields.io/circleci/build/gh/yandex-cloud/nodejs-sdk/master)](https://circleci.com/gh/yandex-cloud/nodejs-sdk/tree/master)
[![npm](https://img.shields.io/npm/v/@yandex-cloud/nodejs-sdk.svg)](https://www.npmjs.com/package/@yandex-cloud/nodejs-sdk)
[![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/nodejs-sdk`

## 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/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 = 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/nodejs-sdk';

// 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/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 = 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.

To run example scripts, you should execute the following commands:
```bash
cd examples
npm i
YC_OAUTH_TOKEN=... YC_FOLDER_ID=... npm run start path/to/example.ts
```

## 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.
Loading