@@ -41,7 +41,7 @@ class APIClientArgs:
4141 # single_conn is set to True by default, when work on parallel set to False
4242 def __init__ (self , port = None , fingerprint = None , sid = None , server = "127.0.0.1" , http_debug_level = 0 ,
4343 api_calls = None , debug_file = "" , proxy_host = None , proxy_port = 8080 ,
44- api_version = None , unsafe = False , unsafe_auto_accept = False , context = "web_api" , single_conn = True ):
44+ api_version = None , unsafe = False , unsafe_auto_accept = False , context = "web_api" , single_conn = True , user_agent = "python-api-wrapper" ):
4545 self .port = port
4646 # management server fingerprint
4747 self .fingerprint = fingerprint
@@ -69,6 +69,8 @@ def __init__(self, port=None, fingerprint=None, sid=None, server="127.0.0.1", ht
6969 self .context = context
7070 # Indicates that the client should use single HTTPS connection
7171 self .single_conn = single_conn
72+ # User agent will be use in api call request header
73+ self .user_agent = user_agent
7274
7375
7476class APIClient :
@@ -115,6 +117,9 @@ def __init__(self, api_client_args=None):
115117 self .conn = None
116118 # Indicates that the client should use single HTTPS connection
117119 self .single_conn = api_client_args .single_conn
120+ # User agent will be use in api call request header
121+ self .user_agent = api_client_args .user_agent
122+
118123
119124 def __enter__ (self ):
120125 return self
@@ -290,7 +295,7 @@ def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=
290295
291296 # Set headers
292297 _headers = {
293- "User-Agent" : "python-api-wrapper" ,
298+ "User-Agent" : self . user_agent ,
294299 "Accept" : "*/*" ,
295300 "Content-Type" : "application/json" ,
296301 "Content-Length" : len (_data ),
0 commit comments