Skip to content

Commit 06f673e

Browse files
committed
pass timeout through SDK diff requests
Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent 206efe9 commit 06f673e

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

socketsecurity/socketcli.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@
2626

2727
load_dotenv()
2828

29+
DEFAULT_API_TIMEOUT = 1200
30+
31+
32+
def get_api_request_timeout(config: CliConfig) -> int:
33+
return config.timeout if config.timeout is not None else DEFAULT_API_TIMEOUT
34+
35+
36+
def build_socket_sdk(config: CliConfig) -> socketdev:
37+
cli_user_agent_string = f"SocketPythonCLI/{config.version}"
38+
return socketdev(
39+
token=config.api_token,
40+
timeout=get_api_request_timeout(config),
41+
allow_unverified=config.allow_unverified,
42+
user_agent=cli_user_agent_string
43+
)
44+
45+
2946
def cli():
3047
try:
3148
main_code()
@@ -63,8 +80,7 @@ def main_code():
6380
"1. Command line: --api-token YOUR_TOKEN\n"
6481
"2. Environment variable: SOCKET_SECURITY_API_TOKEN")
6582
sys.exit(3)
66-
cli_user_agent_string = f"SocketPythonCLI/{config.version}"
67-
sdk = socketdev(token=config.api_token, allow_unverified=config.allow_unverified, user_agent=cli_user_agent_string)
83+
sdk = build_socket_sdk(config)
6884

6985
# Suppress urllib3 InsecureRequestWarning when using --allow-unverified
7086
if config.allow_unverified:
@@ -83,7 +99,7 @@ def main_code():
8399
socket_config = SocketConfig(
84100
api_key=config.api_token,
85101
allow_unverified_ssl=config.allow_unverified,
86-
timeout=config.timeout if config.timeout is not None else 1200 # Use CLI timeout if provided
102+
timeout=get_api_request_timeout(config)
87103
)
88104
log.debug("loaded socket_config")
89105
client = CliClient(socket_config)

0 commit comments

Comments
 (0)