aepp 0.5.2__py3-none-any.whl → 0.5.2.post1__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/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.5.2"
1
+ __version__ = "0.5.2-1"
aepp/cli/__main__.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from ast import arg
2
2
  from matplotlib.pyplot import table
3
3
  import aepp
4
- from aepp import synchronizer, schema, schemamanager, fieldgroupmanager, datatypemanager, identity, queryservice,catalog,flowservice
4
+ from aepp import synchronizer, schema, schemamanager, fieldgroupmanager, datatypemanager, identity, queryservice,catalog,flowservice,sandboxes, segmentation
5
5
  import argparse, cmd, shlex, json
6
6
  from functools import wraps
7
7
  from rich.console import Console
@@ -134,6 +134,42 @@ class ServiceShell(cmd.Cmd):
134
134
  else:
135
135
  console.print(Panel("(!) You must configure the connection first using the 'config' command.", style="red"))
136
136
 
137
+ @login_required
138
+ def do_get_sandboxes(self, args:Any) -> None:
139
+ """List all sandboxes for the current organization"""
140
+ parser = argparse.ArgumentParser(prog='get_sandboxes', add_help=True)
141
+ parser.add_argument("-sv", "--save",help="Save sandboxes to CSV file")
142
+ try:
143
+ args = parser.parse_args(shlex.split(args))
144
+ aepp_sandboxes = sandboxes.Sandboxes(config=self.config)
145
+ sandboxes_list = aepp_sandboxes.getSandboxes()
146
+ if sandboxes_list:
147
+ table = Table(title=f"Sandboxes in Org: {self.config.org_id}")
148
+ table.add_column("Name", style="cyan")
149
+ table.add_column("Title", style="magenta")
150
+ table.add_column("Type", style="green")
151
+ table.add_column("Region", style="yellow")
152
+ table.add_column("Created", style="medium_violet_red")
153
+ for sb in sandboxes_list:
154
+ table.add_row(
155
+ sb.get("name","N/A"),
156
+ sb.get("title","N/A"),
157
+ sb.get("type","N/A"),
158
+ sb.get("region","N/A"),
159
+ sb.get("createdDate","N/A"),
160
+ )
161
+ console.print(table)
162
+ if args.save:
163
+ df_sandboxes = pd.DataFrame(sandboxes_list)
164
+ df_sandboxes.to_csv(f"sandboxes_{self.config.org_id}.csv", index=False)
165
+ console.print(f"Sandboxes exported to sandboxes_{self.config.org_id}.csv", style="green")
166
+ else:
167
+ console.print("(!) No sandboxes found.", style="red")
168
+ except Exception as e:
169
+ console.print(f"(!) Error: {str(e)}", style="red")
170
+ except SystemExit:
171
+ return
172
+
137
173
 
138
174
  @login_required
139
175
  def do_get_schemas(self, args:Any) -> None:
@@ -738,13 +774,81 @@ class ServiceShell(cmd.Cmd):
738
774
  ds.get("name","N/A"),
739
775
  datetime.fromtimestamp(ds.get("created",1000)/1000).isoformat().split('T')[0],
740
776
  str(ds.get("dataIngested",False)),
741
- ds.get("classification",{}).get("dataBehavior","unknown")
777
+ ds.get('classification').get('dataBehavior','N/A'),
778
+ )
779
+ console.print(table)
780
+ except Exception as e:
781
+ console.print(f"(!) Error: {str(e)}", style="red")
782
+ except SystemExit:
783
+ return
784
+
785
+ @login_required
786
+ def do_get_datasets_tableName(self, args:Any) -> None:
787
+ parser = argparse.ArgumentParser(prog='get_datasets', add_help=True)
788
+ try:
789
+ args = parser.parse_args(shlex.split(args))
790
+ aepp_cat = catalog.Catalog(config=self.config)
791
+ datasets = aepp_cat.getDataSets(output='list')
792
+ table = Table(title=f"Datasets in Sandbox: {self.config.sandbox}")
793
+ table.add_column("Name", style="white")
794
+ table.add_column("Table Name", style="cyan",no_wrap=True)
795
+ table.add_column("Data Type", style="red")
796
+ for ds in datasets:
797
+ table.add_row(
798
+ ds.get("name","N/A"),
799
+ ds.get('tags',{}).get('adobe/pqs/table',["N/A"])[0],
800
+ ds.get('classification').get('dataBehavior','N/A'),
742
801
  )
