aepp 0.5.1.post1__tar.gz → 0.5.2__tar.gz
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-0.5.1.post1/aepp.egg-info → aepp-0.5.2}/PKG-INFO +2 -1
- aepp-0.5.2/aepp/__version__.py +1 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/classmanager.py +59 -29
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/cli/__main__.py +20 -26
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/datatypemanager.py +60 -27
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/fieldgroupmanager.py +100 -65
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/schemamanager.py +140 -78
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/synchronizer.py +77 -57
- {aepp-0.5.1.post1 → aepp-0.5.2/aepp.egg-info}/PKG-INFO +2 -1
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp.egg-info/requires.txt +1 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/pyproject.toml +2 -1
- aepp-0.5.1.post1/aepp/__version__.py +0 -1
- {aepp-0.5.1.post1 → aepp-0.5.2}/LICENSE +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/MANIFEST.in +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/README.md +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/__init__.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/accesscontrol.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/catalog.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/cli/__init__.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/config.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/configs.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/connector.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/customerprofile.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/dataaccess.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/dataprep.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/datasets.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/deletion.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/destination.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/destinationinstanceservice.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/edge.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/exportDatasetToDataLandingZone.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/flowservice.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/hygiene.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/identity.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/ingestion.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/observability.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/policy.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/privacyservice.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/queryservice.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/sandboxes.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/schema.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/segmentation.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/sensei.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/som.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/tags.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp/utils.py +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp.egg-info/SOURCES.txt +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp.egg-info/dependency_links.txt +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp.egg-info/entry_points.txt +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/aepp.egg-info/top_level.txt +0 -0
- {aepp-0.5.1.post1 → aepp-0.5.2}/setup.cfg +0 -0
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.2"
|
|
@@ -23,7 +23,7 @@ class ClassManager:
|
|
|
23
23
|
schemaAPI:'Schema'=None,
|
|
24
24
|
config: Union[dict,ConnectObject] = aepp.config.config_object,
|
|
25
25
|
description: str = 'power by aepp',
|
|
26
|
-
localFolder:str=None,
|
|
26
|
+
localFolder:str | list | None = None,
|
|
27
27
|
sandbox:str=None,
|
|
28
28
|
**kwargs
|
|
29
29
|
)->None:
|
|
@@ -48,13 +48,16 @@ class ClassManager:
|
|
|
48
48
|
elif config is not None and localFolder is None:
|
|
49
49
|
self.schemaAPI = Schema(config=config)
|
|
50
50
|
elif localFolder is not None:
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if isinstance(localFolder, str):
|
|
52
|
+
self.localfolder = [Path(localFolder)]
|
|
53
|
+
elif isinstance(localFolder, list):
|
|
54
|
+
self.localfolder = [Path(lf) for lf in localFolder]
|
|
55
|
+
if any([folder.exists() is False for folder in self.localfolder]):
|
|
53
56
|
raise Exception(f"The local folder {self.localfolder} does not exist. Please create it and extract your sandbox before using it.")
|
|
54
57
|
self.schemaAPI = None
|
|
55
|
-
self.classFolder =
|
|
56
|
-
self.behavFolder =
|
|
57
|
-
if
|
|
58
|
+
self.classFolder = [folder / 'class' for folder in self.localfolder]
|
|
59
|
+
self.behavFolder = [folder / 'behaviour' for folder in self.localfolder]
|
|
60
|
+
if any([folder.exists() is False for folder in self.classFolder]):
|
|
58
61
|
raise Exception(f"The local folder {self.classFolder} does not exist. Please create it and extract your sandbox before using it.")
|
|
59
62
|
else:
|
|
60
63
|
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")
|
|
@@ -71,9 +74,11 @@ class ClassManager:
|
|
|
71
74
|
elif type(aepclass) == dict:
|
|
72
75
|
self.tenantId = aepclass.get('meta:tenantNamespace'," ")
|
|
73
76
|
elif self.localfolder is not None:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
for folder in self.localfolder:
|
|
78
|
+
config_json = json.load(FileIO(folder / 'config.json'))
|
|
79
|
+
if config_json.get('tenantId',None) is not None:
|
|
80
|
+
self.tenantId = config_json.get('tenantId')
|
|
81
|
+
break
|
|
77
82
|
else:
|
|
78
83
|
self.tenantId = " "
|
|
79
84
|
if type(aepclass) == dict:
|
|
@@ -82,10 +87,15 @@ class ClassManager:
|
|
|
82
87
|
self.aepclass = self.schemaAPI.getClass(aepclass['$id'],full=False,xtype='xed')
|
|
83
88
|
self.EDITABLE = True
|
|
84
89
|
elif self.localfolder is not None:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
found = False
|
|
91
|
+
for folder in self.classFolder:
|
|
92
|
+
for json_file in folder.glob('*.json'):
|
|
93
|
+
tmp_def = json.load(FileIO(json_file))
|
|
94
|
+
if tmp_def.get('$id') == aepclass['$id']:
|
|
95
|
+
self.aepclass = tmp_def
|
|
96
|
+
found = True
|
|
97
|
+
break
|
|
98
|
+
if found:
|
|
89
99
|
break
|
|
90
100
|
self.EDITABLE = False
|
|
91
101
|
elif self.tenantId[1:] not in aepclass['$id']:
|
|
@@ -93,10 +103,15 @@ class ClassManager:
|
|
|
93
103
|
self.aepclass = self.schemaAPI.getClass(aepclass['$id'],full=True,xtype='xed')
|
|
94
104
|
self.EDITABLE = False
|
|
95
105
|
elif self.localfolder is not None:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
found = False
|
|
107
|
+
for folder in self.classFolder:
|
|
108
|
+
for json_file in folder.glob('*.json'):
|
|
109
|
+
tmp_def = json.load(FileIO(json_file))
|
|
110
|
+
if tmp_def.get('$id') == aepclass['$id']:
|
|
111
|
+
self.aepclass = tmp_def
|
|
112
|
+
found = True
|
|
113
|
+
break
|
|
114
|
+
if found:
|
|
100
115
|
break
|
|
101
116
|
self.EDITABLE = False
|
|
102
117
|
self.__setAttributes__(self.aepclass)
|
|
@@ -106,20 +121,30 @@ class ClassManager:
|
|
|
106
121
|
self.aepclass = self.schemaAPI.getClass(aepclass,full=False,xtype='xed')
|
|
107
122
|
self.EDITABLE = True
|
|
108
123
|
elif self.localfolder is not None:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
found = False
|
|
125
|
+
for folder in self.classFolder:
|
|
126
|
+
for json_file in folder.glob('*.json'):
|
|
127
|
+
tmp_def = json.load(FileIO(json_file))
|
|
128
|
+
if tmp_def.get('$id') == aepclass or tmp_def.get('meta:altId') == aepclass:
|
|
129
|
+
self.aepclass = tmp_def
|
|
130
|
+
found = True
|
|
131
|
+
break
|
|
132
|
+
if found:
|
|
113
133
|
break
|
|
114
134
|
self.EDITABLE = False
|
|
115
135
|
else:
|
|
116
136
|
if self.schemaAPI is not None:
|
|
117
137
|
self.aepclass = self.schemaAPI.getClass(aepclass,full=True,xtype='xed')
|
|
118
138
|
elif self.localfolder is not None:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
139
|
+
found = False
|
|
140
|
+
for folder in self.classFolder:
|
|
141
|
+
for json_file in folder.glob('*.json'):
|
|
142
|
+
tmp_def = json.load(FileIO(json_file))
|
|
143
|
+
if tmp_def.get('$id') == aepclass or tmp_def.get('meta:altId') == aepclass:
|
|
144
|
+
self.aepclass = tmp_def
|
|
145
|
+
found = True
|
|
146
|
+
break
|
|
147
|
+
if found:
|
|
123
148
|
break
|
|
124
149
|
self.EDITABLE = False
|
|
125
150
|
self.__setAttributes__(self.aepclass)
|
|
@@ -168,10 +193,15 @@ class ClassManager:
|
|
|
168
193
|
if self.schemaAPI is not None:
|
|
169
194
|
self.behaviorDefinition = self.schemaAPI.getBehavior(behavId,full=True,xtype='xed')
|
|
170
195
|
elif self.localfolder is not None:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
196
|
+
found = False
|
|
197
|
+
for folder in self.behavFolder:
|
|
198
|
+
for json_file in folder.glob('*.json'):
|
|
199
|
+
tmp_def = json.load(FileIO(json_file))
|
|
200
|
+
if tmp_def.get('$id') == behavId:
|
|
201
|
+
self.behaviorDefinition = tmp_def
|
|
202
|
+
found = True
|
|
203
|
+
break
|
|
204
|
+
if found:
|
|
175
205
|
break
|
|
176
206
|
self.requiredFields = set()
|
|
177
207
|
|
|
@@ -47,26 +47,25 @@ class ServiceShell(cmd.Cmd):
|
|
|
47
47
|
self.sandbox = str(dict_config.get("sandbox-name","prod"))
|
|
48
48
|
else:
|
|
49
49
|
self.sandbox = str(kwargs.get("sandbox","prod"))
|
|
50
|
-
self.secret =
|
|
51
|
-
self.org_id =
|
|
52
|
-
self.client_id =
|
|
53
|
-
self.scopes =
|
|
50
|
+
self.secret = dict_config.get("secret",kwargs.get("secret"))
|
|
51
|
+
self.org_id = dict_config.get("org_id",kwargs.get("org_id"))
|
|
52
|
+
self.client_id = dict_config.get("client_id",kwargs.get("client_id"))
|
|
53
|
+
self.scopes = dict_config.get("scopes",kwargs.get("scopes"))
|
|
54
54
|
else:
|
|
55
|
-
self.sandbox =
|
|
56
|
-
self.secret =
|
|
57
|
-
self.org_id =
|
|
58
|
-
self.client_id =
|
|
59
|
-
self.scopes =
|
|
60
|
-
self.connectInstance = True
|
|
55
|
+
self.sandbox:str|None = kwargs.get("sandbox","prod")
|
|
56
|
+
self.secret:str|None = kwargs.get("secret")
|
|
57
|
+
self.org_id:str|None = kwargs.get("org_id")
|
|
58
|
+
self.client_id:str|None = kwargs.get("client_id")
|
|
59
|
+
self.scopes:str|None = kwargs.get("scopes")
|
|
61
60
|
if self.sandbox is not None and self.secret is not None and self.org_id is not None and self.client_id is not None and self.scopes is not None:
|
|
62
61
|
print("Configuring connection...")
|
|
63
62
|
self.config = aepp.configure(
|
|
64
|
-
connectInstance=self.connectInstance,
|
|
65
63
|
sandbox=self.sandbox,
|
|
66
64
|
secret=self.secret,
|
|
67
65
|
org_id=self.org_id,
|
|
68
66
|
client_id=self.client_id,
|
|
69
|
-
scopes=self.scopes
|
|
67
|
+
scopes=self.scopes,
|
|
68
|
+
connectInstance=self.connectInstance
|
|
70
69
|
)
|
|
71
70
|
self.prompt = f"{self.config.sandbox}> "
|
|
72
71
|
console.print(Panel(f"Connected to [bold green]{self.sandbox}[/bold green]", style="blue"))
|
|
@@ -82,7 +81,6 @@ class ServiceShell(cmd.Cmd):
|
|
|
82
81
|
console.print(f"Configuration file created at {Path.cwd() / Path(filename_json)}", style="green")
|
|
83
82
|
return
|
|
84
83
|
|
|
85
|
-
|
|
86
84
|
# # --- Commands ---
|
|
87
85
|
def do_config(self, arg:Any) -> None:
|
|
88
86
|
"""connect to an AEP instance"""
|
|
@@ -94,14 +92,14 @@ class ServiceShell(cmd.Cmd):
|
|
|
94
92
|
parser.add_argument("-cid", "--client_id", help="Auto-login client ID")
|
|
95
93
|
parser.add_argument("-cf", "--config_file", help="Path to config file", default=None)
|
|
96
94
|
args = parser.parse_args(shlex.split(arg))
|
|
97
|
-
if args.config_file:
|
|
95
|
+
if args.config_file is not None:
|
|
98
96
|
mypath = Path.cwd()
|
|
99
97
|
dict_config = json.load(FileIO(mypath / Path(args.config_file)))
|
|
100
|
-
self.sandbox =
|
|
101
|
-
self.secret =
|
|
102
|
-
self.org_id =
|
|
103
|
-
self.client_id =
|
|
104
|
-
self.scopes =
|
|
98
|
+
self.sandbox:str|None = args.sandbox if args.sandbox else dict_config.get("sandbox-name",args.sandbox)
|
|
99
|
+
self.secret:str|None = dict_config.get("secret",args.secret)
|
|
100
|
+
self.org_id:str|None = dict_config.get("org_id",args.org_id)
|
|
101
|
+
self.client_id:str|None = dict_config.get("client_id",args.client_id)
|
|
102
|
+
self.scopes:str|None = dict_config.get("scopes",args.scopes)
|
|
105
103
|
self.connectInstance = True
|
|
106
104
|
else:
|
|
107
105
|
if args.sandbox: self.sandbox = str(args.sandbox)
|
|
@@ -1203,18 +1201,14 @@ class ServiceShell(cmd.Cmd):
|
|
|
1203
1201
|
console.print("Syncing artifact...", style="blue")
|
|
1204
1202
|
parser = argparse.ArgumentParser(prog='extractArtifact', description='Extract artifacts from AEP')
|
|
1205
1203
|
parser.add_argument('artifact', help='artifact to extract (name or id): "schema","fieldgroup","datatype","descriptor","dataset","identity","mergepolicy","audience"')
|
|
1206
|
-
parser.add_argument('-at','--artifactType', help='artifact type ')
|
|
1207
|
-
parser.add_argument('-t','--targets', help='target sandboxes')
|
|
1208
|
-
parser.add_argument('-lf','--localfolder', help='Local folder to extract artifacts to',default='extractions')
|
|
1204
|
+
parser.add_argument('-at','--artifactType', help='artifact type ',type=str)
|
|
1205
|
+
parser.add_argument('-t','--targets', help='target sandboxes',nargs='+',type=str)
|
|
1206
|
+
parser.add_argument('-lf','--localfolder', help='Local folder to extract artifacts to',default='extractions',nargs='+',type=str)
|
|
1209
1207
|
parser.add_argument('-b','--baseSandbox', help='Base sandbox for synchronization')
|
|
1210
1208
|
parser.add_argument('-rg','--region', help='Region to extract artifacts from: "ndl2" (default), "va7", "aus5", "can2", "ind2"',default='ndl2')
|
|
1211
1209
|
parser.add_argument('-v','--verbose', help='Enable verbose output',default=True)
|
|
1212
1210
|
try:
|
|
1213
1211
|
args = parser.parse_args(shlex.split(args))
|
|
1214
|
-
if ',' in args.targets:
|
|
1215
|
-
args.targets = args.targets.split(',')
|
|
1216
|
-
else:
|
|
1217
|
-
args.targets = [args.targets]
|
|
1218
1212
|
console.print("Initializing Synchronizor...", style="blue")
|
|
1219
1213
|
if args.baseSandbox:
|
|
1220
1214
|
synchronizor = synchronizer.Synchronizer(
|
|
@@ -36,7 +36,7 @@ class DataTypeManager:
|
|
|
36
36
|
schemaAPI:'Schema'=None,
|
|
37
37
|
config: Union[dict,ConnectObject] = aepp.config.config_object,
|
|
38
38
|
description:str="",
|
|
39
|
-
localFolder:str=None,
|
|
39
|
+
localFolder:str|list|None=None,
|
|
40
40
|
sandbox:str=None,
|
|
41
41
|
**kwargs
|
|
42
42
|
)->None:
|
|
@@ -65,10 +65,13 @@ class DataTypeManager:
|
|
|
65
65
|
elif config is not None and localFolder is None:
|
|
66
66
|
self.schemaAPI = Schema(config=config)
|
|
67
67
|
elif localFolder is not None:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
if isinstance(localFolder, str):
|
|
69
|
+
self.localfolder = [Path(localFolder)]
|
|
70
|
+
elif isinstance(localFolder, list):
|
|
71
|
+
self.localfolder = [Path(folder) for folder in localFolder]
|
|
72
|
+
self.datatypeFolder = [folder / 'datatype' for folder in self.localfolder]
|
|
73
|
+
self.datatypeGlobalFolder = [folder / 'global' for folder in self.datatypeFolder]
|
|
74
|
+
if any([folder.exists() is False for folder in self.localfolder]):
|
|
72
75
|
raise Exception(f"The local folder {self.localfolder} does not exist. Please create it and extract your sandbox before using it.")
|
|
73
76
|
self.schemaAPI = None
|
|
74
77
|
if self.schemaAPI is not None:
|
|
@@ -99,20 +102,32 @@ class DataTypeManager:
|
|
|
99
102
|
self.dataType = self.schemaAPI.getDataType(dataType['$id'],full=False)
|
|
100
103
|
self.EDITABLE = True
|
|
101
104
|
elif self.localfolder is not None:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
found = False
|
|
106
|
+
for folder in self.datatypeFolder:
|
|
107
|
+
for dataTypeFile in folder.glob(f"*.json"):
|
|
108
|
+
tmp_def = json.load(FileIO(dataTypeFile))
|
|
109
|
+
if tmp_def.get('$id') == dataType.get('$id') or tmp_def.get('meta:altId') == dataType.get('meta:altId'):
|
|
110
|
+
self.dataType = tmp_def
|
|
111
|
+
found = True
|
|
112
|
+
break
|
|
113
|
+
if found:
|
|
114
|
+
break
|
|
106
115
|
self.EDITABLE = False
|
|
107
116
|
else:
|
|
108
117
|
if self.schemaAPI is not None:
|
|
109
118
|
self.dataType = self.schemaAPI.getDataType(dataType['$id'],full=True)
|
|
110
119
|
self.EDITABLE = True
|
|
111
120
|
elif self.localfolder is not None:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
found = False
|
|
122
|
+
for folder in self.datatypeGlobalFolder:
|
|
123
|
+
for dataTypeFile in folder.glob("*.json"):
|
|
124
|
+
tmp_def = json.load(FileIO(dataTypeFile))
|
|
125
|
+
if tmp_def.get('$id') == dataType.get('$id') or tmp_def.get('meta:altId') == dataType.get('meta:altId') or tmp_def.get('title') == dataType.get('title'):
|
|
126
|
+
self.dataType = tmp_def
|
|
127
|
+
found = True
|
|
128
|
+
break
|
|
129
|
+
if found:
|
|
130
|
+
break
|
|
116
131
|
self.EDITABLE = False
|
|
117
132
|
elif type(dataType) == str:
|
|
118
133
|
if self.tenantId[1:] in dataType:
|
|
@@ -122,10 +137,16 @@ class DataTypeManager:
|
|
|
122
137
|
raise ValueError(f"Cannot find the data type with id {dataType} in the schema API.")
|
|
123
138
|
self.EDITABLE = True
|
|
124
139
|
elif self.localfolder is not None:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
found = False
|
|
141
|
+
for folder in self.datatypeFolder:
|
|
142
|
+
for dataTypeFile in folder.glob("*.json"):
|
|
143
|
+
tmp_def = json.load(FileIO(dataTypeFile))
|
|
144
|
+
if tmp_def.get('$id') == dataType or tmp_def.get('meta:altId') == dataType or tmp_def.get('title') == dataType:
|
|
145
|
+
self.dataType = tmp_def
|
|
146
|
+
found = True
|
|
147
|
+
break
|
|
148
|
+
if found:
|
|
149
|
+
break
|
|
129
150
|
self.EDITABLE = False
|
|
130
151
|
else:
|
|
131
152
|
raise Exception("You try to retrieve the datatype definition from the id, but no API or localFolder has been passed as a parameter.")
|
|
@@ -136,10 +157,16 @@ class DataTypeManager:
|
|
|
136
157
|
raise ValueError(f"Cannot find the data type with id {dataType} in the schema API.")
|
|
137
158
|
self.EDITABLE = True
|
|
138
159
|
elif self.localfolder is not None:
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
160
|
+
found = False
|
|
161
|
+
for folder in self.datatypeGlobalFolder:
|
|
162
|
+
for dataTypeFile in folder.glob("*.json"):
|
|
163
|
+
tmp_def = json.load(FileIO(dataTypeFile))
|
|
164
|
+
if tmp_def.get('$id') == dataType or tmp_def.get('meta:altId') == dataType or tmp_def.get('title') == dataType:
|
|
165
|
+
self.dataType = tmp_def
|
|
166
|
+
found = True
|
|
167
|
+
break
|
|
168
|
+
if found:
|
|
169
|
+
break
|
|
143
170
|
self.EDITABLE = False
|
|
144
171
|
else:
|
|
145
172
|
raise Exception("You try to retrieve the datatype definition from the id, but no API or localFolder has been passed as a parameter.")
|
|
@@ -181,12 +208,18 @@ class DataTypeManager:
|
|
|
181
208
|
self.dataTypeManagers[dt_manager.title] = dt_manager
|
|
182
209
|
elif self.localfolder is not None:
|
|
183
210
|
for dt in dataTypes: ## today only searching custom data types in local folder
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
211
|
+
found = False
|
|
212
|
+
for folder in self.datatypeFolder:
|
|
213
|
+
for dataTypeFile in folder.glob("*.json"):
|
|
214
|
+
tmp_def = json.load(FileIO(dataTypeFile))
|
|
215
|
+
if tmp_def.get('$id') == dt or tmp_def.get('meta:altId') == dt or tmp_def.get('title') == dt:
|
|
216
|
+
dt_manager = DataTypeManager(dataType=tmp_def,localFolder=self.localfolder,tenantId=self.tenantId,sandbox=self.sandbox)
|
|
217
|
+
self.dataTypes[dt_manager.id] = dt_manager.title
|
|
218
|
+
self.dataTypeManagers[dt_manager.title] = dt_manager
|
|
219
|
+
found = True
|
|
220
|
+
break
|
|
221
|
+
if found:
|
|
222
|
+
break
|
|
190
223
|
if title is not None:
|
|
191
224
|
self.dataType['title'] = title
|
|
192
225
|
self.title = title
|
|
@@ -39,7 +39,7 @@ class FieldGroupManager:
|
|
|
39
39
|
config: Union[dict,ConnectObject] = aepp.config.config_object,
|
|
40
40
|
description:str="powered by aepp",
|
|
41
41
|
full:bool=None,
|
|
42
|
-
localFolder:str=None,
|
|
42
|
+
localFolder:str | list | None=None,
|
|
43
43
|
sandbox:str=None,
|
|
44
44
|
**kwargs
|
|
45
45
|
)->None:
|
|
@@ -71,13 +71,16 @@ class FieldGroupManager:
|
|
|
71
71
|
elif config is not None and localFolder is None:
|
|
72
72
|
self.schemaAPI = Schema(config=config)
|
|
73
73
|
elif localFolder is not None:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
self.
|
|
79
|
-
self.
|
|
80
|
-
|
|
74
|
+
if isinstance(localFolder, str):
|
|
75
|
+
self.localfolder = [Path(localFolder)]
|
|
76
|
+
elif isinstance(localFolder, list):
|
|
77
|
+
self.localfolder = [Path(folder) for folder in localFolder]
|
|
78
|
+
self.datatypeFolder = [folder / 'datatype' for folder in self.localfolder]
|
|
79
|
+
self.datatypeGlobalFolder = [folder / 'global' for folder in self.datatypeFolder]
|
|
80
|
+
self.fieldgroupFolder = [folder / 'fieldgroup' for folder in self.localfolder]
|
|
81
|
+
self.fieldgroupGlobalFolder = [folder / 'global' for folder in self.fieldgroupFolder]
|
|
82
|
+
self.descriptorFolder = [folder / 'descriptor' for folder in self.localfolder]
|
|
83
|
+
if any([folder.exists() is False for folder in self.localfolder]):
|
|
81
84
|
raise Exception(f"The local folder {self.localfolder} does not exist. Please create it and extract your sandbox before using it.")
|
|
82
85
|
self.schemaAPI = None
|
|
83
86
|
if self.schemaAPI is not None:
|
|
@@ -95,9 +98,11 @@ class FieldGroupManager:
|
|
|
95
98
|
if fieldGroup.get('meta:tenantNamespace') is not None:
|
|
96
99
|
self.tenantId = fieldGroup.get('meta:tenantNamespace')
|
|
97
100
|
elif self.localfolder is not None:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
for folder in self.localfolder:
|
|
102
|
+
config_json = json.load(FileIO(folder / 'config.json'))
|
|
103
|
+
if config_json.get('tenantId',None) is not None:
|
|
104
|
+
self.tenantId = config_json.get('tenantId')
|
|
105
|
+
break
|
|
101
106
|
else:### Should not be a problem as the element without a tenantId are not supposed to change
|
|
102
107
|
self.tenantId = " "
|
|
103
108
|
if fieldGroup is not None:
|
|
@@ -126,28 +131,40 @@ class FieldGroupManager:
|
|
|
126
131
|
self.fieldGroup = tmp_def
|
|
127
132
|
self.EDITABLE = False
|
|
128
133
|
elif self.localfolder is not None:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
self.fieldGroup = tmp_def
|
|
133
|
-
if self.tenantId[1:] in self.fieldGroup.get('$id'): ## custom field group
|
|
134
|
-
if '/datatypes/' in str(self.fieldGroup):
|
|
135
|
-
dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
|
|
136
|
-
dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup))
|
|
137
|
-
for dt in dataTypes:
|
|
138
|
-
dt_manager = DataTypeManager(dt,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
|
|
139
|
-
self.dataTypes[dt_manager.id] = dt_manager.title
|
|
140
|
-
self.dataTypeManagers[dt_manager.title] = dt_manager
|
|
141
|
-
else: ## OOTB field group
|
|
142
|
-
if 'properties' in self.fieldGroup.keys():
|
|
143
|
-
self.fieldGroup['definitions'] = self.fieldGroup['properties']
|
|
144
|
-
if self.fieldGroup == {}:
|
|
145
|
-
for json_file in self.fieldgroupGlobalFolder.glob('*.json'):
|
|
134
|
+
found = False
|
|
135
|
+
for folder in self.fieldgroupFolder:
|
|
136
|
+
for json_file in folder.glob('*.json'):
|
|
146
137
|
tmp_def = json.load(FileIO(json_file))
|
|
147
138
|
if tmp_def.get('$id') == fieldGroup['$id'] or tmp_def.get('meta:altId') == fieldGroup.get('meta:altId') or tmp_def.get('title') == fieldGroup.get('title'):
|
|
148
139
|
self.fieldGroup = tmp_def
|
|
149
|
-
if
|
|
150
|
-
|
|
140
|
+
if self.tenantId[1:] in self.fieldGroup.get('$id'): ## custom field group
|
|
141
|
+
if '/datatypes/' in str(self.fieldGroup):
|
|
142
|
+
dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
|
|
143
|
+
dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup))
|
|
144
|
+
for dt in dataTypes:
|
|
145
|
+
dt_manager = DataTypeManager(dt,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
|
|
146
|
+
self.dataTypes[dt_manager.id] = dt_manager.title
|
|
147
|
+
self.dataTypeManagers[dt_manager.title] = dt_manager
|
|
148
|
+
else: ## OOTB field group
|
|
149
|
+
if 'properties' in self.fieldGroup.keys():
|
|
150
|
+
self.fieldGroup['definitions'] = self.fieldGroup['properties']
|
|
151
|
+
found = True
|
|
152
|
+
break
|
|
153
|
+
if found:
|
|
154
|
+
break
|
|
155
|
+
if self.fieldGroup == {}:
|
|
156
|
+
found = False
|
|
157
|
+
for folder in self.fieldgroupGlobalFolder:
|
|
158
|
+
for json_file in folder.glob('*.json'):
|
|
159
|
+
tmp_def = json.load(FileIO(json_file))
|
|
160
|
+
if tmp_def.get('$id') == fieldGroup['$id'] or tmp_def.get('meta:altId') == fieldGroup.get('meta:altId') or tmp_def.get('title') == fieldGroup.get('title'):
|
|
161
|
+
self.fieldGroup = tmp_def
|
|
162
|
+
if 'properties' in self.fieldGroup.keys():
|
|
163
|
+
self.fieldGroup['definitions'] = self.fieldGroup['properties']
|
|
164
|
+
found = True
|
|
165
|
+
break
|
|
166
|
+
if found:
|
|
167
|
+
break
|
|
151
168
|
self.EDITABLE = False
|
|
152
169
|
else: ## if definitions key not present
|
|
153
170
|
if 'properties' in self.fieldGroup.keys():
|
|
@@ -166,19 +183,24 @@ class FieldGroupManager:
|
|
|
166
183
|
self.fieldGroup = self.schemaAPI.getFieldGroup(self.fieldGroup['$id'],full=True)
|
|
167
184
|
self.EDITABLE = True
|
|
168
185
|
elif self.localfolder is not None: ## looking into local folder
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
186
|
+
found = False
|
|
187
|
+
for folder in self.fieldgroupFolder:
|
|
188
|
+
for json_file in folder.glob('*.json'): ## only custom Field groups: TO DO check for OOTB FG without definition
|
|
189
|
+
tmp_def = json.load(FileIO(json_file))
|
|
190
|
+
if tmp_def.get('$id') == fieldGroup['$id'] or tmp_def.get('meta:altId') == fieldGroup.get('meta:altId') or tmp_def.get('title') == fieldGroup.get('title'):
|
|
191
|
+
self.fieldGroup = tmp_def
|
|
192
|
+
if self.tenantId[1:] in self.fieldGroup.get('$id'): ## custom field group
|
|
193
|
+
if '/datatypes/' in str(self.fieldGroup):
|
|
194
|
+
dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
|
|
195
|
+
dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup))
|
|
196
|
+
for dt in dataTypes:
|
|
197
|
+
dt_manager = DataTypeManager(dt,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
|
|
198
|
+
self.dataTypes[dt_manager.id] = dt_manager.title
|
|
199
|
+
self.dataTypeManagers[dt_manager.title] = dt_manager
|
|
200
|
+
found = True
|
|
201
|
+
break
|
|
202
|
+
if found:
|
|
203
|
+
break
|
|
182
204
|
else:
|
|
183
205
|
raise ValueError("The field group definition provided does not contains the 'definitions' key. Please check the field group.")
|
|
184
206
|
else:
|
|
@@ -208,26 +230,38 @@ class FieldGroupManager:
|
|
|
208
230
|
self.fieldGroup = tmp_def
|
|
209
231
|
self.EDITABLE = False
|
|
210
232
|
elif self.localfolder is not None:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
self.fieldGroup = tmp_def
|
|
215
|
-
if tmp_def.get('meta:tenantNamespace',None) is not None:
|
|
216
|
-
self.tenantId = tmp_def.get('meta:tenantNamespace')
|
|
217
|
-
if '/datatypes/' in str(self.fieldGroup):
|
|
218
|
-
dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
|
|
219
|
-
dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup.get('definitions')))
|
|
220
|
-
for file in self.datatypeFolder.glob('*.json'):
|
|
221
|
-
tmp_def = json.load(FileIO(file))
|
|
222
|
-
if tmp_def.get('$id') in dataTypes or tmp_def.get('meta:altId') in dataTypes:
|
|
223
|
-
dt_manager = DataTypeManager(tmp_def,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
|
|
224
|
-
self.dataTypes[dt_manager.id] = dt_manager.title
|
|
225
|
-
self.dataTypeManagers[dt_manager.title] = dt_manager
|
|
226
|
-
if self.fieldGroup == {}: ## looking into the global folder
|
|
227
|
-
for json_file in self.fieldgroupGlobalFolder.glob('*.json'):
|
|
233
|
+
found = False
|
|
234
|
+
for folder in self.fieldgroupFolder:
|
|
235
|
+
for json_file in folder.glob('*.json'):
|
|
228
236
|
tmp_def = json.load(FileIO(json_file))
|
|
229
237
|
if tmp_def.get('$id') == fieldGroup or tmp_def.get('meta:altId') == fieldGroup or tmp_def.get('title') == fieldGroup:
|
|
230
|
-
self.fieldGroup = tmp_def
|
|
238
|
+
self.fieldGroup = tmp_def
|
|
239
|
+
if tmp_def.get('meta:tenantNamespace',None) is not None:
|
|
240
|
+
self.tenantId = tmp_def.get('meta:tenantNamespace')
|
|
241
|
+
if '/datatypes/' in str(self.fieldGroup):
|
|
242
|
+
dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
|
|
243
|
+
dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup.get('definitions')))
|
|
244
|
+
for file in self.datatypeFolder.glob('*.json'):
|
|
245
|
+
tmp_def = json.load(FileIO(file))
|
|
246
|
+
if tmp_def.get('$id') in dataTypes or tmp_def.get('meta:altId') in dataTypes:
|
|
247
|
+
dt_manager = DataTypeManager(tmp_def,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
|
|
248
|
+
self.dataTypes[dt_manager.id] = dt_manager.title
|
|
249
|
+
self.dataTypeManagers[dt_manager.title] = dt_manager
|
|
250
|
+
found = True
|
|
251
|
+
break
|
|
252
|
+
if found:
|
|
253
|
+
break
|
|
254
|
+
if self.fieldGroup == {}: ## looking into the global folder
|
|
255
|
+
found = False
|
|
256
|
+
for folder in self.fieldgroupGlobalFolder:
|
|
257
|
+
for json_file in folder.glob('*.json'):
|
|
258
|
+
tmp_def = json.load(FileIO(json_file))
|
|
259
|
+
if tmp_def.get('$id') == fieldGroup or tmp_def.get('meta:altId') == fieldGroup or tmp_def.get('title') == fieldGroup:
|
|
260
|
+
self.fieldGroup = tmp_def
|
|
261
|
+
found = True
|
|
262
|
+
break
|
|
263
|
+
if found:
|
|
264
|
+
break
|
|
231
265
|
else:
|
|
232
266
|
raise ValueError("the element pass is not a field group definition")
|
|
233
267
|
else:
|
|
@@ -1689,10 +1723,11 @@ class FieldGroupManager:
|
|
|
1689
1723
|
res = self.schemaAPI.getDescriptors(prop=f"xdm:sourceSchema=={self.id}")
|
|
1690
1724
|
elif self.localfolder is not None:
|
|
1691
1725
|
res = []
|
|
1692
|
-
for
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1726
|
+
for folder in self.descriptorFolder:
|
|
1727
|
+
for json_file in folder.glob('*.json'):
|
|
1728
|
+
tmp_def = json.load(FileIO(json_file))
|
|
1729
|
+
if tmp_def.get('xdm:sourceSchema') == self.id:
|
|
1730
|
+
res.append(tmp_def)
|
|
1696
1731
|
else:
|
|
1697
1732
|
raise Exception("Require a schema API connection or local folder. Pass the instance of a Schema class or import a configuration file.")
|
|
1698
1733
|
return res
|