aepp 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aepp/__init__.py +24 -24
- aepp/__version__.py +1 -1
- aepp/classmanager.py +59 -29
- aepp/cli/__main__.py +106 -103
- aepp/datatypemanager.py +60 -27
- aepp/deletion.py +22 -22
- aepp/fieldgroupmanager.py +100 -65
- aepp/schemamanager.py +140 -78
- aepp/synchronizer.py +79 -59
- {aepp-0.5.1.dist-info → aepp-0.5.2.dist-info}/METADATA +2 -1
- {aepp-0.5.1.dist-info → aepp-0.5.2.dist-info}/RECORD +15 -15
- {aepp-0.5.1.dist-info → aepp-0.5.2.dist-info}/WHEEL +0 -0
- {aepp-0.5.1.dist-info → aepp-0.5.2.dist-info}/entry_points.txt +0 -0
- {aepp-0.5.1.dist-info → aepp-0.5.2.dist-info}/licenses/LICENSE +0 -0
- {aepp-0.5.1.dist-info → aepp-0.5.2.dist-info}/top_level.txt +0 -0
aepp/schemamanager.py
CHANGED
|
@@ -39,7 +39,7 @@ class SchemaManager:
|
|
|
39
39
|
schemaClass:str="https://ns.adobe.com/xdm/context/profile",
|
|
40
40
|
config: Union[dict,ConnectObject] = aepp.config.config_object,
|
|
41
41
|
description : str = "powered by aepp",
|
|
42
|
-
localFolder:str=None,
|
|
42
|
+
localFolder:str|list|None=None,
|
|
43
43
|
sandbox:str=None,
|
|
44
44
|
**kwargs
|
|
45
45
|
)->None:
|
|
@@ -57,7 +57,7 @@ class SchemaManager:
|
|
|
57
57
|
Possible default value: "https://ns.adobe.com/xdm/context/experienceevent", "https://ns.adobe.com/xdm/context/segmentdefinition"
|
|
58
58
|
config : OPTIONAL : The config object in case you want to override the configuration.
|
|
59
59
|
description : OPTIONAL : To provide a description to your schema
|
|
60
|
-
localFolder : OPTIONAL : If you want to use local storage to create all the connections between schema and field groups, classes and datatypes
|
|
60
|
+
localFolder : OPTIONAL : If you want to use local storage to create all the connections between schema and field groups, classes and datatypes. Can be a set of folders.
|
|
61
61
|
sandbox : OPTIONAL : If you use localFolder, you can specific the sandbox.
|
|
62
62
|
"""
|
|
63
63
|
self.fieldGroupIds=[]
|
|
@@ -72,17 +72,20 @@ class SchemaManager:
|
|
|
72
72
|
elif config is not None and localFolder is None:
|
|
73
73
|
self.schemaAPI = Schema(config=config)
|
|
74
74
|
elif localFolder is not None:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
if isinstance(localFolder, str):
|
|
76
|
+
self.localfolder = [Path(localFolder)]
|
|
77
|
+
else:
|
|
78
|
+
self.localfolder = [Path(folder) for folder in localFolder]
|
|
79
|
+
if any([folder.exists() is False for folder in self.localfolder]):
|
|
80
|
+
raise Exception(f"One of the local folders {self.localfolder} does not exist. Please create it and extract your sandbox before using it.")
|
|
78
81
|
self.schemaAPI = None
|
|
79
|
-
self.schemaFolder =
|
|
80
|
-
self.fieldgroupFolder =
|
|
81
|
-
self.fieldgroupGlobalFolder =
|
|
82
|
-
self.classFolder =
|
|
83
|
-
self.descriptorFolder =
|
|
84
|
-
if
|
|
85
|
-
raise Exception(f"{self.schemaFolder} or {self.fieldgroupFolder} or {self.classFolder} does not exist. Please create it and extract your sandbox before using it.")
|
|
82
|
+
self.schemaFolder = [folder / 'schema' for folder in self.localfolder]
|
|
83
|
+
self.fieldgroupFolder = [folder / 'fieldgroup' for folder in self.localfolder]
|
|
84
|
+
self.fieldgroupGlobalFolder = [folder / 'global' for folder in self.fieldgroupFolder]
|
|
85
|
+
self.classFolder = [folder / 'class' for folder in self.localfolder]
|
|
86
|
+
self.descriptorFolder = [folder / 'descriptor' for folder in self.localfolder]
|
|
87
|
+
if any([folder.exists() is False for folder in self.schemaFolder]) or any([folder.exists() is False for folder in self.fieldgroupFolder]) or any([folder.exists() is False for folder in self.classFolder]):
|
|
88
|
+
raise Exception(f"One of the folders {self.schemaFolder} or {self.fieldgroupFolder} or {self.classFolder} does not exist. Please create it and extract your sandbox before using it.")
|
|
86
89
|
else:
|
|
87
90
|
raise Exception("You need to provide a schemaAPI instance or a config object to connect to the API or a local folder to use the local storage")
|
|
88
91
|
if self.schemaAPI is not None:
|
|
@@ -99,9 +102,11 @@ class SchemaManager:
|
|
|
99
102
|
elif kwargs.get('tenantId') is not None:
|
|
100
103
|
self.tenantId = f"{kwargs.get('tenantId')}"
|
|
101
104
|
elif self.localfolder is not None:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
for folder in self.localfolder:
|
|
106
|
+
config_json = json.load(FileIO(folder / 'config.json'))
|
|
107
|
+
if config_json.get('tenantId',None) is not None:
|
|
108
|
+
self.tenantId = config_json.get('tenantId')
|
|
109
|
+
break
|
|
105
110
|
else: ### Should not be a problem as the element without a tenantId are not supposed to change
|
|
106
111
|
self.tenantId = " "
|
|
107
112
|
if type(schema) == dict:
|
|
@@ -113,32 +118,47 @@ class SchemaManager:
|
|
|
113
118
|
if self.schemaAPI is not None:
|
|
114
119
|
self.schema = self.schemaAPI.getSchema(self.schema['$id'],full=False,schema_type='xed')
|
|
115
120
|
elif self.localfolder is not None:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if self.schema.get('meta:
|
|
121
|
-
self.
|
|
121
|
+
found = False
|
|
122
|
+
for folder in self.schemaFolder:
|
|
123
|
+
for json_file in folder.glob('*.json'):
|
|
124
|
+
tmp_def = json.load(FileIO(json_file))
|
|
125
|
+
if tmp_def.get('$id') == self.schema['$id'] or tmp_def.get('meta:altId') == self.schema.get('meta:altId') or tmp_def.get('title') == self.schema.get('title'):
|
|
126
|
+
self.schema = tmp_def
|
|
127
|
+
if self.schema.get('meta:tenantNamespace') is not None:
|
|
128
|
+
self.tenantId = f"_{self.schema.get('meta:tenantNamespace')}"
|
|
129
|
+
found = True
|
|
130
|
+
break
|
|
131
|
+
if found:
|
|
122
132
|
break
|
|
123
133
|
self.fieldGroupIds = [obj['$ref'] for obj in allOf if ('/mixins/' in obj['$ref'] or '/experience/' in obj['$ref'] or '/context/' in obj['$ref']) and obj['$ref'] != self.classId]
|
|
124
134
|
self.classIds = [self.classId]
|
|
125
135
|
for ref in self.fieldGroupIds:
|
|
126
136
|
if '/mixins/' in ref and self.tenantId[1:] in ref:
|
|
127
137
|
if self.localfolder is not None:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
found = False
|
|
139
|
+
for folder in self.fieldgroupFolder:
|
|
140
|
+
for json_file in folder.glob('*.json'):
|
|
141
|
+
tmp_def = json.load(FileIO(json_file))
|
|
142
|
+
if tmp_def.get('$id') == ref:
|
|
143
|
+
definition = tmp_def
|
|
144
|
+
found = True
|
|
145
|
+
break
|
|
146
|
+
if found:
|
|
132
147
|
break
|
|
133
148
|
elif self.schemaAPI is not None:
|
|
134
149
|
definition = self.schemaAPI.getFieldGroup(ref,full=False)
|
|
135
150
|
fgM = FieldGroupManager(fieldGroup=definition,schemaAPI=self.schemaAPI,localFolder=localFolder,tenantId=self.tenantId,sandbox=self.sandbox)
|
|
136
151
|
else:
|
|
137
152
|
if self.localfolder is not None:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
found = False
|
|
154
|
+
for folder in self.fieldgroupFolder:
|
|
155
|
+
for json_file in folder.glob('*.json'):
|
|
156
|
+
tmp_def = json.load(FileIO(json_file))
|
|
157
|
+
if tmp_def.get('$id') == ref:
|
|
158
|
+
definition = tmp_def
|
|
159
|
+
found = True
|
|
160
|
+
break
|
|
161
|
+
if found:
|
|
142
162
|
break
|
|
143
163
|
elif self.schemaAPI is not None:
|
|
144
164
|
definition = self.schemaAPI.getFieldGroup(ref,full=False)
|
|
@@ -158,17 +178,22 @@ class SchemaManager:
|
|
|
158
178
|
self.fieldGroupIds = [obj.get('$ref','') for obj in allOf if ('/mixins/' in obj.get('$ref','') or '/experience/' in obj.get('$ref','') or '/context/' in obj.get('$ref','')) and obj.get('$ref','') != self.classId]
|
|
159
179
|
self.classIds = [self.classId]
|
|
160
180
|
elif localFolder is not None:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
self.
|
|
181
|
+
found = False
|
|
182
|
+
for folder in self.schemaFolder:
|
|
183
|
+
for json_file in folder.glob('*.json'):
|
|
184
|
+
tmp_def = json.load(FileIO(json_file))
|
|
185
|
+
if tmp_def.get('$id') == schema or tmp_def.get('meta:altId') == schema or schema == tmp_def.get('title'):
|
|
186
|
+
self.schema = tmp_def
|
|
187
|
+
self.requiredFields = set([el.replace('@','_').replace('xdm:','') for el in self.schema.get('required',[])])
|
|
188
|
+
self.__setAttributes__(self.schema)
|
|
189
|
+
allOf = self.schema.get("allOf",[])
|
|
190
|
+
self.fieldGroupIds = [obj.get('$ref','') for obj in allOf if ('/mixins/' in obj.get('$ref','') or '/experience/' in obj.get('$ref','') or '/context/' in obj.get('$ref','')) and obj.get('$ref','') != self.classId]
|
|
191
|
+
self.classIds = [self.classId]
|
|
192
|
+
if self.schema.get('meta:tenantNamespace') is not None:
|
|
193
|
+
self.tenantId = self.schema.get('meta:tenantNamespace')
|
|
194
|
+
found = True
|
|
195
|
+
break
|
|
196
|
+
if found:
|
|
172
197
|
break
|
|
173
198
|
else:
|
|
174
199
|
raise Exception("You need to provide a schemaAPI instance or a localFolder to use the local storage")
|
|
@@ -178,31 +203,51 @@ class SchemaManager:
|
|
|
178
203
|
if self.schemaAPI is not None:
|
|
179
204
|
definition = self.schemaAPI.getFieldGroup(ref,full=False)
|
|
180
205
|
elif self.localfolder is not None:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
definition = tmp_def
|
|
185
|
-
break
|
|
186
|
-
if definition is None:
|
|
187
|
-
for json_file in self.fieldgroupGlobalFolder.glob('*.json'):
|
|
206
|
+
found = False
|
|
207
|
+
for folder in self.fieldgroupFolder:
|
|
208
|
+
for json_file in folder.glob('*.json'):
|
|
188
209
|
tmp_def = json.load(FileIO(json_file))
|
|
189
210
|
if tmp_def.get('$id') == ref:
|
|
190
211
|
definition = tmp_def
|
|
212
|
+
found = True
|
|
213
|
+
break
|
|
214
|
+
if found:
|
|
215
|
+
break
|
|
216
|
+
found = False
|
|
217
|
+
if definition is None:
|
|
218
|
+
for folder in self.fieldgroupGlobalFolder:
|
|
219
|
+
for json_file in folder.glob('*.json'):
|
|
220
|
+
tmp_def = json.load(FileIO(json_file))
|
|
221
|
+
if tmp_def.get('$id') == ref:
|
|
222
|
+
definition = tmp_def
|
|
223
|
+
found = True
|
|
224
|
+
break
|
|
225
|
+
if found:
|
|
191
226
|
break
|
|
192
227
|
else:
|
|
193
228
|
if self.schemaAPI is not None:
|
|
194
229
|
definition = self.schemaAPI.getFieldGroup(ref,full=False)
|
|
195
230
|
elif self.localfolder is not None:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
definition = tmp_def
|
|
200
|
-
break
|
|
201
|
-
if definition is None:
|
|
202
|
-
for json_file in self.fieldgroupGlobalFolder.glob('*.json'):
|
|
231
|
+
found = False
|
|
232
|
+
for folder in self.fieldgroupFolder:
|
|
233
|
+
for json_file in folder.glob('*.json'):
|
|
203
234
|
tmp_def = json.load(FileIO(json_file))
|
|
204
235
|
if tmp_def.get('$id') == ref:
|
|
205
236
|
definition = tmp_def
|
|
237
|
+
found = True
|
|
238
|
+
break
|
|
239
|
+
if found:
|
|
240
|
+
break
|
|
241
|
+
found = False
|
|
242
|
+
if definition is None:
|
|
243
|
+
for folder in self.fieldgroupGlobalFolder:
|
|
244
|
+
for json_file in folder.glob('*.json'):
|
|
245
|
+
tmp_def = json.load(FileIO(json_file))
|
|
246
|
+
if tmp_def.get('$id') == ref:
|
|
247
|
+
definition = tmp_def
|
|
248
|
+
found = True
|
|
249
|
+
break
|
|
250
|
+
if found:
|
|
206
251
|
break
|
|
207
252
|
if 'properties' in definition.keys():
|
|
208
253
|
definition['definitions'] = definition['properties']
|
|
@@ -210,12 +255,17 @@ class SchemaManager:
|
|
|
210
255
|
self.fieldGroupsManagers[fgM.title] = fgM
|
|
211
256
|
for clas in self.classIds:
|
|
212
257
|
if self.localfolder is not None:
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
258
|
+
found = False
|
|
259
|
+
for folder in self.classFolder:
|
|
260
|
+
for json_file in folder.glob('*.json'):
|
|
261
|
+
tmp_def = json.load(FileIO(json_file))
|
|
262
|
+
if tmp_def.get('$id') == clas:
|
|
263
|
+
self.classId = tmp_def['$id']
|
|
264
|
+
self.schemaClass = tmp_def['$id']
|
|
265
|
+
clsM = ClassManager(tmp_def,schemaAPI=self.schemaAPI,localFolder=localFolder,tenantId=self.tenantId,sandbox=self.sandbox)
|
|
266
|
+
found = True
|
|
267
|
+
break
|
|
268
|
+
if found:
|
|
219
269
|
break
|
|
220
270
|
elif self.schemaAPI is not None:
|
|
221
271
|
clsM = ClassManager(clas,schemaAPI=self.schemaAPI,localFolder=localFolder,tenantId=self.tenantId,sandbox=self.sandbox)
|
|
@@ -243,20 +293,31 @@ class SchemaManager:
|
|
|
243
293
|
definition = self.schemaAPI.getFieldGroup(fgId,full=False)
|
|
244
294
|
elif self.localfolder is not None:
|
|
245
295
|
definition = None
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if tmp_def.get('$id') == fgId:
|
|
252
|
-
definition = tmp_def
|
|
253
|
-
break
|
|
254
|
-
if definition is None:
|
|
255
|
-
for json_file in self.fieldgroupGlobalFolder.glob('*.json'):
|
|
296
|
+
found = False
|
|
297
|
+
for fieldGroupPath in self.fieldgroupFolder:
|
|
298
|
+
if fieldGroupPath.exists() is False:
|
|
299
|
+
raise Exception(f"The local folder {fieldGroupPath} does not exist. Please create it and extract your sandbox before using it.")
|
|
300
|
+
for json_file in fieldGroupPath.glob('*.json'):
|
|
256
301
|
tmp_def = json.load(FileIO(json_file))
|
|
257
|
-
if tmp_def.get('$id') ==
|
|
302
|
+
if tmp_def.get('$id') == fgId:
|
|
258
303
|
definition = tmp_def
|
|
259
|
-
|
|
304
|
+
found = True
|
|
305
|
+
break
|
|
306
|
+
if found:
|
|
307
|
+
break
|
|
308
|
+
if definition is None:
|
|
309
|
+
found = False
|
|
310
|
+
for fieldGroupPath in self.fieldgroupGlobalFolder:
|
|
311
|
+
if fieldGroupPath.exists() is False:
|
|
312
|
+
raise Exception(f"The local folder {fieldGroupPath} does not exist. Please create it and extract your sandbox before using it.")
|
|
313
|
+
for json_file in fieldGroupPath.glob('*.json'):
|
|
314
|
+
tmp_def = json.load(FileIO(json_file))
|
|
315
|
+
if tmp_def.get('$id') == fgId:
|
|
316
|
+
definition = tmp_def
|
|
317
|
+
found = True
|
|
318
|
+
break
|
|
319
|
+
if found:
|
|
320
|
+
break
|
|
260
321
|
fgM = FieldGroupManager(definition,schemaAPI=self.schemaAPI, localFolder=localFolder,tenantId=self.tenantId,sandbox=self.sandbox)
|
|
261
322
|
self.fieldGroupsManagers[fgM.title] = fgM
|
|
262
323
|
elif fieldGroups[0] == dict:
|
|
@@ -805,12 +866,13 @@ class SchemaManager:
|
|
|
805
866
|
elif self.localfolder is not None:
|
|
806
867
|
res = []
|
|
807
868
|
fieldGroupsIds = [fg.id for fg in list(self.fieldGroupsManagers.values())]
|
|
808
|
-
for
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
869
|
+
for folder in self.descriptorFolder:
|
|
870
|
+
for json_file in folder.glob('*.json'):
|
|
871
|
+
tmp_def = json.load(FileIO(json_file))
|
|
872
|
+
if tmp_def.get('xdm:sourceSchema') == self.id:
|
|
873
|
+
res.append(tmp_def)
|
|
874
|
+
elif tmp_def.get('xdm:sourceSchema') in fieldGroupsIds:
|
|
875
|
+
res.append(tmp_def)
|
|
814
876
|
else:
|
|
815
877
|
raise Exception("No API connection set and no local folder provided. No descriptors can be retrieved.")
|
|
816
878
|
return res
|
aepp/synchronizer.py
CHANGED
|
@@ -20,7 +20,7 @@ from .configs import ConnectObject
|
|
|
20
20
|
|
|
21
21
|
class Synchronizer:
|
|
22
22
|
## TO DO -> Add support for local environment
|
|
23
|
-
def __init__(self,targets:list=None,config:'ConnectObject'=None,baseSandbox:str=None,region:str='nld2',localFolder:str=None):
|
|
23
|
+
def __init__(self,targets:list=None,config:'ConnectObject'=None,baseSandbox:str=None,region:str='nld2',localFolder:str|list|None=None):
|
|
24
24
|
"""
|
|
25
25
|
Setup the synchronizor object with the base sandbox and target sandbox.
|
|
26
26
|
Arguments:
|
|
@@ -56,24 +56,30 @@ class Synchronizer:
|
|
|
56
56
|
self.baseSandbox = baseSandbox
|
|
57
57
|
elif localFolder is not None:
|
|
58
58
|
self.baseConfig = None
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
self.
|
|
64
|
-
self.
|
|
65
|
-
self.
|
|
66
|
-
self.
|
|
67
|
-
self.
|
|
68
|
-
self.
|
|
69
|
-
self.
|
|
70
|
-
self.
|
|
59
|
+
if isinstance(localFolder, str):
|
|
60
|
+
self.localfolder = [Path(localFolder)]
|
|
61
|
+
else:
|
|
62
|
+
self.localfolder = [Path(folder) for folder in localFolder]
|
|
63
|
+
self.classFolder = [folder / 'class' for folder in self.localfolder]
|
|
64
|
+
self.schemaFolder = [folder / 'schema' for folder in self.localfolder]
|
|
65
|
+
self.fieldgroupFolder = [folder / 'fieldgroup' for folder in self.localfolder]
|
|
66
|
+
self.fieldgroupGlobalFolder = [folder / 'global' for folder in self.fieldgroupFolder]
|
|
67
|
+
self.datatypeFolder = [folder / 'datatype' for folder in self.localfolder]
|
|
68
|
+
self.datatypeGlobalFolder = [folder / 'global' for folder in self.datatypeFolder]
|
|
69
|
+
self.identityFolder = [folder / 'identity' for folder in self.localfolder]
|
|
70
|
+
self.datasetFolder = [folder / 'dataset' for folder in self.localfolder]
|
|
71
|
+
self.descriptorFolder = [folder / 'descriptor' for folder in self.localfolder]
|
|
72
|
+
self.mergePolicyFolder = [folder / 'mergepolicy' for folder in self.localfolder]
|
|
73
|
+
self.audienceFolder = [folder / 'audience' for folder in self.localfolder]
|
|
71
74
|
if baseSandbox is not None:
|
|
72
75
|
self.baseSandbox = baseSandbox
|
|
73
76
|
else:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
for folder in self.localfolder:
|
|
78
|
+
with open(folder / 'config.json','r') as f:
|
|
79
|
+
local_config = json.load(f)
|
|
80
|
+
if 'baseSandbox' in local_config.keys():
|
|
81
|
+
self.baseSandbox = local_config['baseSandbox']
|
|
82
|
+
break
|
|
77
83
|
self.dict_targetsConfig = {target: aepp.configure(org_id=config_object['org_id'],client_id=config_object['client_id'],scopes=config_object['scopes'],secret=config_object['secret'],sandbox=target,connectInstance=True) for target in targets}
|
|
78
84
|
self.region = region
|
|
79
85
|
self.dict_baseComponents = {'schema':{},'class':{},'fieldgroup':{},'datatype':{},'datasets':{},'identities':{},"schemaDescriptors":{},'mergePolicy':{},'audience':{}}
|
|
@@ -163,11 +169,12 @@ class Synchronizer:
|
|
|
163
169
|
if component in base_schema.data.schemas_altId.keys():## replacing name with altId
|
|
164
170
|
component = base_schema.data.schemas_altId[component]
|
|
165
171
|
if self.localfolder is not None:
|
|
166
|
-
for
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
component
|
|
170
|
-
|
|
172
|
+
for folder in self.schemaFolder:
|
|
173
|
+
for file in folder.glob('*.json'):
|
|
174
|
+
sc_file = json.load(FileIO(file))
|
|
175
|
+
if sc_file['title'] == component or sc_file['$id'] == component or sc_file['meta:altId'] == component:
|
|
176
|
+
component = sc_file
|
|
177
|
+
break
|
|
171
178
|
component = schemamanager.SchemaManager(component,config=self.baseConfig,localFolder=self.localfolder,sandbox=self.baseSandbox)
|
|
172
179
|
elif componentType == 'fieldgroup':
|
|
173
180
|
if base_schema is not None:
|
|
@@ -175,11 +182,12 @@ class Synchronizer:
|
|
|
175
182
|
if component in base_schema.data.fieldGroups_altId.keys():## replacing name with altId
|
|
176
183
|
component = base_schema.data.fieldGroups_altId[component]
|
|
177
184
|
if self.localfolder is not None:
|
|
178
|
-
for
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
component
|
|
182
|
-
|
|
185
|
+
for folder in self.fieldgroupFolder:
|
|
186
|
+
for file in folder.glob('*.json'):
|
|
187
|
+
fg_file = json.load(FileIO(file))
|
|
188
|
+
if fg_file['title'] == component or fg_file['$id'] == component or fg_file['meta:altId'] == component:
|
|
189
|
+
component = fg_file
|
|
190
|
+
break
|
|
183
191
|
component = fieldgroupmanager.FieldGroupManager(component,config=self.baseConfig,localFolder=self.localfolder,sandbox=self.baseSandbox)
|
|
184
192
|
elif componentType == 'datatypes':
|
|
185
193
|
datatypes = base_schema.getDataTypes()
|
|
@@ -187,11 +195,12 @@ class Synchronizer:
|
|
|
187
195
|
if component in base_schema.data.dataTypes_altId.keys():## replacing name with altId
|
|
188
196
|
component = base_schema.data.dataTypes_altId[component]
|
|
189
197
|
if self.localfolder is not None:
|
|
190
|
-
for
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
component
|
|
194
|
-
|
|
198
|
+
for folder in self.datatypeFolder:
|
|
199
|
+
for file in folder.glob('*.json'):
|
|
200
|
+
dt_file = json.load(FileIO(file))
|
|
201
|
+
if dt_file['title'] == component or dt_file['$id'] == component or dt_file['meta:altId'] == component:
|
|
202
|
+
component = dt_file
|
|
203
|
+
break
|
|
195
204
|
component = datatypemanager.DataTypeManager(component,config=self.baseConfig,localFolder=self.localfolder,sandbox=self.baseSandbox)
|
|
196
205
|
elif componentType == 'class':
|
|
197
206
|
classes = base_schema.getClasses()
|
|
@@ -204,9 +213,10 @@ class Synchronizer:
|
|
|
204
213
|
identities:list = id_base.getIdentities()
|
|
205
214
|
elif self.localfolder is not None:
|
|
206
215
|
identities = []
|
|
207
|
-
for
|
|
208
|
-
|
|
209
|
-
|
|
216
|
+
for folder in self.identityFolder:
|
|
217
|
+
for file in folder.glob('*.json'):
|
|
218
|
+
id_file = json.load(FileIO(file))
|
|
219
|
+
identities.append(id_file)
|
|
210
220
|
if component in [el['code'] for el in identities]:
|
|
211
221
|
component = [el for el in identities if el['code'] == component][0]
|
|
212
222
|
elif component in [el['name'] for el in identities]:
|
|
@@ -221,11 +231,12 @@ class Synchronizer:
|
|
|
221
231
|
component = cat_base.data.ids[component]
|
|
222
232
|
component = cat_base.getDataSet(component)
|
|
223
233
|
elif self.localfolder is not None:
|
|
224
|
-
for
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
component
|
|
228
|
-
|
|
234
|
+
for folder in self.datasetFolder:
|
|
235
|
+
for file in folder.glob('*.json'):
|
|
236
|
+
ds_file = json.load(FileIO(file))
|
|
237
|
+
if ds_file['id'] == component or ds_file['name'] == component:
|
|
238
|
+
component = ds_file
|
|
239
|
+
break
|
|
229
240
|
if len(component) == 1: ## if the component is the catalog API response {'key': {dataset definition}}
|
|
230
241
|
component = component[list(component.keys())[0]] ## accessing the real dataset definition
|
|
231
242
|
elif componentType == "mergepolicy":
|
|
@@ -235,11 +246,12 @@ class Synchronizer:
|
|
|
235
246
|
if component in [el.get('id','') for el in base_mergePolicies] or component in [el.get('name','') for el in base_mergePolicies]:
|
|
236
247
|
component = [el for el in base_mergePolicies if el.get('id','') == component or el.get('name','') == component][0]
|
|
237
248
|
elif self.localfolder is not None:
|
|
238
|
-
for
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
component
|
|
242
|
-
|
|
249
|
+
for folder in self.mergePolicyFolder:
|
|
250
|
+
for file in folder.glob('*.json'):
|
|
251
|
+
mp_file = json.load(FileIO(file))
|
|
252
|
+
if mp_file.get('id','') == component or mp_file.get('name','') == component:
|
|
253
|
+
component = mp_file
|
|
254
|
+
break
|
|
243
255
|
elif componentType == 'audience':
|
|
244
256
|
if self.baseConfig is not None:
|
|
245
257
|
seg_base = segmentation.Segmentation(config=self.baseConfig)
|
|
@@ -247,11 +259,12 @@ class Synchronizer:
|
|
|
247
259
|
if component in [el.get('id','') for el in base_audiences] or component in [el.get('name','') for el in base_audiences]:
|
|
248
260
|
component = [el for el in base_audiences if el.get('id','') == component or el.get('name','') == component][0]
|
|
249
261
|
elif self.localfolder is not None:
|
|
250
|
-
for
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
component
|
|
254
|
-
|
|
262
|
+
for folder in self.audienceFolder:
|
|
263
|
+
for file in folder.glob('*.json'):
|
|
264
|
+
au_file = json.load(FileIO(file))
|
|
265
|
+
if au_file.get('id','') == component or au_file.get('name','') == component:
|
|
266
|
+
component = au_file
|
|
267
|
+
break
|
|
255
268
|
elif type(component) == dict:
|
|
256
269
|
if 'meta:resourceType' in component.keys():
|
|
257
270
|
componentType = component['meta:resourceType']
|
|
@@ -708,8 +721,9 @@ class Synchronizer:
|
|
|
708
721
|
myschemas = baseSchemaAPI.getSchemas() ## to populate the data object
|
|
709
722
|
elif self.localfolder is not None:
|
|
710
723
|
myschemas = []
|
|
711
|
-
for
|
|
712
|
-
|
|
724
|
+
for folder in self.schemaFolder:
|
|
725
|
+
for json_file in folder.glob('*.json'):
|
|
726
|
+
myschemas.append(json.load(FileIO(json_file)))
|
|
713
727
|
target_descriptors = targetSchemaManager.getDescriptors()
|
|
714
728
|
list_descriptors = []
|
|
715
729
|
for baseDescriptor in base_descriptors:
|
|
@@ -761,10 +775,15 @@ class Synchronizer:
|
|
|
761
775
|
if self.baseConfig is not None and self.localfolder is None:
|
|
762
776
|
base_targetSchemaManager = schemamanager.SchemaManager(base_targetSchemaId,config=self.baseConfig)
|
|
763
777
|
elif self.localfolder is not None:
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
778
|
+
found = False
|
|
779
|
+
for folder in self.schemaFolder:
|
|
780
|
+
for file in folder.glob('*.json'):
|
|
781
|
+
base_targetSchema = json.load(FileIO(file))
|
|
782
|
+
if base_targetSchema['$id'] == base_targetSchemaId:
|
|
783
|
+
base_targetSchemaManager = schemamanager.SchemaManager(base_targetSchema,config=self.baseConfig,localFolder=self.localfolder,sandbox=self.baseSandbox)
|
|
784
|
+
found = True
|
|
785
|
+
break
|
|
786
|
+
if found:
|
|
768
787
|
break
|
|
769
788
|
self.__syncSchema__(base_targetSchemaManager,verbose=verbose)
|
|
770
789
|
target_targetSchemaId = self.dict_targetComponents[targetSchemaManager.sandbox]['schema'][base_targetSchemaName].id
|
|
@@ -888,7 +907,7 @@ class Synchronizer:
|
|
|
888
907
|
|
|
889
908
|
def __syncDataset__(self,baseDataset:dict,verbose:bool=False)-> dict:
|
|
890
909
|
"""
|
|
891
|
-
Synchronize the dataset to the target sandboxes. Mostly creating a new dataset and associated
|
|
910
|
+
Synchronize the dataset to the target sandboxes. Mostly creating a new dataset and associated artifacts when not already created.
|
|
892
911
|
Arguments:
|
|
893
912
|
baseDataset : REQUIRED : dictionary with the dataset definition
|
|
894
913
|
"""
|
|
@@ -903,8 +922,9 @@ class Synchronizer:
|
|
|
903
922
|
base_dataset_related_schemaName = [schemaName for schemaName,schemaId in baseSchemaAPI.data.schemas_id.items() if schemaId == base_dataset_related_schemaId][0]
|
|
904
923
|
elif self.localfolder is not None:
|
|
905
924
|
base_schemas = []
|
|
906
|
-
for
|
|
907
|
-
|
|
925
|
+
for folder in self.schemaFolder:
|
|
926
|
+
for json_file in folder.glob('*.json'):
|
|
927
|
+
base_schemas.append(json.load(FileIO(json_file)))
|
|
908
928
|
base_dataset_related_schemaName = [sc['title'] for sc in base_schemas if sc['$id'] == base_dataset_related_schemaId][0]
|
|
909
929
|
for target in self.dict_targetsConfig.keys():
|
|
910
930
|
targetCatalog = catalog.Catalog(config=self.dict_targetsConfig[target])
|
|
@@ -942,7 +962,7 @@ class Synchronizer:
|
|
|
942
962
|
|
|
943
963
|
def __syncMergePolicy__(self,mergePolicy:dict,verbose:bool=False)->None:
|
|
944
964
|
"""
|
|
945
|
-
Synchronize the dataset to the target sandboxes. Mostly creating a new dataset and associated
|
|
965
|
+
Synchronize the dataset to the target sandboxes. Mostly creating a new dataset and associated artifacts when not already created.
|
|
946
966
|
Arguments:
|
|
947
967
|
mergePolicy : REQUIRED : The merge policy dictionary to sync
|
|
948
968
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aepp
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Package to manage AEP API endpoint and some helper functions
|
|
5
5
|
Author-email: Julien Piccini <piccini.julien@gmail.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -22,6 +22,7 @@ Requires-Dist: tenacity
|
|
|
22
22
|
Requires-Dist: deprecation
|
|
23
23
|
Requires-Dist: datamodel-code-generator
|
|
24
24
|
Requires-Dist: rich
|
|
25
|
+
Requires-Dist: matplotlib
|
|
25
26
|
Dynamic: license-file
|
|
26
27
|
|
|
27
28
|
# Adobe Experience Platform API made for humans
|