Skip to content

Commit e28c5b6

Browse files
committed
Attribute and Identity objects fixes
1 parent 2fba16f commit e28c5b6

22 files changed

Lines changed: 166 additions & 70 deletions

.DS_Store

0 Bytes
Binary file not shown.

splitapiclient/.DS_Store

0 Bytes
Binary file not shown.

splitapiclient/microclients/attribute_microclient.py

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AttributeMicroClient:
3232
},
3333
'delete': {
3434
'method': 'DELETE',
35-
'url_template': 'schema/ws/{workspaceId}/trafficTypes/{trafficTypeId}/schema/{attributeId}',
35+
'url_template': 'schema/ws/{workspaceId}/trafficTypes/{trafficTypeId}/{attributeId}',
3636
'headers': [{
3737
'name': 'Authorization',
3838
'template': 'Bearer {value}',
@@ -48,20 +48,43 @@ def __init__(self, http_client):
4848
'''
4949
self._http_client = http_client
5050

51-
def list(self, workspace_id, traffic_type_id):
51+
def list(self, traffic_type_id, workspace_id):
5252
'''
53-
Returns a list of TrafficType objects.
53+
Returns a list of Attribute objects.
5454
5555
:param traffic_type_id: Id of the TrafficType whose attributes will be
5656
returned
57-
:rtype: list(TrafficType)
57+
:rtype: list(Attribute)
5858
'''
5959
response = self._http_client.make_request(
6060
self._endpoint['all_items'],
61-
trafficTypeId=traffic_type_id,
62-
workspaceId=workspace_id
61+
trafficTypeId = traffic_type_id,
62+
workspaceId = workspace_id
63+
)
64+
final_array=[]
65+
for item in response:
66+
item['workspaceId'] = workspace_id
67+
final_array.append(Attribute(item))
68+
return final_array
69+
70+
def find(self, attribute_id, traffic_type_name, workspace_id):
71+
'''
72+
Find Attribute in a TrafficType for a workspace
73+
74+
:returns: Attribute object
75+
:rtype: Attribute
76+
'''
77+
response = self._http_client.make_request(
78+
self._endpoint['all_items'],
79+
trafficTypeId = traffic_type_name,
80+
workspaceId = workspace_id
6381
)
64-
return [Attribute(item, self._http_client) for item in response]
82+
for item in response:
83+
if item['id']==attribute_id:
84+
item['workspaceId'] = workspace_id
85+
return Attribute(item, self._http_client)
86+
LOGGER.error("Attribute Id does not exist")
87+
return None
6588

6689
def save(self, attribute):
6790
'''
@@ -73,15 +96,15 @@ def save(self, attribute):
7396
:returns: newly created attribute
7497
:rtype: Attribute
7598
'''
99+
wsId = attribute._workspace_id
76100
data = as_dict(attribute)
77-
wsId=data.get('workspaceId')
78101
del data['workspaceId']
79102
del data['isSearchable']
80103
response = self._http_client.make_request(
81104
self._endpoint['create'],
82105
data,
83-
trafficTypeId=data.get('trafficTypeId'),
84-
workspaceId=wsId
106+
trafficTypeId = data.get('trafficTypeId'),
107+
workspaceId = wsId
85108
)
86109
return Attribute(response, self._http_client)
87110

@@ -108,6 +131,6 @@ def delete_by_instance(self, attribute):
108131
data = as_dict(attribute)
109132
return self.delete(
110133
data.get('id'),
111-
data.get('workspaceId'),
134+
attribute._workspace_id,
112135
data.get('trafficTypeId')
113136
)

splitapiclient/microclients/group_microclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def create_group(self, data):
111111
self._endpoint['create_group'],
112112
body = data
113113
)
114-
return response
114+
return Group(response)
115115

116116
def delete_group(self, group_id):
117117
'''

splitapiclient/microclients/segment_definition_microclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SegmentDefinitionMicroClient:
1010
_endpoint = {
1111
'all_items': {
1212
'method': 'GET',
13-
'url_template': 'segments/ws/{workspaceId}/environments/{environmentId}?limit=20&offset={offset}',
13+
'url_template': 'segments/ws/{workspaceId}/environments/{environmentId}?limit=50&offset={offset}',
1414
'headers': [{
1515
'name': 'Authorization',
1616
'template': 'Bearer {value}',

splitapiclient/microclients/segment_microclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class SegmentMicroClient:
5555
},
5656
'all_items': {
5757
'method': 'GET',
58-
'url_template': 'segments/ws/{workspaceId}?limit=20&offset={offset}',
58+
'url_template': 'segments/ws/{workspaceId}?limit=50&offset={offset}',
5959
'headers': [{
6060
'name': 'Authorization',
6161
'template': 'Bearer {value}',

splitapiclient/microclients/traffic_type_microclient.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,20 @@ def list(self, workspace_id):
3939
workspaceId = workspace_id
4040
)
4141
return [TrafficType(item, self._http_client) for item in response]
42+
43+
def find(self, traffic_type_name, workspace_id):
44+
'''
45+
Find TrafficType in workspace
46+
47+
:returns: TrafficType object
48+
:rtype: TrafficType
49+
'''
50+
response = self._http_client.make_request(
51+
self._endpoint['all_items'],
52+
workspaceId = workspace_id
53+
)
54+
for item in response:
55+
if item['name']==traffic_type_name:
56+
return TrafficType(item, workspace_id, self._http_client)
57+
LOGGER.error("TrafficType Name does not exist")
58+
return None

splitapiclient/microclients/user_microclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def find(self, user_email):
122122
for item in self.list('ACTIVE'):
123123
if item._email == user_email:
124124
return item
125-
for item in self.list('DEACTIVED'):
125+
for item in self.list('DEACTIVATED'):
126126
if item._email == user_email:
127127
return item
128128
for item in self.list('PENDING'):

splitapiclient/microclients/workspace_microclient.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def list(self):
5151
self._endpoint['all_items'],
5252
offset = offset_val
5353
)
54-
print(response)
5554
for item in response['objects']:
5655
final_list.append(item)
5756
offset = int(response['offset'])

splitapiclient/resources/attribute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def is_searchable(self, new):
7272

7373
def save(self, apiclient=None):
7474
'''
75-
Delete this attribute
75+
Save this attribute
7676
7777
:param apiclient: If this instance wasn't returned by the client,
7878
the IdentifyClient instance should be passed in order to perform the

0 commit comments

Comments
 (0)