twc-cli 1.1.0__py3-none-any.whl → 1.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of twc-cli might be problematic. Click here for more details.
- CHANGELOG.md +48 -15
- twc/__main__.py +72 -1
- twc/__version__.py +1 -1
- twc/api/client.py +319 -2
- twc/click_ext.py +34 -0
- twc/commands/__init__.py +10 -43
- twc/commands/config.py +141 -22
- twc/commands/database.py +633 -0
- twc/commands/image.py +2 -2
- twc/commands/project.py +9 -0
- twc/commands/server.py +89 -47
- twc/commands/storage.py +818 -0
- twc/fmt.py +14 -1
- twc/utils.py +20 -0
- twc/vars.py +20 -0
- {twc_cli-1.1.0.dist-info → twc_cli-1.3.0.dist-info}/METADATA +2 -1
- twc_cli-1.3.0.dist-info/RECORD +26 -0
- {twc_cli-1.1.0.dist-info → twc_cli-1.3.0.dist-info}/WHEEL +1 -1
- twc_cli-1.1.0.dist-info/RECORD +0 -21
- {twc_cli-1.1.0.dist-info → twc_cli-1.3.0.dist-info}/COPYING +0 -0
- {twc_cli-1.1.0.dist-info → twc_cli-1.3.0.dist-info}/entry_points.txt +0 -0
twc/fmt.py
CHANGED
|
@@ -10,7 +10,7 @@ import click
|
|
|
10
10
|
import yaml
|
|
11
11
|
|
|
12
12
|
from pygments import highlight
|
|
13
|
-
from pygments.lexers import JsonLexer, YamlLexer
|
|
13
|
+
from pygments.lexers import JsonLexer, YamlLexer, IniLexer, TOMLLexer
|
|
14
14
|
from pygments.formatters import TerminalFormatter
|
|
15
15
|
|
|
16
16
|
|
|
@@ -188,3 +188,16 @@ def filter_list(objects: list, filters: str) -> list:
|
|
|
188
188
|
except (KeyError, ValueError):
|
|
189
189
|
return []
|
|
190
190
|
return objects
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def print_colored(data: str, lang: str = None):
|
|
194
|
+
"""Print colorized text to terminal."""
|
|
195
|
+
lexers = {
|
|
196
|
+
"json": JsonLexer(),
|
|
197
|
+
"yaml": YamlLexer(),
|
|
198
|
+
"toml": TOMLLexer(),
|
|
199
|
+
"ini": IniLexer(),
|
|
200
|
+
}
|
|
201
|
+
if lang not in lexers:
|
|
202
|
+
raise ValueError(f"Unsupported lexer: '{lang}'")
|
|
203
|
+
click.echo(highlight(data, lexers[lang], TerminalFormatter()).strip())
|
twc/utils.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Common non TWC-specific functions."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def merge_dicts(a: dict, b: dict, path=None) -> dict:
|
|
5
|
+
"""Merge b into a. Return modified a.
|
|
6
|
+
Ref: https://stackoverflow.com/a/7205107
|
|
7
|
+
"""
|
|
8
|
+
if path is None:
|
|
9
|
+
path = []
|
|
10
|
+
for key in b:
|
|
11
|
+
if key in a:
|
|
12
|
+
if isinstance(a[key], dict) and isinstance(b[key], dict):
|
|
13
|
+
merge_dicts(a[key], b[key], path + [str(key)])
|
|
14
|
+
elif a[key] == b[key]:
|
|
15
|
+
pass # same leaf value
|
|
16
|
+
else:
|
|
17
|
+
a[key] = b[key] # replace existing key's values
|
|
18
|
+
else:
|
|
19
|
+
a[key] = b[key]
|
|
20
|
+
return a
|
twc/vars.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""This module defines variables that depend on Timeweb Cloud products.
|
|
2
|
+
They are subject to change at any time as cloud computing capabilities
|
|
3
|
+
expand or other infrastructure or product changes occur.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# Service URLs
|
|
7
|
+
TWC_CP_URL = "https://timeweb.cloud/my"
|
|
8
|
+
TWC_S3_ENDPOINT = "s3.timeweb.com"
|
|
9
|
+
|
|
10
|
+
# CLI configuration file sceleton.
|
|
11
|
+
DEFAULT_CONFIG = {"default": {"token": ""}}
|
|
12
|
+
|
|
13
|
+
# Default Configurator ID for Cloud Servers.
|
|
14
|
+
DEFAULT_CONFIGURATOR_ID = 11
|
|
15
|
+
|
|
16
|
+
# Location specific parameters. May change later.
|
|
17
|
+
REGIONS_WITH_CONFIGURATOR = ["ru-1"]
|
|
18
|
+
REGIONS_WITH_IPV6 = ["ru-1", "pl-1"]
|
|
19
|
+
REGIONS_WITH_IMAGES = ["ru-1"]
|
|
20
|
+
REGIONS_WITH_LAN = ["ru-1"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: twc-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Timeweb Cloud Command Line Interface.
|
|
5
5
|
Home-page: https://github.com/timeweb-cloud/twc
|
|
6
6
|
License: MIT
|
|
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
17
17
|
Requires-Dist: click-aliases (>=1.0.1,<2.0.0)
|
|
18
|
+
Requires-Dist: click-default-group (>=1.2.2,<2.0.0)
|
|
18
19
|
Requires-Dist: pygments (>=2.14.0,<3.0.0)
|
|
19
20
|
Requires-Dist: pyyaml (>=6.0,<7.0)
|
|
20
21
|
Requires-Dist: requests (>=2.28.1,<3.0.0)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
CHANGELOG.md,sha256=bjqipQ_lEedXJjBpvbcE3V8EEB2vXCXPCWrCVuX7QIE,7000
|
|
2
|
+
COPYING,sha256=fpJLxZS_kHr_659xkpmqEtqHeZp6lQR9CmKCwnYbsmE,1089
|
|
3
|
+
twc/__init__.py,sha256=NwPAMNw3NuHdWGQvWS9_lromVF6VM194oVOipojfJns,113
|
|
4
|
+
twc/__main__.py,sha256=D275h0CHpZB-LPKZyvPHYtcAIRbmdhVuXrDp73dda0A,2620
|
|
5
|
+
twc/__version__.py,sha256=5Zm4QOPB1P-kcT_KFEYr7McP72od62iWMR7Vwc9YE38,420
|
|
6
|
+
twc/api/__init__.py,sha256=1OFp1sNrikcJH_JjkhGjnnKpyfg-SCOH_RBkgG-Mqw8,59
|
|
7
|
+
twc/api/client.py,sha256=UiLiOoD0jwxdFoYv4LcF_pwkqvTBGbVNHZK6jRhdyLg,40159
|
|
8
|
+
twc/api/exceptions.py,sha256=-IKU8HEaFvmvvHd3NaiF6ticnONrGz7L9TYSTF9d5Lg,851
|
|
9
|
+
twc/click_ext.py,sha256=MYpKirAlrp7gJd1qlBkPV33GfQZi9t3UmXuOeNBS0XE,1185
|
|
10
|
+
twc/commands/__init__.py,sha256=EYzMzTUeaiZra167wAFOOTxt3GniCniROKF_STV_iJU,7517
|
|
11
|
+
twc/commands/account.py,sha256=FsqjIiPjCCQ6yvrea3ElzsgbZ1B8nTzNOpTuzlPFcME,5368
|
|
12
|
+
twc/commands/config.py,sha256=9XPjCKqQ2K5IzdgTeNuLWzQk6zxwOTC9m4REGpuRRqs,5108
|
|
13
|
+
twc/commands/database.py,sha256=bLwq_QOAKuwqoZYiO-HuyH7OO027YXiV2iWerg88BQk,17457
|
|
14
|
+
twc/commands/image.py,sha256=NADbvPmGJbmZ_Q0dhyiUEQJt65WbC3K7lUAmmFn-qvg,9510
|
|
15
|
+
twc/commands/project.py,sha256=eYI0X6AMIS_X6P-jDQcdWGbERNmOqTOkFxx9WQFesXc,11669
|
|
16
|
+
twc/commands/server.py,sha256=vwUVeRRMMJIV7G0wS7vGP0fgsvH8sScTSLERCU7Brvs,71079
|
|
17
|
+
twc/commands/ssh_key.py,sha256=6ucRbeOegiLENuqHTdqb7X0bK4__n-_i1Iog6VS0IOk,8218
|
|
18
|
+
twc/commands/storage.py,sha256=YcKi0QzgwH9r_YXX2KM_7M442hJw98U6ubzQa4AwEik,23777
|
|
19
|
+
twc/fmt.py,sha256=_7mJDyodVdGMkxDagx6D6xe-qVlilq3NXO7z2TILq68,6283
|
|
20
|
+
twc/utils.py,sha256=UbMhR0N6ueTIzULNP6U3HSN09EJeIr8-MrtLL67ec6Q,616
|
|
21
|
+
twc/vars.py,sha256=mIV9JlXZBnTtWiXg_jVDOqK-Y7X2laktdUkTKx8SyMc,634
|
|
22
|
+
twc_cli-1.3.0.dist-info/COPYING,sha256=fpJLxZS_kHr_659xkpmqEtqHeZp6lQR9CmKCwnYbsmE,1089
|
|
23
|
+
twc_cli-1.3.0.dist-info/METADATA,sha256=AThrDdPpiHkKEcT-28eYsofXiAV_m9iHpQ1RYbSme7k,1780
|
|
24
|
+
twc_cli-1.3.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
|
25
|
+
twc_cli-1.3.0.dist-info/entry_points.txt,sha256=tmTaVRhm8BkNrXC_9XJMum7O9wFVOvkXcBetxmahWvE,40
|
|
26
|
+
twc_cli-1.3.0.dist-info/RECORD,,
|
twc_cli-1.1.0.dist-info/RECORD
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
CHANGELOG.md,sha256=bHmrAn1UAHLqr6Zo0a5o8oR98fqgo27DsCufPNC7wpw,3720
|
|
2
|
-
COPYING,sha256=fpJLxZS_kHr_659xkpmqEtqHeZp6lQR9CmKCwnYbsmE,1089
|
|
3
|
-
twc/__init__.py,sha256=NwPAMNw3NuHdWGQvWS9_lromVF6VM194oVOipojfJns,113
|
|
4
|
-
twc/__main__.py,sha256=jZG31gIATAFfwGqde3t7ttyAUxJI61v0-0QO61B2pk4,579
|
|
5
|
-
twc/__version__.py,sha256=PSBZ7n33LNwjZEyFsYWX2QQn2SbLMNXgZLUZg9iAjuQ,420
|
|
6
|
-
twc/api/__init__.py,sha256=1OFp1sNrikcJH_JjkhGjnnKpyfg-SCOH_RBkgG-Mqw8,59
|
|
7
|
-
twc/api/client.py,sha256=pyPl029Zd8jh85rCts5fO8fl7dYehcC_rJquzSx6-4U,29592
|
|
8
|
-
twc/api/exceptions.py,sha256=-IKU8HEaFvmvvHd3NaiF6ticnONrGz7L9TYSTF9d5Lg,851
|
|
9
|
-
twc/commands/__init__.py,sha256=8HMovdUeHa4CiFKIHTxL6jQX6sNC6NFyDoxNxzy911A,8376
|
|
10
|
-
twc/commands/account.py,sha256=FsqjIiPjCCQ6yvrea3ElzsgbZ1B8nTzNOpTuzlPFcME,5368
|
|
11
|
-
twc/commands/config.py,sha256=93awq8dnjs7hB6Ffo8PAj03yMR1M_SI23TFPlNry8A8,1471
|
|
12
|
-
twc/commands/image.py,sha256=OuDUfMFVy-tB9r7mcZq5jAOB3Vu6XgHbNRDiZjXW_dw,9510
|
|
13
|
-
twc/commands/project.py,sha256=3FM9SfIMb7qmInfbdy2rzgIZ0N14VIpUQVwrR3f7Pk0,11432
|
|
14
|
-
twc/commands/server.py,sha256=ZfHPFchHcsYx5QmPalPTfwEe3BOOOIIEBMFg3Mf9NFg,69931
|
|
15
|
-
twc/commands/ssh_key.py,sha256=6ucRbeOegiLENuqHTdqb7X0bK4__n-_i1Iog6VS0IOk,8218
|
|
16
|
-
twc/fmt.py,sha256=Quiqlp30SDPrWD4ES0UuLb1FcK9NxTkTt9Qvw4hUSoA,5874
|
|
17
|
-
twc_cli-1.1.0.dist-info/COPYING,sha256=fpJLxZS_kHr_659xkpmqEtqHeZp6lQR9CmKCwnYbsmE,1089
|
|
18
|
-
twc_cli-1.1.0.dist-info/METADATA,sha256=coNEEOvBOAon55uEMvy5ShttDUYK7vBFlCh2Eyksltg,1728
|
|
19
|
-
twc_cli-1.1.0.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
|
|
20
|
-
twc_cli-1.1.0.dist-info/entry_points.txt,sha256=tmTaVRhm8BkNrXC_9XJMum7O9wFVOvkXcBetxmahWvE,40
|
|
21
|
-
twc_cli-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|