@@ -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 )
0 commit comments