diff options
author | y4blokof <y4blokof@yandex-team.com> | 2023-10-18 13:55:49 +0300 |
---|---|---|
committer | y4blokof <y4blokof@yandex-team.com> | 2023-10-18 14:38:13 +0300 |
commit | 7276668051a77939862618cf8034d775bef336ac (patch) | |
tree | 6e89597dcd961736215a79811e8e564fc5ba9db7 | |
parent | 33164cf11158c0b00c25e1e6ba78ccee0cbd807a (diff) | |
download | ydb-7276668051a77939862618cf8034d775bef336ac.tar.gz |
Actualize YDB-DOTNET-SDK docs
14 files changed, 278 insertions, 0 deletions
diff --git a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-access-token.md b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-access-token.md index 58ffe230ef..857ffa2393 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-access-token.md +++ b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-access-token.md @@ -120,6 +120,33 @@ Below are examples of the code for authentication using a token in different {{ {% include [auth-access-token](../../../../_includes/nodejs/auth-access-token.md) %} +- Python + + {% include [auth-access-token](../../../../_includes/python/auth-access-token.md) %} + +- Python (asyncio) + + {% include [auth-access-token](../../../../_includes/python/async/auth-access-token.md) %} + +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Auth; + + const string endpoint = "grpc://localhost:2136"; + const string database = "/local"; + const string token = "MY_VERY_SECURE_TOKEN"; + + var config = new DriverConfig( + endpoint: endpoint, + database: database, + credentials: new TokenProvider(token) + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-anonymous.md b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-anonymous.md index 973beb68af..89d9f7716f 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-anonymous.md +++ b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-anonymous.md @@ -93,6 +93,32 @@ Below are examples of the code for anonymous authentication in different {{ ydb- {% include [auth-anonymous](../../../../_includes/nodejs/auth-anonymous.md) %} +- Python + + {% include [auth-anonymous](../../../../_includes/python/auth-anonymous.md) %} + +- Python (asyncio) + + {% include [auth-anonymous](../../../../_includes/python/async/auth-anonymous.md) %} + +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Auth; + + const string endpoint = "grpc://localhost:2136"; + const string database = "/local"; + + var config = new DriverConfig( + endpoint: endpoint, + database: database, + credentials: new AnonymousProvider() + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-env.md b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-env.md index 2ea42247c5..e2a34b6915 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-env.md +++ b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-env.md @@ -104,6 +104,18 @@ Below are examples of the code for authentication using environment variables in {% include [auth-env](../../../../_includes/nodejs/auth-env.md) %} +- Python + + {% include [auth-env](../../../../_includes/python/auth-env.md) %} + +- Python (asyncio) + + {% include [auth-env](../../../../_includes/python/async/auth-env.md) %} + +- C# + + {% include [work in progress message](_includes/addition.md) %} + - PHP ```php diff --git a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-metadata.md b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-metadata.md index 790eceaf91..9f2284d3de 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-metadata.md +++ b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-metadata.md @@ -94,6 +94,34 @@ Below are examples of the code for authentication using environment variables in {% include [auth-metadata](../../../../_includes/nodejs/auth-metadata.md) %} +- Python + + {% include [auth-metadata](../../../../_includes/python/auth-metadata.md) %} + +- Python (asyncio) + + {% include [auth-metadata](../../../../_includes/python/async/auth-metadata.md) %} + +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Yc; + + var metadataProvider = new MetadataProvider(); + + // Await initial IAM token. + await metadataProvider.Initialize(); + + var config = new DriverConfig( + endpoint: endpoint, // Database endpoint, "grpcs://host:port" + database: database, // Full database path + credentials: metadataProvider + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-service-account.md b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-service-account.md index 6682caafdf..e911cf4686 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-service-account.md +++ b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-service-account.md @@ -104,6 +104,37 @@ Below are examples of the code for authentication using a service account file i {% include [auth-sa-data](../../../../_includes/nodejs/auth-sa-data.md) %} +- Python + + {% include [auth-sa-data](../../../../_includes/python/auth-service-account.md) %} + +- Python (asyncio) + + {% include [auth-sa-data](../../../../_includes/python/async/auth-service-account.md) %} + +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Yc; + + const string endpoint = "grpc://localhost:2136"; + const string database = "/local"; + + var saProvider = new ServiceAccountProvider( + saFilePath: "path/to/sa_file.json" // Path to file with service account JSON info); + ); + await saProvider.Initialize(); + + var config = new DriverConfig( + endpoint: endpoint, + database: database, + credentials: saProvider + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md index 12e01ea91a..4e226db001 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md +++ b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md @@ -65,6 +65,32 @@ Below are examples of the code for authentication based on a username and token {% include [auth-static](../../../../_includes/nodejs/auth-static.md) %} +- Python + + {% include [auth-static](../../../../_includes/python/auth-static.md) %} + +- Python (asyncio) + + {% include [auth-static](../../../../_includes/python/async/auth-static.md) %} + +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Auth; + + const string endpoint = "grpc://localhost:2136"; + const string database = "/local"; + + var config = new DriverConfig( + endpoint: endpoint, // Database endpoint, "grpcs://host:port" + database: database, // Full database path + credentials: new StaticCredentialsProvider(user, password) + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/en/core/reference/ydb-sdk/recipes/init.md b/ydb/docs/en/core/reference/ydb-sdk/recipes/init.md index 1ae8442434..2073cd35bf 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/recipes/init.md +++ b/ydb/docs/en/core/reference/ydb-sdk/recipes/init.md @@ -98,6 +98,19 @@ Below are examples of the code for connecting to {{ ydb-short-name }} (driver cr {% include [work in progress message](_includes/addition.md) %} +- C# (.NET) + + ```C# + using Ydb.Sdk; + + var config = new DriverConfig( + endpoint: "grpc://localhost:2136", + database: "/local" + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-access-token.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-access-token.md index 25b44e725c..11b85db1e2 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-access-token.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-access-token.md @@ -128,6 +128,25 @@ {% include [auth-access-token](../../../../_includes/python/async/auth-access-token.md) %} +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Auth; + + const string endpoint = "grpc://localhost:2136"; + const string database = "/local"; + const string token = "MY_VERY_SECURE_TOKEN"; + + var config = new DriverConfig( + endpoint: endpoint, + database: database, + credentials: new TokenProvider(token) + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-anonymous.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-anonymous.md index 1c5ed15b8f..939290cdd5 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-anonymous.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-anonymous.md @@ -101,6 +101,24 @@ {% include [auth-anonymous](../../../../_includes/python/async/auth-anonymous.md) %} +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Auth; + + const string endpoint = "grpc://localhost:2136"; + const string database = "/local"; + + var config = new DriverConfig( + endpoint: endpoint, + database: database, + credentials: new AnonymousProvider() + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-env.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-env.md index 95e92e5b31..5d53ec6fbe 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-env.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-env.md @@ -114,6 +114,10 @@ description: "В разделе приведены примеры кода ау {% include [auth-env](../../../../_includes/python/async/auth-env.md) %} +- C# + + {% include [work in progress message](_includes/addition.md) %} + - PHP ```php diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-metadata.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-metadata.md index badc2daca9..2387657381 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-metadata.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-metadata.md @@ -102,6 +102,26 @@ {% include [auth-metadata](../../../../_includes/python/async/auth-metadata.md) %} +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Yc; + + var metadataProvider = new MetadataProvider(); + + // Await initial IAM token. + await metadataProvider.Initialize(); + + var config = new DriverConfig( + endpoint: endpoint, // Database endpoint, "grpcs://host:port" + database: database, // Full database path + credentials: metadataProvider + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-service-account.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-service-account.md index 3ed5c1bf4f..bb8018bc90 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-service-account.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-service-account.md @@ -112,6 +112,29 @@ {% include [auth-sa-data](../../../../_includes/python/async/auth-service-account.md) %} +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Yc; + + const string endpoint = "grpc://localhost:2136"; + const string database = "/local"; + + var saProvider = new ServiceAccountProvider( + saFilePath: "path/to/sa_file.json" // Path to file with service account JSON info); + ); + await saProvider.Initialize(); + + var config = new DriverConfig( + endpoint: endpoint, + database: database, + credentials: saProvider + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-static.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-static.md index d5dff25981..db0dcd6c09 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-static.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-static.md @@ -73,6 +73,24 @@ {% include [auth-static](../../../../_includes/python/async/auth-static.md) %} +- C# (.NET) + + ```C# + using Ydb.Sdk; + using Ydb.Sdk.Auth; + + const string endpoint = "grpc://localhost:2136"; + const string database = "/local"; + + var config = new DriverConfig( + endpoint: endpoint, // Database endpoint, "grpcs://host:port" + database: database, // Full database path + credentials: new StaticCredentialsProvider(user, password) + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/init.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/init.md index 43d48c3bb2..7cfb2ec13c 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/init.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/init.md @@ -121,6 +121,19 @@ description: "В статье приведены примеры кода под asyncio.run(ydb_init()) ``` +- C# (.NET) + + ```C# + using Ydb.Sdk; + + var config = new DriverConfig( + endpoint: "grpc://localhost:2136", + database: "/local" + ); + + await using var driver = await Driver.CreateInitialized(config); + ``` + - PHP ```php |