19
19
from conjur_api .models import SslVerificationMode , CreateHostData , CreateTokenData , ListMembersOfData , \
20
20
ListPermittedRolesData , ConjurConnectionInfo , Resource , CredentialsData
21
21
from conjur_api .utils .decorators import allow_sync_invocation
22
- from conjur_api .wrappers .http_wrapper import set_header_value
23
- from conjur_api import __version__
22
+ from conjur_api .wrappers .http_wrapper import set_telemetry_header_value
23
+ from importlib . metadata import version , PackageNotFoundError
24
24
25
25
LOGGING_FORMAT = '%(asctime)s %(levelname)s: %(message)s'
26
26
LOGGING_FORMAT_WARNING = 'WARNING: %(message)s'
@@ -34,30 +34,30 @@ class Client:
34
34
35
35
This class is used to construct a client for API interaction
36
36
"""
37
- integration_name = 'SecretsManager Python SDK'
38
- integration_version = __version__
37
+ integration_name = 'SecretsManagerPython SDK'
38
+ try :
39
+ integration_version = version ("conjur_api" )
40
+ except PackageNotFoundError :
41
+ integration_version = 'No Version Found'
39
42
integration_type = 'cybr-secretsmanager'
40
43
vendor_name = 'CyberArk'
41
44
vendor_version = None
42
45
43
- def set_source_name_header (self ):
46
+ def set_telemetry_header (self ):
44
47
"""
45
48
Build http header
46
49
"""
47
- final_string = ""
48
- if Client .integration_name is not None :
49
- final_string += "in=" + Client .integration_name
50
- if Client .integration_type is not None :
51
- final_string += "&it=" + Client .integration_type
52
- if Client .integration_version is not None :
53
- final_string += "&iv=" + Client .integration_version
50
+ final_telemetry_header = ""
54
51
55
- if Client .vendor_name is not None :
56
- final_string += "&vn=" + Client .vendor_name
57
- if Client .vendor_version is not None :
58
- final_string += "&vv=" + Client .vendor_version
52
+ final_telemetry_header += "in=" + Client .integration_name
53
+ final_telemetry_header += "&it=" + Client .integration_type
54
+ final_telemetry_header += "&iv=" + Client .integration_version
59
55
60
- set_header_value (final_string )
56
+ final_telemetry_header += "&vn=" + Client .vendor_name
57
+ if Client .vendor_version is not None :
58
+ final_telemetry_header += "&vv=" + Client .vendor_version
59
+
60
+ set_telemetry_header_value (final_telemetry_header )
61
61
62
62
# The method signature is long but we want to explicitly control
63
63
# what parameters are allowed
@@ -96,28 +96,73 @@ def __init__(
96
96
self .debug = debug
97
97
self ._api = self ._create_api (http_debug , authn_strategy )
98
98
99
- self .set_source_name_header ()
99
+ self .set_telemetry_header ()
100
100
logging .debug ("Client initialized" )
101
101
102
102
def set_integration_name ( self , value ):
103
+ """
104
+ Sets the integration name for the client and updates the telemetry header.
105
+
106
+ This function updates the integration name value for the client and triggers an update to the
107
+ telemetry header to reflect the change.
108
+
109
+ Args:
110
+ value (str): The integration name to be set for the client.
111
+ """
103
112
Client .integration_name = value
104
- self .set_source_name_header ()
113
+ self .set_telemetry_header ()
105
114
106
115
def set_integration_type ( self , value ):
116
+ """
117
+ Sets the integration type for the client and updates the telemetry header.
118
+
119
+ This function updates the integration type value for the client and triggers an update to the
120
+ telemetry header to reflect the change.
121
+
122
+ Args:
123
+ value (str): The integration type to be set for the client.
124
+ """
107
125
Client .integration_type = value
108
- self .set_source_name_header ()
126
+ self .set_telemetry_header ()
109
127
110
128
def set_integration_version ( self , value ):
129
+ """
130
+ Sets the integration version for the client and updates the telemetry header.
131
+
132
+ This function updates the integration version value for the client and triggers an update to the
133
+ telemetry header to reflect the change.
134
+
135
+ Args:
136
+ value (str): The integration version to be set for the client.
137
+ """
111
138
Client .integration_version = value
112
- self .set_source_name_header ()
139
+ self .set_telemetry_header ()
113
140
114
141
def set_vendor_name ( self , value ):
142
+ """
143
+ Sets the vendor name for the client and updates the telemetry header.
144
+
145
+ This function updates the vendor name value for the client and triggers an update to the
146
+ telemetry header to reflect the change.
147
+
148
+ Args:
149
+ value (str): The vendor name to be set for the client.
150
+ """
115
151
Client .vendor_name = value
116
- self .set_source_name_header ()
152
+ self .set_telemetry_header ()
117
153
118
154
def set_vendor_version ( self , value ):
155
+ """
156
+ Sets the vendor version for the client and updates the telemetry header.
157
+
158
+ This function updates the vendor version value for the client and triggers an update to the
159
+ telemetry header to reflect the change.
160
+
161
+ Args:
162
+ value (str): The vendor version to be set for the client.
163
+ """
119
164
Client .vendor_version = value
120
- self .set_source_name_header ()
165
+ self .set_telemetry_header ()
121
166
122
167
@staticmethod
123
168
def configure_logger (debug : bool ):
0 commit comments