743
802
  console.print(table)
744
803
  except Exception as e:
745
804
  console.print(f"(!) Error: {str(e)}", style="red")
746
805
  except SystemExit:
747
806
  return
807
+
808
+ @login_required
809
+ def do_get_observable_schema_json(self,args:Any) -> None:
810
+ """Get the observable schema for a dataset by name or ID"""
811
+ parser = argparse.ArgumentParser(prog='get_observable_schema', add_help=True)
812
+ parser.add_argument("dataset", help="Dataset ID or Dataset Name to retrieve observable schema for",type=str)
813
+ try:
814
+ args = parser.parse_args(shlex.split(args))
815
+ aepp_cat = catalog.Catalog(config=self.config)
816
+ datasets = aepp_cat.getDataSets(output='list')
817
+ for ds in datasets:
818
+ if ds.get("name","") == args.dataset or ds.get("id","") == args.dataset:
819
+ datasetId = ds.get("id")
820
+ schema_json = aepp_cat.getDataSetObservableSchema(datasetId=datasetId,appendDatasetInfo=True)
821
+ myObs = catalog.ObservableSchemaManager(schema_json,config=self.config)
822
+ data = myObs.to_dict()
823
+ with open(f"{args.dataset}_observable_schema.json", 'w') as f:
824
+ json.dump(data, f, indent=4)
825
+ console.print(f"Saved Observable schema to {args.dataset}_observable_schema.json.", style="green")
826
+ except Exception as e:
827
+ console.print(f"(!) Error: {str(e)}", style="red")
828
+ except SystemExit:
829
+ return
830
+
831
+ @login_required
832
+ def do_get_observable_schema_csv(self,args:Any) -> None:
833
+ """Get the observable schema for a dataset by name or ID"""
834
+ parser = argparse.ArgumentParser(prog='get_observable_schema', add_help=True)
835
+ parser.add_argument("dataset", help="Dataset ID or Dataset Name to retrieve observable schema for",type=str)
836
+ try:
837
+ args = parser.parse_args(shlex.split(args))
838
+ aepp_cat = catalog.Catalog(config=self.config)
839
+ datasets = aepp_cat.getDataSets(output='list')
840
+ for ds in datasets:
841
+ if ds.get("name","") == args.dataset or ds.get("id","") == args.dataset:
842
+ datasetId = ds.get("id")
843
+ schema_json = aepp_cat.getDataSetObservableSchema(datasetId=datasetId,appendDatasetInfo=True)
844
+ myObs = catalog.ObservableSchemaManager(schema_json,config=self.config)
845
+ data = myObs.to_dataframe()
846
+ data.to_csv(f"{args.dataset}_observable_schema.csv", index=False)
847
+ console.print(f"Saved Observable schema to {args.dataset}_observable_schema.csv.", style="green")
848
+ except Exception as e:
849
+ console.print(f"(!) Error: {str(e)}", style="red")
850
+ except SystemExit:
851
+ return
748
852
 
749
853
  @login_required
750
854
  def do_get_datasets_infos(self, args:Any) -> None:
@@ -754,23 +858,58 @@ class ServiceShell(cmd.Cmd):
754
858
  args = parser.parse_args(shlex.split(args))
755
859
  aepp_cat = catalog.Catalog(config=self.config)
756
860
  datasets = aepp_cat.getDataSets()
861
+ aepp_cat.data.infos = aepp_cat.data.infos.sort_values(by=['ups_storageSize','datalake_storageSize'], ascending=False)
757
862
  aepp_cat.data.infos.to_csv(f"{aepp_cat.sandbox}_datasets_infos.csv",index=False)
758
863
  console.print(f"Datasets infos exported to {aepp_cat.sandbox}_datasets_infos.csv", style="green")
759
864
  table = Table(title=f"Datasets in Sandbox: {self.config.sandbox}")
760
865
  table.add_column("ID", style="white")
761
866
  table.add_column("Name", style="white",no_wrap=True)
762
- table.add_column("Datalake_rows", style="blue")
763
- table.add_column("Datalake_storage", style="blue")
764
- table.add_column("UPS_rows", style="magenta")
765
- table.add_column("UPS_storage", style="magenta")
867
+ table.add_column("UPS Rows", style="cyan")
868
+ table.add_column("UPS Storage Size", style="green")
869
+ table.add_column("Datalake Rows", style="magenta")
870
+ table.add_column("Datalake Storage Size", style="yellow")
766
871
  for _, ds in aepp_cat.data.infos.iterrows():
