|
1 | | -import os |
2 | | - |
3 | 1 | from . import pool, scheme, table |
4 | 2 | import ydb |
5 | 3 | from .. import _utilities |
6 | | -from ydb.driver import get_config |
7 | | - |
8 | | - |
9 | | -def default_credentials(credentials=None): |
10 | | - if credentials is not None: |
11 | | - return credentials |
12 | | - |
13 | | - service_account_key_file = os.getenv("YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS") |
14 | | - if service_account_key_file is not None: |
15 | | - from .iam import ServiceAccountCredentials |
16 | | - |
17 | | - return ServiceAccountCredentials.from_file(service_account_key_file) |
18 | | - |
19 | | - anonymous_credetials = os.getenv("YDB_ANONYMOUS_CREDENTIALS", "0") == "1" |
20 | | - if anonymous_credetials: |
21 | | - return ydb.credentials.AnonymousCredentials() |
22 | | - |
23 | | - metadata_credentials = os.getenv("YDB_METADATA_CREDENTIALS", "0") == "1" |
24 | | - if metadata_credentials: |
25 | | - from .iam import MetadataUrlCredentials |
26 | | - |
27 | | - return MetadataUrlCredentials() |
28 | | - |
29 | | - access_token = os.getenv("YDB_ACCESS_TOKEN_CREDENTIALS") |
30 | | - if access_token is not None: |
31 | | - return ydb.credentials.AccessTokenCredentials(access_token) |
32 | | - |
33 | | - # (legacy instantiation) |
34 | | - creds = ydb.auth_helpers.construct_credentials_from_environ() |
35 | | - if creds is not None: |
36 | | - return creds |
37 | | - |
38 | | - from .iam import MetadataUrlCredentials |
39 | | - |
40 | | - return MetadataUrlCredentials() |
| 4 | +from ydb.driver import get_config, default_credentials |
41 | 5 |
|
42 | 6 |
|
43 | 7 | class DriverConfig(ydb.DriverConfig): |
|
0 commit comments