cgcsdk 1.0.12__py3-none-any.whl → 1.0.14__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.
- cgc/.env +1 -1
- cgc/CHANGELOG.md +14 -0
- cgc/cgc.py +1 -1
- cgc/commands/auth/auth_cmd.py +3 -4
- cgc/commands/auth/auth_logic.py +61 -0
- cgc/commands/auth/auth_responses.py +2 -1
- cgc/commands/auth/auth_utils.py +2 -53
- cgc/commands/{billing → compute/billing}/__init__.py +1 -1
- cgc/commands/{billing → compute/billing}/billing_cmd.py +2 -2
- cgc/commands/{billing → compute/billing}/billing_responses.py +2 -2
- cgc/commands/compute/compute_utils.py +22 -13
- cgc/commands/volume/volume_cmd.py +1 -1
- cgc/commands/volume/volume_responses.py +1 -1
- cgc/commands/volume/volume_utils.py +2 -1
- cgc/tests/responses_tests.py +1 -1
- cgc/utils/consts/env_consts.py +0 -1
- cgc/utils/get_headers_data.py +18 -0
- cgc/utils/prepare_headers.py +12 -27
- cgc/utils/requests_helper.py +0 -4
- cgc/utils/version_control.py +6 -3
- {cgcsdk-1.0.12.dist-info → cgcsdk-1.0.14.dist-info}/METADATA +7 -6
- {cgcsdk-1.0.12.dist-info → cgcsdk-1.0.14.dist-info}/RECORD +27 -25
- /cgc/commands/{billing → compute/billing}/billing_utils.py +0 -0
- {cgcsdk-1.0.12.dist-info → cgcsdk-1.0.14.dist-info}/LICENSE +0 -0
- {cgcsdk-1.0.12.dist-info → cgcsdk-1.0.14.dist-info}/WHEEL +0 -0
- {cgcsdk-1.0.12.dist-info → cgcsdk-1.0.14.dist-info}/entry_points.txt +0 -0
- {cgcsdk-1.0.12.dist-info → cgcsdk-1.0.14.dist-info}/top_level.txt +0 -0
cgc/.env
CHANGED
cgc/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.0.14
|
4
|
+
|
5
|
+
Release on June 13, 2024
|
6
|
+
|
7
|
+
* fixed DB creation issue with a client
|
8
|
+
* fixed client handling when your context server is not available
|
9
|
+
|
10
|
+
## 1.0.13
|
11
|
+
|
12
|
+
Release on June 05, 2024
|
13
|
+
|
14
|
+
* increase volume create size to 4 TB (4096 GB)
|
15
|
+
* cgc volume list now shows which disk type is used for the volume
|
16
|
+
|
3
17
|
## 1.0.12
|
4
18
|
|
5
19
|
Release on May 09, 2024
|
cgc/cgc.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import click
|
2
2
|
from cgc.commands.volume.volume_cmd import volume_group
|
3
3
|
from cgc.commands.compute.compute_cmd import compute_group
|
4
|
-
from cgc.commands.billing.billing_cmd import billing_group
|
4
|
+
from cgc.commands.compute.billing.billing_cmd import billing_group
|
5
5
|
from cgc.commands.db.db_cmd import db_group
|
6
6
|
from cgc.commands.resource.resource_cmd import resource_group
|
7
7
|
from cgc.commands.jobs.jobs_cmd import job_group
|
cgc/commands/auth/auth_cmd.py
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
import click
|
2
|
-
import os
|
3
2
|
from cgc.commands.auth.auth_responses import (
|
4
3
|
auth_register_response,
|
5
4
|
login_successful_response,
|
6
5
|
)
|
7
|
-
from cgc.commands.auth.
|
6
|
+
from cgc.commands.auth.auth_logic import (
|
8
7
|
auth_create_api_key_with_save,
|
9
8
|
auth_delete_api_key,
|
10
9
|
auth_list_api_keys,
|
11
10
|
)
|
12
|
-
from cgc.utils.prepare_headers import
|
13
|
-
|
11
|
+
from cgc.utils.prepare_headers import get_url_and_prepare_headers_register
|
12
|
+
from cgc.utils.get_headers_data import (
|
14
13
|
load_user_api_url,
|
15
14
|
load_user_cgc_secret,
|
16
15
|
)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import os
|
2
|
+
from cgc.utils.config_utils import get_config_path
|
3
|
+
|
4
|
+
|
5
|
+
from cgc.utils import get_headers_data, prepare_headers
|
6
|
+
from cgc.utils.consts.env_consts import TMP_DIR
|
7
|
+
from cgc.utils.requests_helper import call_api, EndpointTypes
|
8
|
+
from cgc.utils.response_utils import retrieve_and_validate_response_send_metric
|
9
|
+
from cgc.utils.config_utils import save_to_config
|
10
|
+
|
11
|
+
TMP_DIR_PATH = os.path.join(get_config_path(), TMP_DIR)
|
12
|
+
|
13
|
+
|
14
|
+
def auth_delete_api_key(api_key: str, user_id: str = None, password: str = None):
|
15
|
+
"""Function to delete API key."""
|
16
|
+
url = f"{get_headers_data.load_user_api_url()}/v1/api/user/delete/api-key?api_key={api_key}"
|
17
|
+
headers = prepare_headers.prepare_headers_api_key(user_id, password)
|
18
|
+
metric = "auth.api-key"
|
19
|
+
__res = call_api(
|
20
|
+
request=EndpointTypes.delete,
|
21
|
+
url=url,
|
22
|
+
headers=headers,
|
23
|
+
)
|
24
|
+
|
25
|
+
json_data = retrieve_and_validate_response_send_metric(__res, metric)
|
26
|
+
return json_data["details"]
|
27
|
+
|
28
|
+
|
29
|
+
def auth_list_api_keys(user_id: str = None, password: str = None):
|
30
|
+
"""Function to list API keys."""
|
31
|
+
url = f"{get_headers_data.load_user_api_url()}/v1/api/user/list/api-key"
|
32
|
+
headers = prepare_headers.prepare_headers_api_key(user_id, password)
|
33
|
+
metric = "auth.api-key"
|
34
|
+
__res = call_api(
|
35
|
+
request=EndpointTypes.get,
|
36
|
+
url=url,
|
37
|
+
headers=headers,
|
38
|
+
)
|
39
|
+
|
40
|
+
json_data = retrieve_and_validate_response_send_metric(__res, metric)
|
41
|
+
return json_data["details"].get("api_keys")
|
42
|
+
|
43
|
+
|
44
|
+
def auth_create_api_key_with_save(user_id: str = None, password: str = None):
|
45
|
+
"""Function to create API key and API secret for user and save it to config file."""
|
46
|
+
url = f"{get_headers_data.load_user_api_url()}/v1/api/user/create/api-key"
|
47
|
+
headers = prepare_headers.prepare_headers_api_key(user_id, password)
|
48
|
+
metric = "auth.api-key"
|
49
|
+
__res = call_api(
|
50
|
+
request=EndpointTypes.post,
|
51
|
+
url=url,
|
52
|
+
headers=headers,
|
53
|
+
)
|
54
|
+
|
55
|
+
json_data = retrieve_and_validate_response_send_metric(__res, metric)
|
56
|
+
api_key = json_data["details"].get("_id")
|
57
|
+
secret = json_data["details"].get("secret")
|
58
|
+
save_to_config(api_key=api_key, api_secret=secret)
|
59
|
+
if user_id is not None and password is not None:
|
60
|
+
save_to_config(user_id=user_id, password=password)
|
61
|
+
return api_key, secret
|
@@ -2,6 +2,7 @@ import shutil
|
|
2
2
|
import os
|
3
3
|
|
4
4
|
from cgc.commands.auth import auth_utils
|
5
|
+
from cgc.commands.auth import auth_logic
|
5
6
|
from cgc.utils.consts.env_consts import TMP_DIR, get_config_file_name
|
6
7
|
from cgc.utils.config_utils import get_config_path, save_to_config
|
7
8
|
from cgc.utils.message_utils import key_error_decorator_for_helpers
|
@@ -24,7 +25,7 @@ def auth_register_response(
|
|
24
25
|
cgc_api_url=cgc_api_url,
|
25
26
|
cgc_secret=cgc_secret,
|
26
27
|
)
|
27
|
-
|
28
|
+
auth_logic.auth_create_api_key_with_save()
|
28
29
|
shutil.rmtree(TMP_DIR_PATH)
|
29
30
|
# config.json
|
30
31
|
if config_filename == "config.json":
|
cgc/commands/auth/auth_utils.py
CHANGED
@@ -6,10 +6,9 @@ import urllib
|
|
6
6
|
import requests
|
7
7
|
|
8
8
|
from cgc.utils.config_utils import get_config_path
|
9
|
-
from cgc.utils.config_utils import save_to_config
|
10
9
|
from cgc.utils.config_utils import read_from_cfg
|
11
10
|
from cgc.utils.cryptography import rsa_crypto
|
12
|
-
from cgc.utils import
|
11
|
+
from cgc.utils import get_headers_data
|
13
12
|
from cgc.utils.consts.env_consts import TMP_DIR
|
14
13
|
|
15
14
|
from cgc.utils.requests_helper import call_api, EndpointTypes
|
@@ -32,7 +31,7 @@ def _get_jwt_from_server(user_id: str = None, password: str = None) -> str:
|
|
32
31
|
if user_id is None and password is None:
|
33
32
|
user_id = urllib.parse.quote(read_from_cfg("user_id"))
|
34
33
|
password = urllib.parse.quote(read_from_cfg("password"))
|
35
|
-
url = f"{
|
34
|
+
url = f"{get_headers_data.load_user_api_url()}/v1/api/user/create/token"
|
36
35
|
headers = {
|
37
36
|
"accept": "application/json",
|
38
37
|
"Content-Type": "application/x-www-form-urlencoded",
|
@@ -53,56 +52,6 @@ def get_jwt(user_id: str = None, password: str = None) -> str:
|
|
53
52
|
return json_data["access_token"]
|
54
53
|
|
55
54
|
|
56
|
-
def auth_create_api_key_with_save(user_id: str = None, password: str = None):
|
57
|
-
"""Function to create API key and API secret for user and save it to config file."""
|
58
|
-
url = f"{prepare_headers.load_user_api_url()}/v1/api/user/create/api-key"
|
59
|
-
headers = prepare_headers.prepare_headers_api_key(user_id, password)
|
60
|
-
metric = "auth.api-key"
|
61
|
-
__res = call_api(
|
62
|
-
request=EndpointTypes.post,
|
63
|
-
url=url,
|
64
|
-
headers=headers,
|
65
|
-
)
|
66
|
-
|
67
|
-
json_data = retrieve_and_validate_response_send_metric(__res, metric)
|
68
|
-
api_key = json_data["details"].get("_id")
|
69
|
-
secret = json_data["details"].get("secret")
|
70
|
-
save_to_config(api_key=api_key, api_secret=secret)
|
71
|
-
if user_id is not None and password is not None:
|
72
|
-
save_to_config(user_id=user_id, password=password)
|
73
|
-
return api_key, secret
|
74
|
-
|
75
|
-
|
76
|
-
def auth_delete_api_key(api_key: str, user_id: str = None, password: str = None):
|
77
|
-
"""Function to delete API key."""
|
78
|
-
url = f"{prepare_headers.load_user_api_url()}/v1/api/user/delete/api-key?api_key={api_key}"
|
79
|
-
headers = prepare_headers.prepare_headers_api_key(user_id, password)
|
80
|
-
metric = "auth.api-key"
|
81
|
-
__res = call_api(
|
82
|
-
request=EndpointTypes.delete,
|
83
|
-
url=url,
|
84
|
-
headers=headers,
|
85
|
-
)
|
86
|
-
|
87
|
-
json_data = retrieve_and_validate_response_send_metric(__res, metric)
|
88
|
-
return json_data["details"]
|
89
|
-
|
90
|
-
|
91
|
-
def auth_list_api_keys(user_id: str = None, password: str = None):
|
92
|
-
"""Function to list API keys."""
|
93
|
-
url = f"{prepare_headers.load_user_api_url()}/v1/api/user/list/api-key"
|
94
|
-
headers = prepare_headers.prepare_headers_api_key(user_id, password)
|
95
|
-
metric = "auth.api-key"
|
96
|
-
__res = call_api(
|
97
|
-
request=EndpointTypes.get,
|
98
|
-
url=url,
|
99
|
-
headers=headers,
|
100
|
-
)
|
101
|
-
|
102
|
-
json_data = retrieve_and_validate_response_send_metric(__res, metric)
|
103
|
-
return json_data["details"].get("api_keys")
|
104
|
-
|
105
|
-
|
106
55
|
def save_and_unzip_file(res: requests.Response) -> str:
|
107
56
|
"""Function to save file, unzip it and return path to its directory.
|
108
57
|
|
@@ -7,7 +7,7 @@ class BillingCommandException(ResponseException):
|
|
7
7
|
|
8
8
|
class NoCostsFound(BillingCommandException):
|
9
9
|
def __init__(self) -> None:
|
10
|
-
super().__init__(
|
10
|
+
super().__init__("No costs found in your namespace for current month.")
|
11
11
|
|
12
12
|
|
13
13
|
class NoInvoiceFoundForSelectedMonth(BillingCommandException):
|
@@ -2,8 +2,8 @@ import click
|
|
2
2
|
|
3
3
|
from datetime import datetime
|
4
4
|
|
5
|
-
from cgc.commands.billing.billing_utils import verify_input_datetime
|
6
|
-
from cgc.commands.billing.billing_responses import (
|
5
|
+
from cgc.commands.compute.billing.billing_utils import verify_input_datetime
|
6
|
+
from cgc.commands.compute.billing.billing_responses import (
|
7
7
|
billing_status_response,
|
8
8
|
billing_invoice_response,
|
9
9
|
stop_events_resource_response,
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import calendar
|
2
|
-
from cgc.commands.billing import (
|
2
|
+
from cgc.commands.compute.billing import (
|
3
3
|
NoCostsFound,
|
4
4
|
NoInvoiceFoundForSelectedMonth,
|
5
5
|
NoResourceStopEvents,
|
6
6
|
NoVolumeStopEvents,
|
7
7
|
)
|
8
|
-
from cgc.commands.billing.billing_utils import (
|
8
|
+
from cgc.commands.compute.billing.billing_utils import (
|
9
9
|
get_billing_status_message,
|
10
10
|
get_table_compute_stop_events_message,
|
11
11
|
get_table_volume_stop_events_message,
|
@@ -1,4 +1,6 @@
|
|
1
|
+
from typing import Optional
|
1
2
|
import cgc.utils.consts.env_consts as env_consts
|
3
|
+
from cgc.utils.get_headers_data import load_user_api_url
|
2
4
|
|
3
5
|
|
4
6
|
def list_get_mounted_volumes_paths(volume_list: list) -> str:
|
@@ -172,7 +174,7 @@ def compute_create_payload(
|
|
172
174
|
cpu,
|
173
175
|
memory,
|
174
176
|
volumes: list,
|
175
|
-
volume_full_path: str,
|
177
|
+
volume_full_path: Optional[str] = None,
|
176
178
|
resource_data: list = [],
|
177
179
|
config_maps_data: list = [],
|
178
180
|
gpu: int = 0,
|
@@ -186,9 +188,12 @@ def compute_create_payload(
|
|
186
188
|
"""
|
187
189
|
Create payload for app creation.
|
188
190
|
"""
|
189
|
-
|
191
|
+
extra_payload = {}
|
190
192
|
if shm_size is not None and shm_size != 0:
|
191
|
-
|
193
|
+
extra_payload["shared_memory"] = shm_size
|
194
|
+
|
195
|
+
if volume_full_path is not None:
|
196
|
+
extra_payload["full_mount_path"] = volume_full_path
|
192
197
|
|
193
198
|
payload = {
|
194
199
|
"resource_data": {
|
@@ -198,15 +203,16 @@ def compute_create_payload(
|
|
198
203
|
"gpu": gpu,
|
199
204
|
"memory": memory,
|
200
205
|
"gpu_type": gpu_type,
|
201
|
-
|
202
|
-
**shm_payload,
|
206
|
+
**extra_payload,
|
203
207
|
}
|
204
208
|
}
|
205
209
|
try:
|
206
210
|
if len(volumes) != 0:
|
207
|
-
if not volume_full_path:
|
211
|
+
if volume_full_path is not None and not volume_full_path:
|
208
212
|
payload["resource_data"]["pv_volume"] = volumes
|
209
|
-
elif
|
213
|
+
elif (
|
214
|
+
volume_full_path is not None and volume_full_path and len(volumes) != 1
|
215
|
+
):
|
210
216
|
raise Exception(
|
211
217
|
"Volume full path can only be used with a single volume"
|
212
218
|
)
|
@@ -216,12 +222,6 @@ def compute_create_payload(
|
|
216
222
|
pass
|
217
223
|
try:
|
218
224
|
resource_data_dict = {"resource_data": {}}
|
219
|
-
if node_port_enabled:
|
220
|
-
if not env_consts.ON_PREMISES:
|
221
|
-
raise Exception(
|
222
|
-
"NodePort is supported in on-premises environments only."
|
223
|
-
)
|
224
|
-
resource_data_dict["resource_data"]["node_port_enabled"] = True
|
225
225
|
if len(resource_data) != 0:
|
226
226
|
for resource in resource_data:
|
227
227
|
try:
|
@@ -231,6 +231,15 @@ def compute_create_payload(
|
|
231
231
|
raise Exception(
|
232
232
|
"Invalid resource data format. Use key=value format"
|
233
233
|
)
|
234
|
+
if (
|
235
|
+
node_port_enabled
|
236
|
+
or "node_port_enabled" in resource_data_dict["resource_data"]
|
237
|
+
):
|
238
|
+
if env_consts.CGC_API_URL != load_user_api_url():
|
239
|
+
raise Exception(
|
240
|
+
"NodePort is supported in on-premises environments only."
|
241
|
+
)
|
242
|
+
resource_data_dict["resource_data"]["node_port_enabled"] = True
|
234
243
|
if image_name:
|
235
244
|
resource_data_dict["resource_data"]["custom_image"] = image_name
|
236
245
|
if startup_command:
|
@@ -26,7 +26,7 @@ def volume_list_response(data: dict) -> str:
|
|
26
26
|
volume_list_to_print, total_size = get_formatted_volume_list_and_total_size(
|
27
27
|
list_of_volumes
|
28
28
|
)
|
29
|
-
list_headers = ["name", "used", "size", "type", "mounted to"]
|
29
|
+
list_headers = ["name", "used", "size", "type", "disks type", "mounted to"]
|
30
30
|
|
31
31
|
setup_gauge(f"{get_namespace()}.volume.count", len(list_of_volumes))
|
32
32
|
setup_gauge(f"{get_namespace()}.volume.totalSizeAccumulated", total_size)
|
@@ -12,12 +12,13 @@ def get_formatted_volume_list_and_total_size(list_of_volumes: list):
|
|
12
12
|
name = volume["name"]
|
13
13
|
used = volume["used"]
|
14
14
|
size = volume["size"]
|
15
|
+
disks_type = volume["disks_type"]
|
15
16
|
access_types = ", ".join(volume["access_types"])
|
16
17
|
mounts = volume["mounted_to"]
|
17
18
|
mounts[:] = [s.rsplit("-", 2)[0] for s in mounts]
|
18
19
|
all_mounted_to = ", ".join(mounts)
|
19
20
|
total_size += int("".join(filter(str.isdigit, size)))
|
20
|
-
row_list = [name, used, size, access_types, all_mounted_to]
|
21
|
+
row_list = [name, used, size, access_types, disks_type, all_mounted_to]
|
21
22
|
list_to_print.append(row_list)
|
22
23
|
return list_to_print, total_size
|
23
24
|
|
cgc/tests/responses_tests.py
CHANGED
@@ -17,7 +17,7 @@ from cgc.commands.compute.compute_responses import (
|
|
17
17
|
template_list_response,
|
18
18
|
template_get_start_path_response,
|
19
19
|
)
|
20
|
-
from cgc.commands.billing.billing_responses import (
|
20
|
+
from cgc.commands.compute.billing.billing_responses import (
|
21
21
|
billing_status_response,
|
22
22
|
billing_invoice_response,
|
23
23
|
stop_events_resource_response,
|
cgc/utils/consts/env_consts.py
CHANGED
@@ -38,7 +38,6 @@ TMP_DIR = os.getenv("TMP_DIR")
|
|
38
38
|
RELEASE = int(os.getenv("RELEASE"))
|
39
39
|
MAJOR_VERSION = int(os.getenv("MAJOR_VERSION"))
|
40
40
|
MINOR_VERSION = int(os.getenv("MINOR_VERSION"))
|
41
|
-
ON_PREMISES = True if os.getenv("ON_PREMISES") == "1" else False
|
42
41
|
|
43
42
|
|
44
43
|
def get_config_file_name():
|
@@ -0,0 +1,18 @@
|
|
1
|
+
from cgc.utils.config_utils import read_from_cfg
|
2
|
+
|
3
|
+
|
4
|
+
def load_user_api_keys():
|
5
|
+
"""Based on configuration getter creates pair of API keys
|
6
|
+
|
7
|
+
:return: api_key and api_secret
|
8
|
+
:rtype: list of strings
|
9
|
+
"""
|
10
|
+
return read_from_cfg("api_key"), read_from_cfg("api_secret")
|
11
|
+
|
12
|
+
|
13
|
+
def load_user_cgc_secret():
|
14
|
+
return read_from_cfg("cgc_secret")
|
15
|
+
|
16
|
+
|
17
|
+
def load_user_api_url():
|
18
|
+
return read_from_cfg("cgc_api_url")
|
cgc/utils/prepare_headers.py
CHANGED
@@ -1,23 +1,6 @@
|
|
1
|
-
from cgc.utils.config_utils import read_from_cfg
|
2
1
|
from cgc.commands.auth import auth_utils
|
3
2
|
from cgc.utils.message_utils import key_error_decorator_for_helpers
|
4
|
-
|
5
|
-
|
6
|
-
def load_user_api_keys():
|
7
|
-
"""Based on configuration getter creates pair of API keys
|
8
|
-
|
9
|
-
:return: api_key and api_secret
|
10
|
-
:rtype: list of strings
|
11
|
-
"""
|
12
|
-
return read_from_cfg("api_key"), read_from_cfg("api_secret")
|
13
|
-
|
14
|
-
|
15
|
-
def load_user_cgc_secret():
|
16
|
-
return read_from_cfg("cgc_secret")
|
17
|
-
|
18
|
-
|
19
|
-
def load_user_api_url():
|
20
|
-
return read_from_cfg("cgc_api_url")
|
3
|
+
import cgc.utils.get_headers_data as get_headers_data
|
21
4
|
|
22
5
|
|
23
6
|
@key_error_decorator_for_helpers
|
@@ -27,15 +10,15 @@ def get_api_url_and_prepare_headers():
|
|
27
10
|
:return: CGC_API_URL and headers
|
28
11
|
:rtype: string and dict
|
29
12
|
"""
|
30
|
-
api_key, api_secret = load_user_api_keys()
|
13
|
+
api_key, api_secret = get_headers_data.load_user_api_keys()
|
31
14
|
headers = {
|
32
15
|
"accept": "application/json",
|
33
16
|
"Content-Type": "application/json; charset=UTF-8",
|
34
|
-
"comtegra-cgc": load_user_cgc_secret(),
|
17
|
+
"comtegra-cgc": get_headers_data.load_user_cgc_secret(),
|
35
18
|
"api-key": api_key,
|
36
19
|
"api-secret": api_secret,
|
37
20
|
}
|
38
|
-
return load_user_api_url(), headers
|
21
|
+
return get_headers_data.load_user_api_url(), headers
|
39
22
|
|
40
23
|
|
41
24
|
def get_url_and_prepare_headers_register(
|
@@ -46,17 +29,19 @@ def get_url_and_prepare_headers_register(
|
|
46
29
|
:return: url, headers
|
47
30
|
:rtype: string and dict
|
48
31
|
"""
|
49
|
-
url = f"{load_user_api_url() if url is None else url}/v1/api/user/register?user_id={user_id}&access_key={access_key}"
|
32
|
+
url = f"{get_headers_data.load_user_api_url() if url is None else url}/v1/api/user/register?user_id={user_id}&access_key={access_key}"
|
50
33
|
headers = {
|
51
34
|
"accept": "application/json",
|
52
35
|
"Content-Type": "octet-stream",
|
53
|
-
"comtegra-cgc":
|
36
|
+
"comtegra-cgc": (
|
37
|
+
get_headers_data.load_user_cgc_secret() if secret is None else secret
|
38
|
+
),
|
54
39
|
}
|
55
40
|
return url, headers
|
56
41
|
|
57
42
|
|
58
43
|
def get_url_and_headers_jwt_token():
|
59
|
-
url = f"{load_user_api_url()}/v1/api/user/create/token"
|
44
|
+
url = f"{get_headers_data.load_user_api_url()}/v1/api/user/create/token"
|
60
45
|
headers = {
|
61
46
|
"accept": "application/json",
|
62
47
|
"Content-Type": "application/x-www-form-urlencoded",
|
@@ -74,7 +59,7 @@ def prepare_headers_api_key(user_id: str = None, password: str = None):
|
|
74
59
|
headers = {
|
75
60
|
"accept": "application/json",
|
76
61
|
"Authorization": f"Bearer {auth_utils.get_jwt(user_id, password)}",
|
77
|
-
"comtegra-cgc": load_user_cgc_secret(),
|
62
|
+
"comtegra-cgc": get_headers_data.load_user_cgc_secret(),
|
78
63
|
}
|
79
64
|
return headers
|
80
65
|
|
@@ -85,10 +70,10 @@ def get_api_url_and_prepare_headers_version_control():
|
|
85
70
|
:return: url and headers in a for of dictionary
|
86
71
|
:rtype: string, dict
|
87
72
|
"""
|
88
|
-
url = f"{load_user_api_url()}/v1/api/info/version"
|
73
|
+
url = f"{get_headers_data.load_user_api_url()}/v1/api/info/version"
|
89
74
|
headers = {
|
90
75
|
"accept": "application/json",
|
91
76
|
"Content-Type": "application/json",
|
92
|
-
"comtegra-cgc": load_user_cgc_secret(),
|
77
|
+
"comtegra-cgc": get_headers_data.load_user_cgc_secret(),
|
93
78
|
}
|
94
79
|
return url, headers
|
cgc/utils/requests_helper.py
CHANGED
@@ -53,16 +53,12 @@ def call_api(request: EndpointTypes, **kwargs):
|
|
53
53
|
except requests.exceptions.ReadTimeout:
|
54
54
|
increment_metric(metric="client.timeout", is_error=True)
|
55
55
|
click.echo(prepare_error_message(TIMEOUT_ERROR))
|
56
|
-
sys.exit()
|
57
|
-
|
58
56
|
except requests.exceptions.ConnectionError:
|
59
57
|
increment_metric(metric="client.connection", is_error=True)
|
60
58
|
click.echo(prepare_error_message(CONNECTION_ERROR))
|
61
|
-
sys.exit()
|
62
59
|
except OSError:
|
63
60
|
increment_metric(metric="client.certificate", is_error=True)
|
64
61
|
click.echo(prepare_error_message(CERTIFICATE_ERROR))
|
65
|
-
sys.exit()
|
66
62
|
except:
|
67
63
|
increment_metric(metric="client.unhandled", is_error=True)
|
68
64
|
click.echo(prepare_error_message(UNKNOWN_ERROR))
|
cgc/utils/version_control.py
CHANGED
@@ -31,9 +31,10 @@ def get_server_version():
|
|
31
31
|
except Exception:
|
32
32
|
click.echo(
|
33
33
|
"Your current context server is not available, cannot check server version.",
|
34
|
-
color="
|
34
|
+
color="red",
|
35
35
|
)
|
36
|
-
|
36
|
+
else:
|
37
|
+
return __res.json()
|
37
38
|
|
38
39
|
|
39
40
|
def print_compare_versions(server_version: str, client_version: str):
|
@@ -47,6 +48,8 @@ def check_version():
|
|
47
48
|
if not is_config_file_present():
|
48
49
|
return
|
49
50
|
data = get_server_version()
|
51
|
+
if data is None:
|
52
|
+
return
|
50
53
|
server_release, server_major, server_minor = (
|
51
54
|
data["server_version"]["release"],
|
52
55
|
data["server_version"]["major"],
|
@@ -57,7 +60,7 @@ def check_version():
|
|
57
60
|
] # braking change - 0.9.0, will not work with lower server version
|
58
61
|
server_version = f"{server_release}.{server_major}.{server_minor}"
|
59
62
|
client_version = f"{RELEASE}.{MAJOR_VERSION}.{MINOR_VERSION}"
|
60
|
-
if server_major
|
63
|
+
if server_major >= MAJOR_VERSION and server_release > RELEASE:
|
61
64
|
click.echo(prepare_error_message(OUTDATED_MAJOR))
|
62
65
|
print_compare_versions(server_version, client_version)
|
63
66
|
while True:
|
@@ -1,24 +1,25 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: cgcsdk
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.14
|
4
4
|
Summary: Comtegra GPU Cloud REST API client
|
5
|
+
Home-page: https://git.comtegra.pl/
|
5
6
|
Author: Comtegra AI Team
|
6
7
|
Author-email: ai@comtegra.pl
|
7
8
|
License: BSD 2-clause
|
8
|
-
Project-URL: Documentation, https://
|
9
|
-
Project-URL: GitHub, https://
|
10
|
-
Project-URL: Changelog, https://
|
9
|
+
Project-URL: Documentation, https://docs.cgc.comtegra.cloud/
|
10
|
+
Project-URL: GitHub, https://git.comtegra.pl/
|
11
|
+
Project-URL: Changelog, https://git.comtegra.pl/foobar/foobar/blob/master/CHANGELOG.md
|
11
12
|
Keywords: cloud,sdk,orchestrator,kubernetes,jupyter-notebook
|
12
13
|
Classifier: Development Status :: 1 - Planning
|
13
14
|
Classifier: Intended Audience :: Science/Research
|
14
15
|
Classifier: License :: OSI Approved :: BSD License
|
15
16
|
Classifier: Operating System :: POSIX :: Linux
|
16
17
|
Classifier: Programming Language :: Python :: 3
|
17
|
-
Classifier: Programming Language :: Python :: 3.4
|
18
|
-
Classifier: Programming Language :: Python :: 3.5
|
19
18
|
Classifier: Programming Language :: Python :: 3.8
|
20
19
|
Classifier: Programming Language :: Python :: 3.9
|
21
20
|
Classifier: Programming Language :: Python :: 3.10
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
22
23
|
Description-Content-Type: text/markdown
|
23
24
|
License-File: LICENSE
|
24
25
|
Requires-Dist: click
|
@@ -1,7 +1,7 @@
|
|
1
|
-
cgc/.env,sha256=
|
2
|
-
cgc/CHANGELOG.md,sha256=
|
1
|
+
cgc/.env,sha256=C_RaN_SqTDvKhLL3epnhR5d2Y_0V8Uw-fEEGTkOlS1Q,210
|
2
|
+
cgc/CHANGELOG.md,sha256=a7qt1BD65-gg2BeD6Uk46lXosgfcJjqE8LvBaLuFe5M,9024
|
3
3
|
cgc/__init__.py,sha256=d03Xv8Pw4ktNyUHfmicP6XfxYPXnVYLaCZPyUlg_RNQ,326
|
4
|
-
cgc/cgc.py,sha256=
|
4
|
+
cgc/cgc.py,sha256=3I_Ef0ggX9caaJKJkhfGYSe8XwkHzSWxwGAClMHDnUs,1663
|
5
5
|
cgc/config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
cgc/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
cgc/commands/cgc_cmd.py,sha256=QwqjZl9FmAMOvuUQMJm-wOV88OxbdwK5UIS0zkg-mAo,4956
|
@@ -10,18 +10,19 @@ cgc/commands/cgc_helpers.py,sha256=ngArFjVw-8P_2g7J8k3b9xgDxfJw7JeaOtkhTySMSGU,1
|
|
10
10
|
cgc/commands/cgc_models.py,sha256=T4eCMO5AO2kZpIRqpZ7ZfgO9gxCo_MLlY33msCzrLvA,182
|
11
11
|
cgc/commands/exceptions.py,sha256=kVCWEdcqmkLO5QVIINdEXQw29_glyX2C11ZMFgT7b8E,155
|
12
12
|
cgc/commands/auth/__init__.py,sha256=JnqNezSEUEVVPQIymya4llXr8LIug2vymQSAGBr4Ovg,397
|
13
|
-
cgc/commands/auth/auth_cmd.py,sha256=
|
14
|
-
cgc/commands/auth/
|
15
|
-
cgc/commands/auth/
|
16
|
-
cgc/commands/
|
17
|
-
cgc/commands/billing/billing_cmd.py,sha256=T1E5WW5Z-RlzddaotimTuvLvIbGihNpStIBETnlUznM,4140
|
18
|
-
cgc/commands/billing/billing_responses.py,sha256=HAD5N-Odx3Jz1OmhO4v66rHoXpTYIOGlXDsrs0da9dk,1949
|
19
|
-
cgc/commands/billing/billing_utils.py,sha256=zXLbBBcWeOgur-r0OKiIjaKeaxMNxASXWzCTeTsyC6o,4711
|
13
|
+
cgc/commands/auth/auth_cmd.py,sha256=f8_2oIlFQ1k0zvJXGfrwkdVoK5EJBwWesNdOcjtY_uM,4220
|
14
|
+
cgc/commands/auth/auth_logic.py,sha256=PzEyC6OBRSne_5dQT-cq69J0i8BqfGL0MIoXW-yM8qE,2281
|
15
|
+
cgc/commands/auth/auth_responses.py,sha256=yMGQzggdRkO3hYgXiy6DAFqmVw4lkgfd12g1qQx-CBc,2000
|
16
|
+
cgc/commands/auth/auth_utils.py,sha256=8NZQQuR0JDCxRkNOHy8nRLDpeT3W87iNyaBI1owj79c,3597
|
20
17
|
cgc/commands/compute/__init__.py,sha256=lCdLfZ0ECSHtXEUSwq5YRHH85yXHchSsz8ZJvmClPtI,239
|
21
18
|
cgc/commands/compute/compute_cmd.py,sha256=eXKeoOV3DsOypuxzKMa3MpITOKKbF2cZjy30iofHHG8,15489
|
22
19
|
cgc/commands/compute/compute_models.py,sha256=yse6mCEhhE2RdWIO7EHx4r5Y-350gWWy4UWFsdltNNg,778
|
23
20
|
cgc/commands/compute/compute_responses.py,sha256=DnRIZC_F1ZE887fMOXXYGYuYmB9n5x63sf8Ga_TL4Ww,5806
|
24
|
-
cgc/commands/compute/compute_utils.py,sha256=
|
21
|
+
cgc/commands/compute/compute_utils.py,sha256=Pj4xa-C8-MzXF-CCnnHNXn0sXjHy_t-N7c-eig-vF1Y,9182
|
22
|
+
cgc/commands/compute/billing/__init__.py,sha256=ccjz-AzBCROjuR11qZRM4_62slI9ErmLi27xPUoRPHM,752
|
23
|
+
cgc/commands/compute/billing/billing_cmd.py,sha256=8lGf2GPyr09ZmqkRshmgfSPQgXa9o_IDSfwZgMfBE4k,4156
|
24
|
+
cgc/commands/compute/billing/billing_responses.py,sha256=5vQSR_d41uizengzfXlHXL7XivO_73PpWdKmoUgqYNw,1965
|
25
|
+
cgc/commands/compute/billing/billing_utils.py,sha256=zXLbBBcWeOgur-r0OKiIjaKeaxMNxASXWzCTeTsyC6o,4711
|
25
26
|
cgc/commands/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
27
|
cgc/commands/db/db_cmd.py,sha256=4iamsHTy68YjrKztyRGz2PqQgo54Q_rURgm2zpp_hL8,3512
|
27
28
|
cgc/commands/db/db_models.py,sha256=oJUAF23nb_r8fSyhLHMJrRbRzLY_vpJQu6Vy4WRa0cg,1036
|
@@ -45,9 +46,9 @@ cgc/commands/user/secret_responses.py,sha256=sg7HP5a0LnUvlo9w8oOcYASwI2cPeRnecjT
|
|
45
46
|
cgc/commands/user/secret_utils.py,sha256=70dn937rzecQ0eE-8zb9fLnBDWtjWjdQY1LJvHv3NzM,1623
|
46
47
|
cgc/commands/volume/__init__.py,sha256=Ou3kyb72aaXkrVCfQCVdniA65R2xHsRFgebooG1gflA,384
|
47
48
|
cgc/commands/volume/data_model.py,sha256=meprXdaXLo3mMTZta1ks1-BJ7G0rO16qi_ycH-sXJpY,1295
|
48
|
-
cgc/commands/volume/volume_cmd.py,sha256=
|
49
|
-
cgc/commands/volume/volume_responses.py,sha256=
|
50
|
-
cgc/commands/volume/volume_utils.py,sha256=
|
49
|
+
cgc/commands/volume/volume_cmd.py,sha256=bKXEdlxcL1gmVYeRXQeVY463IMHO-So4PWPBRXL6O4Y,7673
|
50
|
+
cgc/commands/volume/volume_responses.py,sha256=PqYe5HVbClkCMIuXWn_FDvPUNxsJW8M_hFIB0lf40bo,3213
|
51
|
+
cgc/commands/volume/volume_utils.py,sha256=6IuDCNT-KAvUUF_EDg5cL9JewTGsbBsZlYd_zKHowCU,1973
|
51
52
|
cgc/sdk/__init__.py,sha256=m8uAD2e_ADbHC4_kaOpLrUk_bHy7wC56rPjhcttclCs,177
|
52
53
|
cgc/sdk/exceptions.py,sha256=99XIzDO6LYKjex715troH-MkGUN7hi2Bit4KHfSHDis,214
|
53
54
|
cgc/sdk/job.py,sha256=q9Vsarc3rKzurM4AOmbQDsQUVdyRqx0UzJVe_uO8xCU,5318
|
@@ -56,7 +57,7 @@ cgc/sdk/resource.py,sha256=w8SVRqrx0Mj1FS91Bt0oaMAfC4CDEcomgqzFCNgGaPc,13537
|
|
56
57
|
cgc/telemetry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
57
58
|
cgc/telemetry/basic.py,sha256=XagCcyH4QSEPmfiQ1WCjqXslnJO6IaJCY0AMPySd5rc,3175
|
58
59
|
cgc/tests/__init__.py,sha256=8aI3MVpkzaj0_UX02kZCtY5vmGO0rnq0mw2H04-OHf8,102743
|
59
|
-
cgc/tests/responses_tests.py,sha256=
|
60
|
+
cgc/tests/responses_tests.py,sha256=9vLOaUICeUXoDObeFwuu0FBTmC-hnJNZfzvolT96dGM,9188
|
60
61
|
cgc/tests/desired_responses/test_billing_invoice.txt,sha256=KR5m2gamn_bgfBdBmWDH2sPRJIPOw1u8kdH-gYE8jow,1579
|
61
62
|
cgc/tests/desired_responses/test_billing_status.txt,sha256=2KSUixFOrhXI5ON6qtsIUmzFye5LBZB1xneY8ST0MqE,2381
|
62
63
|
cgc/tests/desired_responses/test_billing_stop_events_compute.txt,sha256=nHdixgLhAXDMeoDvjk9Mwv6b0JIAsW8j7Z6SS5scjSs,234
|
@@ -69,22 +70,23 @@ cgc/utils/__init__.py,sha256=JOvbqyGdFtswXE1TntOqM7XuIg5-t042WzAzvmX7Xtk,3661
|
|
69
70
|
cgc/utils/click_group.py,sha256=Scfw8eMIyt2dE1ezUq2JuiI-E_LklqXQXJEr7L-EG6A,633
|
70
71
|
cgc/utils/config_utils.py,sha256=-DkUBncq_nTUIbxnF9vTiibZHgJ6Beomzk7fg7zQJVA,3465
|
71
72
|
cgc/utils/custom_exceptions.py,sha256=qvHdzaunZswZgN96iOHZIfLjehlJ79mcjqoMoW-tqEM,2628
|
73
|
+
cgc/utils/get_headers_data.py,sha256=JdEg5vrAHcWfsSJ7poYk3sNIY10OxX7YGVcmua-37lY,413
|
72
74
|
cgc/utils/message_utils.py,sha256=FAiUC-0zJiMhfPQAQC0ki1ZUs1vI_QqHwLmfoCDbLeU,1790
|
73
|
-
cgc/utils/prepare_headers.py,sha256=
|
74
|
-
cgc/utils/requests_helper.py,sha256=
|
75
|
+
cgc/utils/prepare_headers.py,sha256=Hi3WNqtqydW56tNTLZmpfMTpu4aKCoDrLx4OcCGH9_U,2656
|
76
|
+
cgc/utils/requests_helper.py,sha256=Z89dTOTbSSi1xmtNPmAdJpduR9-DC12WEQsHYeuM9a0,2046
|
75
77
|
cgc/utils/response_utils.py,sha256=9vJqAt2UFJ1n-oesFPe6CB_ooGoStjl-twY_31Jt4_I,7374
|
76
78
|
cgc/utils/update.py,sha256=AsQwhcBqsjgNPKn6AN6ojt0Ew5otvJXyshys6bjr7DQ,413
|
77
|
-
cgc/utils/version_control.py,sha256=
|
79
|
+
cgc/utils/version_control.py,sha256=jYm_XYHzM61DR8aJlwDLAB6psOGLjOiXR6zTOEfv57A,3515
|
78
80
|
cgc/utils/consts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
79
|
-
cgc/utils/consts/env_consts.py,sha256=
|
81
|
+
cgc/utils/consts/env_consts.py,sha256=3MaR8sMlQyGWP6sBWajhVbnzhDovD2ZQjKYeQ27e-1w,1225
|
80
82
|
cgc/utils/consts/message_consts.py,sha256=8CIe3N_HL6Pj-gSArkPkpegsvm-QMWxqqnSgtzG08Qw,1218
|
81
83
|
cgc/utils/cryptography/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
82
84
|
cgc/utils/cryptography/aes_crypto.py,sha256=S0rKg38oy7rM5lTrP6DDpjLA-XRxuZggAXyxMFHtyzY,3333
|
83
85
|
cgc/utils/cryptography/encryption_module.py,sha256=rbblBBorHYPGl-iKblyZX3_NuPEvUTpnH1l_RgNGCbA,1958
|
84
86
|
cgc/utils/cryptography/rsa_crypto.py,sha256=h3jU5qPpj9uVjP1rTqZJTdYB5yjhD9HZpr_nD439h9Q,4180
|
85
|
-
cgcsdk-1.0.
|
86
|
-
cgcsdk-1.0.
|
87
|
-
cgcsdk-1.0.
|
88
|
-
cgcsdk-1.0.
|
89
|
-
cgcsdk-1.0.
|
90
|
-
cgcsdk-1.0.
|
87
|
+
cgcsdk-1.0.14.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
88
|
+
cgcsdk-1.0.14.dist-info/METADATA,sha256=9bvU67kTs5GpfGtnmy7FWIifW4aJmOwSiMEwYO4iKH0,3091
|
89
|
+
cgcsdk-1.0.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
90
|
+
cgcsdk-1.0.14.dist-info/entry_points.txt,sha256=bdfIHeJ6Y-BBr5yupCVoK7SUrJj1yNdew8OtIOg_3No,36
|
91
|
+
cgcsdk-1.0.14.dist-info/top_level.txt,sha256=nqW9tqcIcCXFigQT69AuOk7XHKc4pCuv4HGJQGXb6iA,12
|
92
|
+
cgcsdk-1.0.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|