767
872
  table.add_row(
768
873
  ds.get("id","N/A"),
769
874
  ds.get("name","N/A"),
875
+ str(ds.get("ups_rows","N/A")),
876
+ str(ds.get("ups_storageSize","N/A")),
770
877
  str(ds.get("datalake_rows","N/A")),
771
878
  str(ds.get("datalake_storageSize","N/A")),
772
- str(ds.get("ups_rows","N/A")),
773
- str(ds.get("ups_storageSize","N/A"))
879
+ )
880
+ console.print(table)
881
+ except Exception as e:
882
+ console.print(f"(!) Error: {str(e)}", style="red")
883
+ except SystemExit:
884
+ return
885
+
886
+ @login_required
887
+ def do_get_snapshot_datasets(self,args:Any) -> None:
888
+ """List all snapshot datasets in the current sandbox"""
889
+ parser = argparse.ArgumentParser(prog='get_snapshot_datasets', add_help=True)
890
+ try:
891
+ args = parser.parse_args(shlex.split(args))
892
+ aepp_cat = catalog.Catalog(config=self.config)
893
+ datasets = aepp_cat.getProfileSnapshotDatasets(explicitMergePolicy=True)
894
+ list_ds = []
895
+ for key, ds in datasets.items():
896
+ obj = ds
897
+ obj['id'] = key
898
+ list_ds.append(obj)
899
+ df_datasets = pd.DataFrame(list_ds)
900
+ df_datasets.to_csv(f"{self.config.sandbox}_snapshot_datasets.csv",index=False)
901
+ console.print(f"Snapshot Datasets exported to {self.config.sandbox}_snapshot_datasets.csv", style="green")
902
+ table = Table(title=f"Snapshot Datasets in Sandbox: {self.config.sandbox}")
903
+ table.add_column("ID", style="white")
904
+ table.add_column("Table Name", style="white")
905
+ table.add_column("Merge Policy Name", style="yellow")
906
+ table.add_column("Merge Policy ID", style="green")
907
+ for ds in list_ds:
908
+ table.add_row(
909
+ ds.get("id","N/A"),
910
+ ds.get("tags",{}).get('adobe/pqs/table',["N/A"])[0],
911
+ ds.get('mergePolicyName','N/A'),
912
+ [el.split(':')[1] for el in ds.get('tags',{}).get('unifiedProfile',[]) if el.startswith('mergePolicyId')][0]
774
913
  )
775
914
  console.print(table)
776
915
  except Exception as e:
@@ -844,6 +983,37 @@ class ServiceShell(cmd.Cmd):
844
983
  except SystemExit:
845
984
  return
846
985
 
986
+ @login_required
987
+ def do_get_audiences(self, args:Any) -> None:
988
+ """List all audiences in the current sandbox"""
989
+ parser = argparse.ArgumentParser(prog='get_audiences', add_help=True)
990
+ try:
991
+ args = parser.parse_args(shlex.split(args))
992
+ aepp_audience = segmentation.Segmentation(config=self.config)
993
+ audiences = aepp_audience.getAudiences()
994
+ df_audiences = pd.DataFrame(audiences)
995
+ df_audiences.to_csv(f"{self.config.sandbox}_audiences.csv",index=False)
996
+ console.print(f"Audiences exported to {self.config.sandbox}_audiences.csv", style="green")
997
+ table = Table(title=f"Audiences in Sandbox: {self.config.sandbox}")
998
+ table.add_column("ID", style="cyan")
999
+ table.add_column("Name", style="magenta")
1000
+ table.add_column("Evaluation", style="yellow")
1001
+ table.add_column("Total Profiles", style="green")
1002
+ table.add_column("Evaluation Date", style="white")
1003
+ for aud in audiences:
1004
+ table.add_row(
1005
+ aud.get("id","N/A"),
1006
+ aud.get("name","N/A"),
1007
+ '[red3]Batch[/red3]' if aud.get("evaluationInfo",{}).get("batch",{}).get('enabled') else '[chartreuse1]Streaming[/chartreuse1]' if aud.get("evaluationInfo",{}).get("continuous",{}).get('enabled') else '[blue_violet]Edge[/blue_violet]' if aud.get("evaluationInfo",{}).get("synchronous",{}).get('enabled') else 'N/A',
1008
+ str(aud.get('metrics',{}).get('data',{}).get('totalProfiles','N/A')),
1009
+ datetime.fromtimestamp(aud.get('metrics',{}).get('updateEpoch',0)).isoformat(),
1010
+ )
1011
+ console.print(table)
1012
+ except Exception as e:
1013
+ console.print(f"(!) Error: {str(e)}", style="red")
1014
+ except SystemExit:
1015
+ return
1016
+
847
1017
  @login_required
