Skip to content

Commit 89e58d9

Browse files
authored
Merge pull request #365 from splitio/dw-update-apikey-splitio.client
updated apikey in splitio.client classes
2 parents 323da96 + 481e4a5 commit 89e58d9

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

splitio/client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def track(self, key, traffic_type, event_type, value=None, properties=None):
377377
start = get_current_epoch_time_ms()
378378
key = input_validator.validate_track_key(key)
379379
event_type = input_validator.validate_event_type(event_type)
380-
should_validate_existance = self.ready and self._factory._apikey != 'localhost' # pylint: disable=protected-access
380+
should_validate_existance = self.ready and self._factory._sdk_key != 'localhost' # pylint: disable=protected-access
381381
traffic_type = input_validator.validate_traffic_type(
382382
traffic_type,
383383
should_validate_existance,

splitio/client/config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
}
6363

6464

65-
def _parse_operation_mode(apikey, config):
65+
def _parse_operation_mode(sdk_key, config):
6666
"""
6767
Process incoming config to determine operation mode and storage type
6868
@@ -72,7 +72,7 @@ def _parse_operation_mode(apikey, config):
7272
:returns: operation mode and storage type
7373
:rtype: Tuple (str, str)
7474
"""
75-
if apikey == 'localhost':
75+
if sdk_key == 'localhost':
7676
_LOGGER.debug('Using Localhost operation mode')
7777
return 'localhost', 'localhost'
7878

@@ -119,20 +119,20 @@ def _sanitize_impressions_mode(storage_type, mode, refresh_rate=None):
119119
return mode, refresh_rate
120120

121121

122-
def sanitize(apikey, config):
122+
def sanitize(sdk_key, config):
123123
"""
124124
Look for inconsistencies or ill-formed configs and tune it accordingly.
125125
126-
:param apikey: customer's apikey
127-
:type apikey: str
126+
:param sdk_key: sdk key
127+
:type sdk_key: str
128128
129129
:param config: DEFAULT + user supplied config
130130
:type config: dict
131131
132132
:returns: sanitized config
133133
:rtype: dict
134134
"""
135-
config['operationMode'], config['storageType'] = _parse_operation_mode(apikey, config)
135+
config['operationMode'], config['storageType'] = _parse_operation_mode(sdk_key, config)
136136
processed = DEFAULT_CONFIG.copy()
137137
processed.update(config)
138138
imp_mode, imp_rate = _sanitize_impressions_mode(config['storageType'], config.get('impressionsMode'),

splitio/client/factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class SplitFactory(object): # pylint: disable=too-many-instance-attributes
9191

9292
def __init__( # pylint: disable=too-many-arguments
9393
self,
94-
apikey,
94+
sdk_key,
9595
storages,
9696
labels_enabled,
9797
recorder,
@@ -120,7 +120,7 @@ def __init__( # pylint: disable=too-many-arguments
120120
:param preforked_initialization: Whether should be instantiated as preforked or not.
121121
:type preforked_initialization: bool
122122
"""
123-
self._apikey = apikey
123+
self._sdk_key = sdk_key
124124
self._storages = storages
125125
self._labels_enabled = labels_enabled
126126
self._sync_manager = sync_manager
@@ -253,7 +253,7 @@ def _wait_for_tasks_to_stop():
253253
finally:
254254
self._status = Status.DESTROYED
255255
with _INSTANTIATED_FACTORIES_LOCK:
256-
_INSTANTIATED_FACTORIES.subtract([self._apikey])
256+
_INSTANTIATED_FACTORIES.subtract([self._sdk_key])
257257

258258
@property
259259
def destroyed(self):

splitio/client/input_validator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,20 +449,20 @@ def filter(self, record):
449449
return record.name not in ('SegmentsAPI', 'HttpClient')
450450

451451

452-
def validate_factory_instantiation(sdkkey):
452+
def validate_factory_instantiation(sdk_key):
453453
"""
454454
Check if the factory if being instantiated with the appropriate arguments.
455455
456-
:param apikey: str
457-
:type apikey: str
456+
:param sdk_key: str
457+
:type sdk_key: str
458458
:return: bool
459459
:rtype: True|False
460460
"""
461-
if sdkkey == 'localhost':
461+
if sdk_key == 'localhost':
462462
return True
463-
if (not _check_not_null(sdkkey, 'sdkkey', 'factory_instantiation')) or \
464-
(not _check_is_string(sdkkey, 'sdkkey', 'factory_instantiation')) or \
465-
(not _check_string_not_empty(sdkkey, 'sdkkey', 'factory_instantiation')):
463+
if (not _check_not_null(sdk_key, 'sdk_key', 'factory_instantiation')) or \
464+
(not _check_is_string(sdk_key, 'sdk_key', 'factory_instantiation')) or \
465+
(not _check_string_not_empty(sdk_key, 'sdk_key', 'factory_instantiation')):
466466
return False
467467
return True
468468

tests/client/test_input_validator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def test_track(self, mocker):
553553
telemetry_producer.get_telemetry_init_producer(),
554554
mocker.Mock()
555555
)
556-
factory._apikey = 'some-test'
556+
factory._sdk_key = 'some-test'
557557

558558
client = Client(factory, recorder)
559559
client._event_storage = event_storage
@@ -728,14 +728,14 @@ def test_track(self, mocker):
728728
)]
729729

730730
# Test that it does not warn when in localhost mode.
731-
factory._apikey = 'localhost'
731+
factory._sdk_key = 'localhost'
732732
_logger.reset_mock()
733733
assert client.track("some_key", "traffic_type", "event_type", None) is True
734734
assert _logger.error.mock_calls == []
735735
assert _logger.warning.mock_calls == []
736736

737737
# Test that it does not warn when not in localhost mode and not ready
738-
factory._apikey = 'not-localhost'
738+
factory._sdk_key = 'not-localhost'
739739
ready_property.return_value = False
740740
type(factory).ready = ready_property
741741
_logger.reset_mock()
@@ -1156,19 +1156,19 @@ def test_input_validation_factory(self, mocker):
11561156

11571157
assert get_factory(None) is None
11581158
assert logger.error.mock_calls == [
1159-
mocker.call("%s: you passed a null %s, %s must be a non-empty string.", 'factory_instantiation', 'sdkkey', 'sdkkey')
1159+
mocker.call("%s: you passed a null %s, %s must be a non-empty string.", 'factory_instantiation', 'sdk_key', 'sdk_key')
11601160
]
11611161

11621162
logger.reset_mock()
11631163
assert get_factory('') is None
11641164
assert logger.error.mock_calls == [
1165-
mocker.call("%s: you passed an empty %s, %s must be a non-empty string.", 'factory_instantiation', 'sdkkey', 'sdkkey')
1165+
mocker.call("%s: you passed an empty %s, %s must be a non-empty string.", 'factory_instantiation', 'sdk_key', 'sdk_key')
11661166
]
11671167

11681168
logger.reset_mock()
11691169
assert get_factory(True) is None
11701170
assert logger.error.mock_calls == [
1171-
mocker.call("%s: you passed an invalid %s, %s must be a non-empty string.", 'factory_instantiation', 'sdkkey', 'sdkkey')
1171+
mocker.call("%s: you passed an invalid %s, %s must be a non-empty string.", 'factory_instantiation', 'sdk_key', 'sdk_key')
11721172
]
11731173

11741174
logger.reset_mock()

0 commit comments

Comments
 (0)