|
1 | | -import platform |
2 | 1 | from typing import ClassVar, Dict, Optional |
3 | 2 |
|
4 | 3 | from requests import Response, exceptions, request |
5 | 4 |
|
6 | | -from cycode import __version__ |
7 | 5 | from cycode.cli.exceptions.custom_exceptions import HttpUnauthorizedError, NetworkError |
8 | | -from cycode.cli.user_settings.configuration_manager import ConfigurationManager |
9 | 6 | from cycode.cyclient import config, logger |
10 | | - |
11 | | - |
12 | | -def get_cli_user_agent() -> str: |
13 | | - """Return base User-Agent of CLI. |
14 | | -
|
15 | | - Example: CycodeCLI/0.2.3 (OS: Darwin; Arch: arm64; Python: 3.8.16; InstallID: *uuid4*) |
16 | | - """ |
17 | | - app_name = 'CycodeCLI' |
18 | | - version = __version__ |
19 | | - |
20 | | - os = platform.system() |
21 | | - arch = platform.machine() |
22 | | - python_version = platform.python_version() |
23 | | - |
24 | | - install_id = ConfigurationManager().get_or_create_installation_id() |
25 | | - |
26 | | - return f'{app_name}/{version} (OS: {os}; Arch: {arch}; Python: {python_version}; InstallID: {install_id})' |
| 7 | +from cycode.cyclient.headers import get_cli_user_agent, get_correlation_id |
27 | 8 |
|
28 | 9 |
|
29 | 10 | class CycodeClientBase: |
30 | | - MANDATORY_HEADERS: ClassVar[Dict[str, str]] = {'User-Agent': get_cli_user_agent()} |
| 11 | + MANDATORY_HEADERS: ClassVar[Dict[str, str]] = { |
| 12 | + 'User-Agent': get_cli_user_agent(), |
| 13 | + 'X-Correlation-Id': get_correlation_id(), |
| 14 | + } |
31 | 15 |
|
32 | 16 | def __init__(self, api_url: str) -> None: |
33 | 17 | self.timeout = config.timeout |
|
0 commit comments