848
1018
  def do_get_flows(self, args:Any) -> None:
849
1019
  """List flows in the current sandbox based on parameters provided. By default, list all sources and destinations."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aepp
3
- Version: 0.5.2
3
+ Version: 0.5.2.post1
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
@@ -1,5 +1,5 @@
1
1
  aepp/__init__.py,sha256=rsU4OMu3pJIgy8emJAD6lhAfqH0-raZ6GyIMJanNBdM,27912
2
- aepp/__version__.py,sha256=wlmBF5A1gVspskZOpqNe0Xi1AY5ZRYF38SMV3fRd_LA,21
2
+ aepp/__version__.py,sha256=AUsss0HkU-B8aUszp_T12nUU7w7iBuYD5ALVA6BTKYA,23
3
3
  aepp/accesscontrol.py,sha256=PB3FcrO4bvDjdNxjHx7p_20hp4ahBXewoOSxuTGMXC8,17423
4
4
  aepp/catalog.py,sha256=hK9m3SAP0fhgkYqu14Tcfq14qBhw54tLCOF0mH31b1M,68237
5
5
  aepp/classmanager.py,sha256=16hx_hptg3PYwmezZCr9dLjvOkNSunih1PK3Q-iPoZY,66099
@@ -35,10 +35,10 @@ aepp/synchronizer.py,sha256=3scwuimQJIBVdEqJ9fVsT1UgmFc9EkH3mpYxUwSoAOE,79363
35
35
  aepp/tags.py,sha256=t2qBallTcWR4IOXcDBmrPpqjbSay1z3E2bcRijzVm1s,17641
36
36
  aepp/utils.py,sha256=tG-YVXylm38-bynqfp5N_Mzyo7mhlZj-dLo7wLoO4tM,1200
37
37
  aepp/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- aepp/cli/__main__.py,sha256=9Hswyux5umZozY0NP6i1J7WWV81PrNj--pfOQ9REeL8,67968
39
- aepp-0.5.2.dist-info/licenses/LICENSE,sha256=HjYTlfne3BbS5gNHzNqJ5COCiTQLUdf87QkzRyFbE4Y,10337
40
- aepp-0.5.2.dist-info/METADATA,sha256=wfGA0AzXQdAwcYWD6RB9umN6LWXz_RP07HaEAorpG5k,5338
41
- aepp-0.5.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
42
- aepp-0.5.2.dist-info/entry_points.txt,sha256=e7HAumUTymoUiCuVRzFlcchennUBLcjxvuiimySF98Y,48
43
- aepp-0.5.2.dist-info/top_level.txt,sha256=dtZJI8SzhWVgZRl68PHKZX_fD6amvDiFR-lqD9FSJvE,5
44
- aepp-0.5.2.dist-info/RECORD,,
38
+ aepp/cli/__main__.py,sha256=B2W5iooeKlsWQdWrJr27Y72ibEIgBHZTTGlLe-YgOZU,77329
39
+ aepp-0.5.2.post1.dist-info/licenses/LICENSE,sha256=HjYTlfne3BbS5gNHzNqJ5COCiTQLUdf87QkzRyFbE4Y,10337
40
+ aepp-0.5.2.post1.dist-info/METADATA,sha256=mp5AAwkCCK-cruebhH-SMdo89di8CdHacoTi5H5BTdw,5344
41
+ aepp-0.5.2.post1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
42
+ aepp-0.5.2.post1.dist-info/entry_points.txt,sha256=e7HAumUTymoUiCuVRzFlcchennUBLcjxvuiimySF98Y,48
43
+ aepp-0.5.2.post1.dist-info/top_level.txt,sha256=dtZJI8SzhWVgZRl68PHKZX_fD6amvDiFR-lqD9FSJvE,5
44
+ aepp-0.5.2.post1.dist-info/RECORD,,