|
2 | 2 | unicode_literals |
3 | 3 | from identify.main.identify_client import BaseIdentifyClient |
4 | 4 | from 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 |
9 | 5 | from identify.util.exceptions import InsufficientConfigArgumentsException |
10 | | - |
11 | | - |
12 | | -class TrafficTypeMicroClient: |
13 | | - ''' |
14 | | - ''' |
15 | | - |
16 | | - def __init__(self, http_client): |
17 | | - ''' |
18 | | - ''' |
19 | | - self._http_client = http_client |
20 | | - |
21 | | - def get_all(self): |
22 | | - ''' |
23 | | - Returns a list of TrafficType objects. |
24 | | - ''' |
25 | | - return TrafficType.retrieve_all(self._http_client) |
26 | | - |
27 | | - |
28 | | -class EnvironmentMicroClient: |
29 | | - ''' |
30 | | - ''' |
31 | | - |
32 | | - def __init__(self, http_client): |
33 | | - ''' |
34 | | - ''' |
35 | | - self._http_client = http_client |
36 | | - |
37 | | - def get_all(self): |
38 | | - ''' |
39 | | - Returns a list of environments. |
40 | | - ''' |
41 | | - return Environment.retrieve_all(self._http_client) |
42 | | - |
43 | | - |
44 | | -class AttributeMicroClient: |
45 | | - ''' |
46 | | - ''' |
47 | | - |
48 | | - def __init__(self, http_client): |
49 | | - ''' |
50 | | - ''' |
51 | | - self._http_client = http_client |
52 | | - |
53 | | - def get_all(self, traffic_type_id): |
54 | | - ''' |
55 | | - Returns a list of attributes for a particular traffic type. |
56 | | -
|
57 | | - :param traffic_type_id: Id of the traffic type whose attributes are to |
58 | | - be retrieved. |
59 | | - ''' |
60 | | - return Attribute.retrieve_all( |
61 | | - self._http_client, |
62 | | - trafficTypeId=traffic_type_id |
63 | | - ) |
64 | | - |
65 | | - def create(self, traffic_type_id, attr_id, display_name, description, |
66 | | - data_type, is_searchable): |
67 | | - ''' |
68 | | - Creates an attribute for a specific traffic type. |
69 | | -
|
70 | | - :param traffic_type_id: Id of the traffic type for which an attribute |
71 | | - will be created. |
72 | | - :param attr_id: string. New attribute's Id |
73 | | - :param display_name: string. New attribute's display name |
74 | | - :param description: string. New attribute's description |
75 | | - :param data_type: string. New attribute's data type |
76 | | - :param is_searchable: string. |
77 | | - ''' |
78 | | - return Attribute.create( |
79 | | - self._http_client, |
80 | | - attr_id, |
81 | | - traffic_type_id, |
82 | | - display_name, |
83 | | - description, |
84 | | - data_type, |
85 | | - is_searchable |
86 | | - ) |
87 | | - |
88 | | - def delete(self, traffic_type_id, attribute_id): |
89 | | - ''' |
90 | | - Delete an attribute from a particular traffic type. |
91 | | -
|
92 | | - :param traffic_type_id: Trafic id of the schema whose attribute |
93 | | - will be removed. |
94 | | - :param attribute_id: Id of the attribute to be removed. |
95 | | - ''' |
96 | | - return Attribute.delete( |
97 | | - self._http_client, |
98 | | - attribute_id, |
99 | | - traffic_type_id |
100 | | - ) |
101 | | - |
102 | | - |
103 | | -class IdentityMicroClient: |
104 | | - ''' |
105 | | - ''' |
106 | | - |
107 | | - def __init__(self, http_client): |
108 | | - ''' |
109 | | - ''' |
110 | | - self._http_client = http_client |
111 | | - |
112 | | - def add_many(self, traffic_type_id, environment_id, identities, |
113 | | - organization_id=None): |
114 | | - ''' |
115 | | - Create Identities for a specific traffic type and environment. |
116 | | -
|
117 | | - :param traffic_type_id: Traffic type id |
118 | | - :param environment_id: Environment where the identities will be created. |
119 | | - :param identities: Identities to be added. Should be in a dict with |
120 | | - the following format: |
121 | | - { |
122 | | - 'key1': { |
123 | | - attribute_id_1a: value_1a, |
124 | | - attribute_id_1b: value_1b, |
125 | | - }, |
126 | | - 'key2': { |
127 | | - attribute_id_2a: value_2a, |
128 | | - attribute_id_2b: value_2b, |
129 | | - } |
130 | | - } |
131 | | - ''' |
132 | | - return Identity.create_many( |
133 | | - self._http_client, |
134 | | - traffic_type_id, |
135 | | - environment_id, |
136 | | - identities, |
137 | | - organization_id |
138 | | - ) |
139 | | - |
140 | | - def add(self, traffic_type_id, environment_id, key, values, |
141 | | - organization_id=None): |
142 | | - ''' |
143 | | - Create a new Identity. |
144 | | -
|
145 | | - :param traffic_type_id: Traffic Type Id |
146 | | - :param environment_id: Environment where the identity will be created. |
147 | | - :key: Identity key |
148 | | - :values: Attribute values for the identity. Should be a dict with |
149 | | - the following format: |
150 | | - { |
151 | | - attribute_id1: value1, |
152 | | - attribute_id2: value2, |
153 | | - } |
154 | | - ''' |
155 | | - return Identity.create( |
156 | | - self._http_client, |
157 | | - key, |
158 | | - traffic_type_id, |
159 | | - environment_id, |
160 | | - values, |
161 | | - organization_id |
162 | | - ) |
163 | | - |
164 | | - def update(self, traffic_type_id, environment_id, key, values, |
165 | | - organization_id=None): |
166 | | - ''' |
167 | | - Update an Identity. |
168 | | -
|
169 | | - :param traffic_type_id: Traffic Type Id |
170 | | - :param environment_id: Environment where the identity will be updated. |
171 | | - :key: Identity key |
172 | | - :values: Attribute values for the identity. Should be a dict with |
173 | | - the following format: |
174 | | - { |
175 | | - attribute_id1: value1, |
176 | | - attribute_id2: value2, |
177 | | - } |
178 | | - ''' |
179 | | - return Identity.update( |
180 | | - self._http_client, |
181 | | - key, |
182 | | - traffic_type_id, |
183 | | - environment_id, |
184 | | - values, |
185 | | - organization_id |
186 | | - ) |
187 | | - |
188 | | - def patch(self, traffic_type_id, environment_id, key, values, |
189 | | - organization_id=None): |
190 | | - ''' |
191 | | - Patch an Identity. |
192 | | -
|
193 | | - :param traffic_type_id: Traffic Type Id |
194 | | - :param environment_id: Environment where the identity will be patched. |
195 | | - :key: Identity key |
196 | | - :values: Attribute values for the identity. Should be a dict with |
197 | | - the following format: |
198 | | - { |
199 | | - attribute_id1: value1, |
200 | | - attribute_id2: value2, |
201 | | - } |
202 | | - ''' |
203 | | - return Identity.patch( |
204 | | - self._http_client, |
205 | | - key, |
206 | | - traffic_type_id, |
207 | | - environment_id, |
208 | | - values, |
209 | | - organization_id |
210 | | - ) |
211 | | - |
212 | | - def delete_attributes(self, traffic_type_id, environment_id, key): |
213 | | - ''' |
214 | | - Delete all attributes for a specific key. |
215 | | -
|
216 | | - :param traffic_type_id: Traffic Type Id, |
217 | | - :param environment_id: Enviroment Id, |
218 | | - :key: Key whose attributes will be deleted. |
219 | | - ''' |
220 | | - return Identity.delete_all_attributes( |
221 | | - self._http_client, |
222 | | - traffic_type_id, |
223 | | - environment_id, |
224 | | - key |
225 | | - ) |
| 6 | +from identify.microclients import TrafficTypeMicroClient |
| 7 | +from identify.microclients import EnvironmentMicroClient |
| 8 | +from identify.microclients import IdentityMicroClient |
| 9 | +from identify.microclients import AttributeMicroClient |
226 | 10 |
|
227 | 11 |
|
228 | 12 | class SyncIdentifyClient(BaseIdentifyClient): |
|
0 commit comments