Skip to content

Commit ae41ed8

Browse files
committed
update naming conventions
1 parent e4f9e47 commit ae41ed8

50 files changed

Lines changed: 362 additions & 276 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

identify/microclients/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

identify/resources/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _setup_args(self):
6262
'''
6363
le2e_test_file = path.join(
6464
path.dirname(path.realpath(__file__)),
65-
'identify',
65+
'splitapiclient',
6666
'tests',
6767
'e2e',
6868
'e2etests.py'
@@ -88,8 +88,9 @@ def run(self):
8888

8989
# Standard unit test requirements
9090
tests_requires = [
91-
'pytest-mock',
92-
'pytest',
91+
'mock==2.0.0',
92+
'pytest-mock==1.6.0',
93+
'pytest==3.1.3',
9394
]
9495

9596

@@ -101,11 +102,11 @@ def run(self):
101102

102103
# Get version number
103104
with open(path.join(path.abspath(path.dirname(__file__)),
104-
'identify', 'version.py')) as f:
105+
'splitapiclient', 'version.py')) as f:
105106
exec(f.read())
106107
# Run setup!
107108
setup(
108-
name='identify_client',
109+
name='splitapiclient',
109110
version=__version__, # noqa
110111
description='Split.io Identify Python Client',
111112
author='Patricio Echague, Sebastian Arrubia, Martin Redolatti',

identify/http_clients/base_client.py renamed to splitapiclient/http_clients/base_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
import abc
44
import re
55
import six
6-
from identify.util.exceptions import MissingParametersException
6+
from splitapiclient.util.exceptions import MissingParametersException
7+
78

89
class BaseHttpClient(six.with_metaclass(abc.ABCMeta)):
910
'''
1011
Abstrac class providing an interface and generic methods of the HTTP client
11-
responsible for interacting with the Identify APIs
12+
responsible for interacting with the Split APIs
1213
'''
1314

1415
def __init__(self, baseurl, auth_token):
1516
'''
1617
Class constructor. Sotores basic connection information.
1718
18-
:param baseurl: string. Identify host and base url.
19+
:param baseurl: string. Split host and base url.
1920
:param auth_token: string. Authentication token needed to make API
2021
calls.
2122
'''

identify/http_clients/sync_client.py renamed to splitapiclient/http_clients/sync_client.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import json
44
from functools import partial
55
import requests
6-
from identify.http_clients import base_client
7-
from identify.util.logger import LOGGER
8-
from identify.util.exceptions import HTTPResponseError, HTTPNotFoundError, \
9-
HTTPIncorrectParametersError, HTTPUnauthorizedError, \
10-
IdentifyBackendUnreachableError
6+
from splitapiclient.http_clients import base_client
7+
from splitapiclient.util.logger import LOGGER
8+
from splitapiclient.util.exceptions import HTTPResponseError, \
9+
HTTPNotFoundError, HTTPIncorrectParametersError, HTTPUnauthorizedError, \
10+
SplitBackendUnreachableError
1111

1212

1313
class SyncHttpClient(base_client.BaseHttpClient):
@@ -54,18 +54,18 @@ def _handle_invalid_response(self, response):
5454
if exc:
5555
raise exc()
5656
else:
57-
raise HTTPResponseError
57+
raise HTTPResponseError()
5858

5959
def _handle_connection_error(self, e):
6060
'''
61-
Handle error when attempting to connect to identify backend.
61+
Handle error when attempting to connect to split backend.
6262
Logs exception thrown by requests module, and raises an
63-
IdentifyBackendUnreachableError error, so that it can be caught
64-
by using the top level IdentifyException
63+
SplitBackendUnreachableError error, so that it can be caught
64+
by using the top level SplitException
6565
'''
6666
LOGGER.debug(e)
67-
raise IdentifyBackendUnreachableError(
68-
'Unable to reach Identify backend'
67+
raise SplitBackendUnreachableError(
68+
'Unable to reach Split backend'
6969
)
7070

7171
def make_request(self, endpoint, body=None, **kwargs):
@@ -97,10 +97,9 @@ def make_request(self, endpoint, body=None, **kwargs):
9797
# Make the actual HTTP call!
9898
try:
9999
response = method(url, headers=headers)
100+
LOGGER.debug('RESPONSE: ' + response.text)
100101
except Exception as e:
101102
return self._handle_connection_error(e)
102-
finally:
103-
LOGGER.debug('RESPONSE: ' + response.text)
104103

105104
if not response.status_code == 200:
106105
LOGGER.warning('RESPONSE CODE: %s' % response.status_code)
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from identify.main.identify_sync_client import SyncIdentifyClient
1+
from splitapiclient.main.sync_apiclient import SyncApiClient
22

33

44
def get_client(config):
55
'''
6-
Entry point for the Identify API client
6+
Entry point for the Split API client
77
'''
88
_async = config.get('async', False)
99
if _async:
1010
raise Exception('Async client not yet implemented')
1111

12-
return SyncIdentifyClient(config)
12+
return SyncApiClient(config)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import abc
44

55

6-
class BaseIdentifyClient:
6+
class BaseApiClient:
77
'''
88
'''
99
__metaclass__ = abc.ABCMeta
@@ -13,17 +13,17 @@ def __init__(self, config):
1313
pass
1414

1515
@abc.abstractproperty
16-
def traffic_type(self):
16+
def traffic_types(self):
1717
pass
1818

1919
@abc.abstractproperty
20-
def environment(self):
20+
def environments(sself):
2121
pass
2222

2323
@abc.abstractproperty
24-
def attribute(self):
24+
def attributes(self):
2525
pass
2626

2727
@abc.abstractproperty
28-
def identity(self):
28+
def identities(self):
2929
pass
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from __future__ import absolute_import, division, print_function, \
22
unicode_literals
3-
from identify.main.identify_client import BaseIdentifyClient
4-
from identify.http_clients.sync_client import SyncHttpClient
5-
from identify.util.exceptions import InsufficientConfigArgumentsException
6-
from identify.microclients import TrafficTypeMicroClient
7-
from identify.microclients import EnvironmentMicroClient
8-
from identify.microclients import IdentityMicroClient
9-
from identify.microclients import AttributeMicroClient
3+
from splitapiclient.main.apiclient import BaseApiClient
4+
from splitapiclient.http_clients.sync_client import SyncHttpClient
5+
from splitapiclient.util.exceptions import InsufficientConfigArgumentsException
6+
from splitapiclient.microclients import TrafficTypeMicroClient
7+
from splitapiclient.microclients import EnvironmentMicroClient
8+
from splitapiclient.microclients import IdentityMicroClient
9+
from splitapiclient.microclients import AttributeMicroClient
1010

1111

12-
class SyncIdentifyClient(BaseIdentifyClient):
12+
class SyncApiClient(BaseApiClient):
1313
'''
14-
Synchronous Identify API client
14+
Synchronous Split API client
1515
'''
1616

1717
def __init__(self, config):
@@ -41,17 +41,17 @@ def __init__(self, config):
4141
self._identity_client = IdentityMicroClient(http_client)
4242

4343
@property
44-
def traffic_type(self):
44+
def traffic_types(self):
4545
return self._traffic_type_client
4646

4747
@property
48-
def environment(self):
48+
def environments(self):
4949
return self._environment_client
5050

5151
@property
52-
def attribute(self):
52+
def attributes(self):
5353
return self._attribute_client
5454

5555
@property
56-
def identity(self):
56+
def identities(self):
5757
return self._identity_client

0 commit comments

Comments
 (0)