Skip to content

Commit 7e1f9c1

Browse files
authored
Merge pull request #6 from splitio/add-split-owners
Added support for owners array in split info.
2 parents c9b8e70 + 1c2e43e commit 7e1f9c1

4 files changed

Lines changed: 78 additions & 4 deletions

File tree

splitapiclient/microclients/split_microclient.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ class SplitMicroClient:
4343
'query_string': [],
4444
'response': True,
4545
},
46+
'get': {
47+
'method': 'GET',
48+
'url_template': ('splits/ws/{workspaceId}/{splitName}'),
49+
'headers': [{
50+
'name': 'Authorization',
51+
'template': 'Bearer {value}',
52+
'required': True,
53+
}],
54+
'query_string': [],
55+
'response': True,
56+
},
4657
'all_items': {
4758
'method': 'GET',
4859
'url_template': 'splits/ws/{workspaceId}?limit=20&offset={offset}{tags}',
@@ -139,6 +150,24 @@ def find(self, split_name, workspace_id, tags):
139150
LOGGER.error("Split Name does not exist")
140151
return None
141152

153+
def get(self, split_name, workspace_id):
154+
'''
155+
get a split details
156+
157+
:param split_name: split name
158+
:param workspace_id: workspace id
159+
160+
:returns: split object
161+
:rtype: Split
162+
'''
163+
response = self._http_client.make_request(
164+
self._endpoint['get'],
165+
workspaceId = workspace_id,
166+
splitName = split_name
167+
)
168+
response['workspaceId'] = workspace_id
169+
return Split(response, workspace_id, self._http_client)
170+
142171
def add(self, split, traffic_type_name, workspace_id):
143172
'''
144173
add a split

splitapiclient/resources/split.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class Split(BaseResource):
2121
'name': 'string'
2222
},
2323
'rolloutStatusTimestamp': 'number',
24-
'tags': [{'name': 'string'}]
24+
'tags': [{'name': 'string'}],
25+
'owners': [{'id':'string','type':'string'}]
2526
}
2627

2728
def __init__(self, data=None, workspace_id=None, client=None):
@@ -39,6 +40,7 @@ def __init__(self, data=None, workspace_id=None, client=None):
3940
self._id = data.get('id') if 'id' in data else None
4041
self._rolloutStatus = data.get('rolloutStatus') if 'rolloutStatus' in data else {}
4142
self._rolloutStatusTimestamp = data.get('rolloutStatusTimestamp') if 'rolloutStatusTimestamp' in data else 0
43+
self._owners = data.get('owners') if 'owners' in data else []
4244

4345
@property
4446
def name(self):

splitapiclient/tests/microclients/splitt_microclient_test.py renamed to splitapiclient/tests/microclients/split_microclient_test.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ def test_list(self, mocker):
2020
'id': None,
2121
'rolloutStatus': None,
2222
'rolloutStatusTimestamp': None,
23-
'tags': None
23+
'tags': None,
24+
'owners': None
2425
}, {
2526
'name': 'sp2',
2627
'description': 'desc',
2728
'creationTime' : None,
2829
'id': None,
2930
'rolloutStatus': None,
3031
'rolloutStatusTimestamp': None,
31-
'tags': None
32+
'tags': None,
33+
'owners': None
3234
}],
3335
'offset': 1,
3436
'totalCount': 2,
@@ -55,6 +57,7 @@ def test_list(self, mocker):
5557
'rolloutStatus': None,
5658
'rolloutStatusTimestamp': None,
5759
'tags': None,
60+
'owners': None,
5861
'id': None
5962
}, {
6063
'name': 'sp2',
@@ -65,8 +68,47 @@ def test_list(self, mocker):
6568
'rolloutStatus': None,
6669
'rolloutStatusTimestamp': None,
6770
'tags': None,
71+
'owners': None,
6872
'id': None
6973
}]
7074

7175
assert result[0].to_dict() == data[0]
7276
assert result[1].to_dict() == data[1]
77+
78+
def test_get(self, mocker):
79+
'''
80+
'''
81+
mocker.patch('splitapiclient.http_clients.sync_client.SyncHttpClient.make_request')
82+
sc = SyncHttpClient('abc', 'abc')
83+
emc = SplitMicroClient(sc)
84+
data = {
85+
'name': 'sp1',
86+
'description': 'desc',
87+
'creationTime' : None,
88+
'id': None,
89+
'rolloutStatus': None,
90+
'rolloutStatusTimestamp': None,
91+
'tags': None,
92+
'owners': None
93+
}
94+
95+
SyncHttpClient.make_request.return_value = data
96+
result = emc.get('sp1', 'ws_id')
97+
SyncHttpClient.make_request.assert_called_once_with(
98+
SplitMicroClient._endpoint['get'],
99+
workspaceId = 'ws_id',
100+
splitName = 'sp1'
101+
)
102+
data = {
103+
'name': 'sp1',
104+
'description': 'desc',
105+
'trafficType' : None,
106+
'creationTime' : None,
107+
'id': 'sp1',
108+
'rolloutStatus': None,
109+
'rolloutStatusTimestamp': None,
110+
'tags': None,
111+
'owners': None,
112+
'id': None
113+
}
114+
assert result.to_dict() == data

splitapiclient/tests/resources/test_split.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def test_update_description(self, mocker):
131131
'id': 'split1',
132132
'rolloutStatus': None,
133133
'rolloutStatusTimestamp': None,
134-
'tags': None
134+
'tags': None,
135+
'owners': None
135136
}
136137

137138
http_client_mock = mocker.Mock(spec=BaseHttpClient)

0 commit comments

Comments
 (0)