cjapy 0.2.4.post1__tar.gz → 0.2.4.post3__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.
- cjapy-0.2.4.post3/.gitignore +15 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/PKG-INFO +3 -2
- cjapy-0.2.4.post3/cjapy/__version__.py +1 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/cjapy.py +91 -9
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/token_provider.py +2 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy.egg-info/PKG-INFO +3 -2
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy.egg-info/SOURCES.txt +1 -0
- cjapy-0.2.4.post3/docs/cja.md +712 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/docs/releases.md +4 -1
- cjapy-0.2.4.post1/cjapy/__version__.py +0 -1
- cjapy-0.2.4.post1/docs/cja.md +0 -676
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/LICENSE +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/README.md +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/__init__.py +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/config.py +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/configs.py +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/connector.py +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/projects.py +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/requestCreator.py +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy/workspace.py +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy.egg-info/dependency_links.txt +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy.egg-info/requires.txt +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/cjapy.egg-info/top_level.txt +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/docs/authenticating_without_config_json.md +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/docs/getting_started.md +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/docs/logging.md +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/docs/main.md +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/docs/projects.md +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/docs/requestCreator.md +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/docs/workspace.md +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/pyproject.toml +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/requirements.txt +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/setup.cfg +0 -0
- {cjapy-0.2.4.post1 → cjapy-0.2.4.post3}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cjapy
|
|
3
|
-
Version: 0.2.4.
|
|
3
|
+
Version: 0.2.4.post3
|
|
4
4
|
Summary: Adobe Customer Journey Analytics (CJA) wrapper
|
|
5
5
|
Home-page: https://github.com/pitchmuc/cjapy
|
|
6
6
|
Author: Julien Piccini
|
|
@@ -33,6 +33,7 @@ Provides-Extra: dynamic
|
|
|
33
33
|
Requires-Dist: version; extra == "dynamic"
|
|
34
34
|
Dynamic: author
|
|
35
35
|
Dynamic: home-page
|
|
36
|
+
Dynamic: license-file
|
|
36
37
|
Dynamic: requires-python
|
|
37
38
|
|
|
38
39
|
# Adobe Customer Journey API
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.4-3"
|
|
@@ -798,6 +798,79 @@ class CJA:
|
|
|
798
798
|
return df
|
|
799
799
|
return dimensions
|
|
800
800
|
|
|
801
|
+
def getSharedComponentsMatrix(self, include_dimensions=True, include_metrics=True):
|
|
802
|
+
"""
|
|
803
|
+
Build a matrix of shared components (dimensions and/or metrics) across dataviews.
|
|
804
|
+
|
|
805
|
+
Parameters
|
|
806
|
+
----------
|
|
807
|
+
include_dimensions : bool, optional
|
|
808
|
+
Whether to include shared dimensions (default: True).
|
|
809
|
+
include_metrics : bool, optional
|
|
810
|
+
Whether to include shared metrics (default: True).
|
|
811
|
+
|
|
812
|
+
Returns
|
|
813
|
+
-------
|
|
814
|
+
pandas.DataFrame
|
|
815
|
+
A DataFrame where rows are components (with id, type, name)
|
|
816
|
+
and columns are dataview names, containing 1/0 for presence.
|
|
817
|
+
|
|
818
|
+
Example
|
|
819
|
+
-------
|
|
820
|
+
>>> # Get shared dimensions and metrics matrix
|
|
821
|
+
>>> df = cja.getSharedComponentsMatrix()
|
|
822
|
+
>>> df.head()
|
|
823
|
+
type name Claims Dataview Member Portal
|
|
824
|
+
id
|
|
825
|
+
d1 dimension Customer ID 1 1
|
|
826
|
+
m1 metric Revenue 1 0
|
|
827
|
+
"""
|
|
828
|
+
print(
|
|
829
|
+
f"Shared components matrix generation started..."
|
|
830
|
+
)
|
|
831
|
+
dataviews = self.getDataViews()
|
|
832
|
+
dv_map = dict(zip(dataviews["id"], dataviews["name"]))
|
|
833
|
+
|
|
834
|
+
def build_shared_matrix(fetch_fn, comp_type):
|
|
835
|
+
results = {}
|
|
836
|
+
id_to_name = {}
|
|
837
|
+
|
|
838
|
+
for dv_id, dv_name in dv_map.items():
|
|
839
|
+
try:
|
|
840
|
+
comps = fetch_fn(dv_id, inclType=True, full=True)
|
|
841
|
+
shared = comps[comps["sharedComponent"] == True][["id", "name"]]
|
|
842
|
+
results[dv_name] = set(shared["id"].tolist())
|
|
843
|
+
id_to_name.update(dict(zip(shared["id"], shared["name"])))
|
|
844
|
+
except Exception as e:
|
|
845
|
+
print(f"Error fetching {comp_type} for {dv_id} ({dv_name}): {e}")
|
|
846
|
+
|
|
847
|
+
all_ids = sorted(set().union(*results.values()))
|
|
848
|
+
df = pd.DataFrame(index=all_ids)
|
|
849
|
+
|
|
850
|
+
for dv_name, comp_ids in results.items():
|
|
851
|
+
df[dv_name] = df.index.isin(comp_ids).astype(int)
|
|
852
|
+
|
|
853
|
+
df.insert(0, "name", df.index.map(id_to_name))
|
|
854
|
+
df.insert(0, "type", comp_type)
|
|
855
|
+
return df
|
|
856
|
+
|
|
857
|
+
dfs = []
|
|
858
|
+
if include_dimensions:
|
|
859
|
+
dfs.append(build_shared_matrix(self.getDimensions, "dimension"))
|
|
860
|
+
if include_metrics:
|
|
861
|
+
dfs.append(build_shared_matrix(self.getMetrics, "metric"))
|
|
862
|
+
|
|
863
|
+
if not dfs:
|
|
864
|
+
raise ValueError("At least one of include_dimensions/include_metrics must be True")
|
|
865
|
+
|
|
866
|
+
print(
|
|
867
|
+
f"Shared components matrix created"
|
|
868
|
+
"Hint: use `df.head()` to preview or `display(df)`."
|
|
869
|
+
)
|
|
870
|
+
|
|
871
|
+
return pd.concat(dfs)
|
|
872
|
+
|
|
873
|
+
|
|
801
874
|
def getDimension(
|
|
802
875
|
self, dataviewId: str = None,
|
|
803
876
|
dimensionId: str = None,
|
|
@@ -934,9 +1007,7 @@ class CJA:
|
|
|
934
1007
|
"page": 0,
|
|
935
1008
|
}
|
|
936
1009
|
if full:
|
|
937
|
-
params[
|
|
938
|
-
"expansion"
|
|
939
|
-
] = "name,description,owner,isDeleted,parentDataGroupId,segmentList,currentTimezoneOffset,timezoneDesignator,modified,createdDate,organization,curationEnabled,recentRecordedAccess,sessionDefinition,curatedComponents,externalData,containerNames"
|
|
1010
|
+
params["expansion"] = "name,description,owner,isDeleted,parentDataGroupId,segmentList,currentTimezoneOffset,timezoneDesignator,modified,createdDate,organization,curationEnabled,recentRecordedAccess,sessionDefinition,curatedComponents,externalData,containerNames"
|
|
940
1011
|
if parentDataGroupId:
|
|
941
1012
|
params["parentDataGroupId"] = parentDataGroupId
|
|
942
1013
|
if externalIds:
|
|
@@ -986,20 +1057,24 @@ class CJA:
|
|
|
986
1057
|
f.write(json.dumps(res, indent=4))
|
|
987
1058
|
return res
|
|
988
1059
|
|
|
989
|
-
def getConnections(self,limit:int=1000,full:bool=
|
|
1060
|
+
def getConnections(self,limit:int=1000,full:bool=False,expansion:str=None,output:str='df',**kwargs)-> JsonListOrDataFrameType:
|
|
990
1061
|
"""
|
|
991
1062
|
Retrieve the connections associated to that company.
|
|
992
1063
|
Arguments:
|
|
993
1064
|
limit : OPTIONAL : number of results per request (default 100)
|
|
994
1065
|
full : OPTIONAL : define if all possible information are returned (default True).
|
|
995
1066
|
output : OPTIONAL : Type of output selected, either "df" (default) or "raw"
|
|
1067
|
+
expansion : OPTIONAL : list of additional elements to be returned. (will replace the full=True option)
|
|
1068
|
+
possible values: "name,primaryIdType,configuredContainers,description,owner,isDeleted,isDisabled,dataSets,createdDate,modified,caseSensitive,organization,components,numDailyEvents,externalData,backfillEnabled,granularBackfills,granularStreaming,backfillsSummaryConnection,backfillsSummaryDataSets,dataSetLastIngested,componentType,sandboxName,sandboxId,fieldsId,floatPrecision,dataRetentionMonths,validationErrors,resolveIdentityNamespace,stitchedDataSets"
|
|
996
1069
|
"""
|
|
997
1070
|
if self.loggingEnabled:
|
|
998
1071
|
self.logger.debug(f"getConnections start")
|
|
999
1072
|
path = f"/data/connections"
|
|
1000
|
-
params = {"limit":limit,"page":0}
|
|
1001
|
-
if
|
|
1002
|
-
params["expansion"] =
|
|
1073
|
+
params = {"limit":limit,"page":0,"expansion":"name,description,owner,dataSets,createdDate,modified,sandboxName,dataRetentionMonths,primaryIdType"}
|
|
1074
|
+
if expansion is not None:
|
|
1075
|
+
params["expansion"] = expansion
|
|
1076
|
+
elif full:
|
|
1077
|
+
params["expansion"] ="name,primaryIdType,configuredContainers,description,owner,isDeleted,isDisabled,dataSets,createdDate,modified,caseSensitive,organization,components,numDailyEvents,externalData,backfillEnabled,granularBackfills,granularStreaming,backfillsSummaryConnection,backfillsSummaryDataSets,dataSetLastIngested,componentType,sandboxName,sandboxId,fieldsId,floatPrecision,dataRetentionMonths,validationErrors,resolveIdentityNamespace,stitchedDataSets"
|
|
1003
1078
|
res = self.connector.getData(self.endpoint + path,params=params, **kwargs)
|
|
1004
1079
|
data = res.get('content',[])
|
|
1005
1080
|
lastpage = res.get('lastPage',True)
|
|
@@ -1013,16 +1088,23 @@ class CJA:
|
|
|
1013
1088
|
return df
|
|
1014
1089
|
return data
|
|
1015
1090
|
|
|
1016
|
-
def getConnection(self,connectionId:str=None,**kwargs)->dict:
|
|
1091
|
+
def getConnection(self,connectionId:str=None,full:bool=False,expansion:str=None,**kwargs)->dict:
|
|
1017
1092
|
"""
|
|
1018
1093
|
Returns the dictionary of a single connection based on its ID, without prefix.
|
|
1019
1094
|
Arguments:
|
|
1020
1095
|
connectionId : REQUIRED : The ID of the connection without prefix.
|
|
1096
|
+
full : OPTIONAL : define if all possible information are returned (default True).
|
|
1097
|
+
expansion : OPTIONAL : list of additional elements to be returned. (will replace the full=True option)
|
|
1098
|
+
possible values: "name,primaryIdType,configuredContainers,description,owner,isDeleted,isDisabled,dataSets,createdDate,modified,caseSensitive,organization,components,numDailyEvents,externalData,backfillEnabled,granularBackfills,granularStreaming,backfillsSummaryConnection,backfillsSummaryDataSets,dataSetLastIngested,componentType,sandboxName,sandboxId,fieldsId,floatPrecision,dataRetentionMonths,validationErrors,resolveIdentityNamespace,stitchedDataSets"
|
|
1021
1099
|
"""
|
|
1022
1100
|
if connectionId is None:
|
|
1023
1101
|
raise ValueError("Require a connection ID")
|
|
1024
1102
|
path = f"/data/connections/{connectionId}"
|
|
1025
|
-
params = {
|
|
1103
|
+
params = {"expansion":"name,description,owner,dataSets,createdDate,modified,sandboxName,dataRetentionMonths,primaryIdType"}
|
|
1104
|
+
if expansion is not None:
|
|
1105
|
+
params["expansion"] = expansion
|
|
1106
|
+
elif full:
|
|
1107
|
+
params = {'expansion':"name,primaryIdType,configuredContainers,description,owner,isDeleted,isDisabled,dataSets,createdDate,modified,caseSensitive,organization,components,numDailyEvents,externalData,backfillEnabled,granularBackfills,granularStreaming,backfillsSummaryConnection,backfillsSummaryDataSets,dataSetLastIngested,componentType,sandboxName,sandboxId,fieldsId,floatPrecision,dataRetentionMonths,validationErrors,resolveIdentityNamespace,stitchedDataSets"}
|
|
1026
1108
|
res = self.connector.getData(self.endpoint + path,params=params, **kwargs)
|
|
1027
1109
|
return res
|
|
1028
1110
|
|
|
@@ -88,4 +88,6 @@ def get_oauth_token_and_expiry_for_config(config: dict,
|
|
|
88
88
|
responseJson = response.json()
|
|
89
89
|
token = responseJson.get('access_token')
|
|
90
90
|
expiry = responseJson.get("expires_in")
|
|
91
|
+
if token is None or expiry is None:
|
|
92
|
+
raise Exception(f"OAuth response missing required fields. Response: {responseJson}")
|
|
91
93
|
return {'token': token, 'expiry': expiry}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cjapy
|
|
3
|
-
Version: 0.2.4.
|
|
3
|
+
Version: 0.2.4.post3
|
|
4
4
|
Summary: Adobe Customer Journey Analytics (CJA) wrapper
|
|
5
5
|
Home-page: https://github.com/pitchmuc/cjapy
|
|
6
6
|
Author: Julien Piccini
|
|
@@ -33,6 +33,7 @@ Provides-Extra: dynamic
|
|
|
33
33
|
Requires-Dist: version; extra == "dynamic"
|
|
34
34
|
Dynamic: author
|
|
35
35
|
Dynamic: home-page
|
|
36
|
+
Dynamic: license-file
|
|
36
37
|
Dynamic: requires-python
|
|
37
38
|
|
|
38
39
|
# Adobe Customer Journey API
|