22 unicode_literals
33from identify .main .identify_client import BaseIdentifyClient
44from identify .http_clients .sync_client import SyncHttpClient
5- from identify .resources .traffic_type import TrafficType
6- from identify .resources .environment import Environment
7- from identify .resources .attribute import Attribute
8- from identify .resources .identity import Identity
95from 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
1010
1111
1212class SyncIdentifyClient (BaseIdentifyClient ):
@@ -33,167 +33,25 @@ def __init__(self, config):
3333 % ',' .join (missing )
3434 )
3535
36- self . _client = SyncHttpClient (self ._base_url , self ._apikey )
36+ http_client = SyncHttpClient (self ._base_url , self ._apikey )
3737
38- def get_traffic_types (self ):
39- '''
40- Returns a list of TrafficType objects.
41- '''
42- return TrafficType .retrieve_all (self ._client )
38+ self ._traffic_type_client = TrafficTypeMicroClient (http_client )
39+ self ._environment_client = EnvironmentMicroClient (http_client )
40+ self ._attribute_client = AttributeMicroClient (http_client )
41+ self ._identity_client = IdentityMicroClient (http_client )
4342
44- def get_environments (self ):
45- '''
46- Returns a list of environments.
47- '''
48- return Environment .retrieve_all (self ._client )
43+ @property
44+ def traffic_type (self ):
45+ return self ._traffic_type_client
4946
50- def get_attributes_for_traffic_type ( self , traffic_type_id ):
51- '''
52- Returns a list of attributes for a particular traffic type.
47+ @ property
48+ def environment ( self ):
49+ return self . _environment_client
5350
54- :param traffic_type_id: Id of the traffic type whose attributes are to
55- be retrieved.
56- '''
57- return Attribute .retrieve_all (
58- self ._client ,
59- trafficTypeId = traffic_type_id
60- )
61-
62- def create_attribute_for_traffic_type (self , traffic_type_id , attr_data ):
63- '''
64- Creates an attribute for a specific traffic type.
51+ @property
52+ def attribute (self ):
53+ return self ._attribute_client
6554
66- :param traffic_type_id: Id of the traffic type for which an attribute
67- will be created.
68- :param attr_data: Dictionary with the the data to create the new
69- attribute. Should include the followind fields:
70- - 'id': Id of the new attribute
71- - 'displayName': Display Name of the new attribute
72- - 'description': Description of the new attribute
73- - 'dataType': Data type of the new attribute
74- '''
75- return Attribute .create (
76- self ._client ,
77- attr_data .get ('id' ),
78- traffic_type_id ,
79- attr_data .get ('displayName' ),
80- attr_data .get ('description' ),
81- attr_data .get ('dataType' )
82- )
83-
84- def delete_attribute_from_schema (self , traffic_type_id , attribute_id ):
85- '''
86- Delete an attribute from a particular traffic type.
87-
88- :param traffic_type_id: Trafic id of the schema whose attribute
89- will be removed.
90- :param attribute_id: Id of the attribute to be removed.
91- '''
92- return Attribute .delete (self ._client , attribute_id , traffic_type_id )
93-
94- def add_identities (self , traffic_type_id , environment_id , identities ):
95- '''
96- Create Identities for a specific traffic type and environment.
97-
98- :param traffic_type_id: Traffic type id
99- :param environment_id: Environment where the identities will be created.
100- :param identities: Identities to be added. Should be in a dict with
101- the following format:
102- {
103- 'key1': {
104- attribute_id_1a: value_1a,
105- attribute_id_1b: value_1b,
106- },
107- 'key2': {
108- attribute_id_2a: value_2a,
109- attribute_id_2b: value_2b,
110- }
111- }
112- '''
113- return Identity .create_many (
114- self ._client ,
115- traffic_type_id ,
116- environment_id ,
117- identities
118- )
119-
120- def add_identity (self , traffic_type_id , environment_id , key , values ):
121- '''
122- Create a new Identity.
123-
124- :param traffic_type_id: Traffic Type Id
125- :param environment_id: Environment where the identity will be created.
126- :key: Identity key
127- :values: Attribute values for the identity. Should be a dict with
128- the following format:
129- {
130- attribute_id1: value1,
131- attribute_id2: value2,
132- }
133- '''
134- return Identity .create (
135- self ._client ,
136- key ,
137- traffic_type_id ,
138- environment_id ,
139- values
140- )
141-
142- def update_identity (self , traffic_type_id , environment_id , key , values ):
143- '''
144- Update an Identity.
145-
146- :param traffic_type_id: Traffic Type Id
147- :param environment_id: Environment where the identity will be updated.
148- :key: Identity key
149- :values: Attribute values for the identity. Should be a dict with
150- the following format:
151- {
152- attribute_id1: value1,
153- attribute_id2: value2,
154- }
155- '''
156- return Identity .update (
157- self ._client ,
158- key ,
159- traffic_type_id ,
160- environment_id ,
161- values
162- )
163-
164- def patch_identity (self , traffic_type_id , environment_id , key , values ):
165- '''
166- Patch an Identity.
167-
168- :param traffic_type_id: Traffic Type Id
169- :param environment_id: Environment where the identity will be patched.
170- :key: Identity key
171- :values: Attribute values for the identity. Should be a dict with
172- the following format:
173- {
174- attribute_id1: value1,
175- attribute_id2: value2,
176- }
177- '''
178- return Identity .patch (
179- self ._client ,
180- key ,
181- traffic_type_id ,
182- environment_id ,
183- values
184- )
185-
186- def delete_attributes_from_key (self , traffic_type_id , environment_id , key ):
187- '''
188- Delete all attributes for a specific key.
189-
190- :param traffic_type_id: Traffic Type Id,
191- :param environment_id: Enviroment Id,
192- :key: Key whose attributes will be deleted.
193- '''
194- return Identity .delete_all_attributes (
195- self ._client ,
196- traffic_type_id ,
197- environment_id ,
198- key
199- )
55+ @property
56+ def identity (self ):
57+ return self ._identity_client
0 commit comments