cjapy 0.2.2__tar.gz → 0.2.2.post2__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.2 → cjapy-0.2.2.post2}/PKG-INFO +1 -1
- cjapy-0.2.2.post2/cjapy/__version__.py +1 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/cjapy.py +95 -51
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/configs.py +29 -5
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/connector.py +13 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/projects.py +5 -1
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy.egg-info/PKG-INFO +1 -1
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/releases.md +6 -1
- cjapy-0.2.2/cjapy/__version__.py +0 -1
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/LICENSE +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/README.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/__init__.py +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/config.py +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/requestCreator.py +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/token_provider.py +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy/workspace.py +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy.egg-info/SOURCES.txt +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy.egg-info/dependency_links.txt +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy.egg-info/requires.txt +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/cjapy.egg-info/top_level.txt +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/authenticating_without_config_json.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/cja.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/getting_started.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/logging.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/main.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/projects.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/requestCreator.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/docs/workspace.md +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/pyproject.toml +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/requirements.txt +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/setup.cfg +0 -0
- {cjapy-0.2.2 → cjapy-0.2.2.post2}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.2-2"
|
|
@@ -69,7 +69,7 @@ class CJA:
|
|
|
69
69
|
self.filters = []
|
|
70
70
|
self.calculatedMetrics: JsonListOrDataFrameType = []
|
|
71
71
|
|
|
72
|
-
def getCurrentUser(self, admin: bool = False, useCache: bool = True) -> dict:
|
|
72
|
+
def getCurrentUser(self, admin: bool = False, useCache: bool = True, **kwargs) -> dict:
|
|
73
73
|
"""
|
|
74
74
|
return the current user
|
|
75
75
|
"""
|
|
@@ -79,7 +79,7 @@ class CJA:
|
|
|
79
79
|
params = {"useCache": useCache}
|
|
80
80
|
if admin:
|
|
81
81
|
params["expansion"] = "admin"
|
|
82
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
82
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
83
83
|
return res
|
|
84
84
|
|
|
85
85
|
def getCalculatedMetrics(
|
|
@@ -94,6 +94,7 @@ class CJA:
|
|
|
94
94
|
approved: bool = False,
|
|
95
95
|
cache: bool = True,
|
|
96
96
|
output: str = "df",
|
|
97
|
+
**kwargs
|
|
97
98
|
) -> JsonListOrDataFrameType:
|
|
98
99
|
"""
|
|
99
100
|
Returns a dataframe or the list of calculated Metrics.
|
|
@@ -139,12 +140,12 @@ class CJA:
|
|
|
139
140
|
params["favorite"] = favorite
|
|
140
141
|
if approved:
|
|
141
142
|
params["approved"] = approved
|
|
142
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
143
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
143
144
|
data = res["content"]
|
|
144
145
|
lastPage = res.get("lastPage", True)
|
|
145
146
|
while lastPage != True:
|
|
146
147
|
params["page"] += 1
|
|
147
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
148
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
148
149
|
data += res["content"]
|
|
149
150
|
lastPage = res.get("lastPage", True)
|
|
150
151
|
if output == "df":
|
|
@@ -173,7 +174,7 @@ class CJA:
|
|
|
173
174
|
return df
|
|
174
175
|
return res
|
|
175
176
|
|
|
176
|
-
def getCalculatedMetric(self, calcId: str = None, full: bool = True) -> dict:
|
|
177
|
+
def getCalculatedMetric(self, calcId: str = None, full: bool = True, **kwargs) -> dict:
|
|
177
178
|
"""
|
|
178
179
|
Return a single calculated metrics based on its ID.
|
|
179
180
|
Arguments:
|
|
@@ -190,7 +191,7 @@ class CJA:
|
|
|
190
191
|
params[
|
|
191
192
|
"expansion"
|
|
192
193
|
] = "approved,favorite,shares,tags,sharesFullName,usageSummary,usageSummaryWithRelevancyScore,reportSuiteName,siteTitle,ownerFullName,modified,migratedIds,isDeleted,definition,authorization,compatibility,legacyId,internal,dataGroup,categories"
|
|
193
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
194
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
194
195
|
return res
|
|
195
196
|
|
|
196
197
|
def createCalculatedMetric(self, data: dict = None) -> dict:
|
|
@@ -235,7 +236,7 @@ class CJA:
|
|
|
235
236
|
res = self.connector.deleteData(self.endpoint + path)
|
|
236
237
|
return res
|
|
237
238
|
|
|
238
|
-
def updateCalculatedMetrics(self, calcId: str = None, data: dict = None) -> dict:
|
|
239
|
+
def updateCalculatedMetrics(self, calcId: str = None, data: dict = None, **kwargs) -> dict:
|
|
239
240
|
"""
|
|
240
241
|
Will overwrite the calculated metrics object with the new object (PUT method)
|
|
241
242
|
Arguments:
|
|
@@ -249,7 +250,7 @@ class CJA:
|
|
|
249
250
|
if self.loggingEnabled:
|
|
250
251
|
self.logger.debug(f"updateCalculatedMetrics start, id: {calcId}")
|
|
251
252
|
path = f"/calculatedmetrics/{calcId}"
|
|
252
|
-
res = self.connector.putData(self.endpoint + path, data=data)
|
|
253
|
+
res = self.connector.putData(self.endpoint + path, data=data, **kwargs)
|
|
253
254
|
return res
|
|
254
255
|
|
|
255
256
|
def getShares(
|
|
@@ -258,6 +259,7 @@ class CJA:
|
|
|
258
259
|
inclType: str = "sharedTo",
|
|
259
260
|
limit: int = 100,
|
|
260
261
|
useCache: bool = True,
|
|
262
|
+
**kwargs
|
|
261
263
|
) -> dict:
|
|
262
264
|
"""
|
|
263
265
|
Returns the elements shared.
|
|
@@ -273,7 +275,7 @@ class CJA:
|
|
|
273
275
|
path = "/componentmetadata/shares"
|
|
274
276
|
if userId is not None:
|
|
275
277
|
params["userId"] = userId
|
|
276
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
278
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
277
279
|
return res
|
|
278
280
|
|
|
279
281
|
def getShare(self, shareId: str = None, useCache: bool = True) -> dict:
|
|
@@ -372,6 +374,7 @@ class CJA:
|
|
|
372
374
|
full: bool = True,
|
|
373
375
|
includeType: str = "all",
|
|
374
376
|
output: str = "df",
|
|
377
|
+
**kwargs
|
|
375
378
|
) -> JsonListOrDataFrameType:
|
|
376
379
|
"""
|
|
377
380
|
Return daterange information in a list or in a dataframe
|
|
@@ -395,14 +398,14 @@ class CJA:
|
|
|
395
398
|
] = "definition,modified,ownerFullName,sharesFullName,shares,tags"
|
|
396
399
|
if includeType is not None:
|
|
397
400
|
params["includeType"] = includeType
|
|
398
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
401
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
399
402
|
data = res.get("content", [])
|
|
400
403
|
if output == "df":
|
|
401
404
|
df = pd.DataFrame(data)
|
|
402
405
|
return df
|
|
403
406
|
return data
|
|
404
407
|
|
|
405
|
-
def getDateRange(self, dateRangeId: str = None) -> dict:
|
|
408
|
+
def getDateRange(self, dateRangeId: str = None, **kwargs) -> dict:
|
|
406
409
|
"""
|
|
407
410
|
Return a single dateRange definition.
|
|
408
411
|
Argument:
|
|
@@ -416,7 +419,7 @@ class CJA:
|
|
|
416
419
|
params = {
|
|
417
420
|
"expansion": "definition,modified,ownerFullName,sharesFullName,shares,tags"
|
|
418
421
|
}
|
|
419
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
422
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
420
423
|
return res
|
|
421
424
|
|
|
422
425
|
def deleteDateRange(self, dateRangeId: str = None) -> dict:
|
|
@@ -450,7 +453,7 @@ class CJA:
|
|
|
450
453
|
res = self.connector.putData(self.endpoint + path, data=data)
|
|
451
454
|
return res
|
|
452
455
|
|
|
453
|
-
def createDateRange(self, dateRangeData: dict = None) -> dict:
|
|
456
|
+
def createDateRange(self, dateRangeData: dict = None, **kwargs) -> dict:
|
|
454
457
|
"""
|
|
455
458
|
Create a single dateRange with the dictionary passed
|
|
456
459
|
Argument:
|
|
@@ -461,7 +464,7 @@ class CJA:
|
|
|
461
464
|
if self.loggingEnabled:
|
|
462
465
|
self.logger.debug(f"createDateRange start")
|
|
463
466
|
path = f"/dateranges/"
|
|
464
|
-
res = self.connector.putData(self.endpoint + path, data=dateRangeData)
|
|
467
|
+
res = self.connector.putData(self.endpoint + path, data=dateRangeData, **kwargs)
|
|
465
468
|
return res
|
|
466
469
|
|
|
467
470
|
def getTags(self, limit: int = 100) -> dict:
|
|
@@ -691,7 +694,7 @@ class CJA:
|
|
|
691
694
|
params["includeOberonXml"] = True
|
|
692
695
|
if noneValues == False:
|
|
693
696
|
params["lookupNoneValues"] = False
|
|
694
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
697
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
695
698
|
return res
|
|
696
699
|
|
|
697
700
|
def getDimensions(
|
|
@@ -701,6 +704,7 @@ class CJA:
|
|
|
701
704
|
inclType: str = None,
|
|
702
705
|
verbose: bool = False,
|
|
703
706
|
output: str = "df",
|
|
707
|
+
**kwargs
|
|
704
708
|
) -> dict:
|
|
705
709
|
"""
|
|
706
710
|
Used to retrieve dimensions for a dataview
|
|
@@ -723,14 +727,14 @@ class CJA:
|
|
|
723
727
|
if inclType == "hidden":
|
|
724
728
|
params["includeType"] = "hidden"
|
|
725
729
|
res = self.connector.getData(
|
|
726
|
-
self.endpoint + path, params=params, verbose=verbose
|
|
730
|
+
self.endpoint + path, params=params, verbose=verbose, **kwargs
|
|
727
731
|
)
|
|
728
732
|
dimensions = res.get("content", [])
|
|
729
733
|
lastPage = res.get('lastPage',True)
|
|
730
734
|
while lastPage == False:
|
|
731
735
|
params["page"] += 1
|
|
732
736
|
res = self.connector.getData(
|
|
733
|
-
self.endpoint + path, params=params, verbose=verbose
|
|
737
|
+
self.endpoint + path, params=params, verbose=verbose, **kwargs
|
|
734
738
|
)
|
|
735
739
|
dimensions += res.get('content',[])
|
|
736
740
|
lastPage = res.get('lastPage',True)
|
|
@@ -742,7 +746,8 @@ class CJA:
|
|
|
742
746
|
def getDimension(
|
|
743
747
|
self, dataviewId: str = None,
|
|
744
748
|
dimensionId: str = None,
|
|
745
|
-
full: bool = True
|
|
749
|
+
full: bool = True,
|
|
750
|
+
**kwargs
|
|
746
751
|
):
|
|
747
752
|
"""
|
|
748
753
|
Return a specific dimension based on the dataview ID and dimension ID passed.
|
|
@@ -763,7 +768,7 @@ class CJA:
|
|
|
763
768
|
params[
|
|
764
769
|
"expansion"
|
|
765
770
|
] = "approved,favorite,tags,usageSummary,usageSummaryWithRelevancyScore,description,sourceFieldId,segmentable,required,hideFromReporting,hidden,includeExcludeSetting,fieldDefinition,storageId,tableName,dataSetIds,dataSetType,type,schemaPath,hasData,sourceFieldName,schemaType,sourceFieldType,fromGlobalLookup,multiValued,precision"
|
|
766
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
771
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
767
772
|
return res
|
|
768
773
|
|
|
769
774
|
def getMetrics(
|
|
@@ -773,6 +778,7 @@ class CJA:
|
|
|
773
778
|
inclType: str = None,
|
|
774
779
|
verbose: bool = False,
|
|
775
780
|
output: str = "df",
|
|
781
|
+
**kwargs
|
|
776
782
|
) -> dict:
|
|
777
783
|
"""
|
|
778
784
|
Used to retrieve metrics for a dataview
|
|
@@ -795,14 +801,14 @@ class CJA:
|
|
|
795
801
|
if inclType == "hidden":
|
|
796
802
|
params["includeType"] = "hidden"
|
|
797
803
|
res = self.connector.getData(
|
|
798
|
-
self.endpoint + path, params=params, verbose=verbose
|
|
804
|
+
self.endpoint + path, params=params, verbose=verbose, **kwargs
|
|
799
805
|
)
|
|
800
806
|
metrics = res.get('content',[])
|
|
801
807
|
lastPage = res.get('lastPage',True)
|
|
802
808
|
while lastPage == False:
|
|
803
809
|
params["page"] += 1
|
|
804
810
|
res = self.connector.getData(
|
|
805
|
-
self.endpoint + path, params=params, verbose=verbose
|
|
811
|
+
self.endpoint + path, params=params, verbose=verbose, **kwargs
|
|
806
812
|
)
|
|
807
813
|
metrics += res.get('content',[])
|
|
808
814
|
lastPage = res.get('lastPage',True)
|
|
@@ -812,7 +818,7 @@ class CJA:
|
|
|
812
818
|
return res
|
|
813
819
|
|
|
814
820
|
def getMetric(
|
|
815
|
-
self, dataviewId: str = None, metricId: str = None, full: bool = True
|
|
821
|
+
self, dataviewId: str = None, metricId: str = None, full: bool = True, **kwargs
|
|
816
822
|
):
|
|
817
823
|
"""
|
|
818
824
|
Return a specific metric based on the dataview ID and dimension ID passed.
|
|
@@ -833,7 +839,7 @@ class CJA:
|
|
|
833
839
|
params[
|
|
834
840
|
"expansion"
|
|
835
841
|
] = "approved,favorite,tags,usageSummary,usageSummaryWithRelevancyScore,description,sourceFieldId,segmentable,required,hideFromReporting,hidden,includeExcludeSetting,fieldDefinition,bucketingSetting,noValueOptionsSetting,defaultDimensionSort,persistenceSetting,storageId,tableName,dataSetIds,dataSetType,type,schemaPath,hasData,sourceFieldName,schemaType,sourceFieldType,fromGlobalLookup,multiValued,precision"
|
|
836
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
842
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
837
843
|
return res
|
|
838
844
|
|
|
839
845
|
def getDataViews(
|
|
@@ -883,14 +889,14 @@ class CJA:
|
|
|
883
889
|
if externalParentIds:
|
|
884
890
|
params["externalParentIds"] = externalParentIds
|
|
885
891
|
res = self.connector.getData(
|
|
886
|
-
self.endpoint + path, params=params, verbose=verbose
|
|
892
|
+
self.endpoint + path, params=params, verbose=verbose, **kwargs
|
|
887
893
|
)
|
|
888
894
|
data = res["content"]
|
|
889
895
|
last = res.get("last", True)
|
|
890
896
|
while last != True:
|
|
891
897
|
params["page"] += 1
|
|
892
898
|
res = self.connector.getData(
|
|
893
|
-
self.endpoint + path, params=params, verbose=verbose
|
|
899
|
+
self.endpoint + path, params=params, verbose=verbose, **kwargs
|
|
894
900
|
)
|
|
895
901
|
data += res["content"]
|
|
896
902
|
last = res.get("last", True)
|
|
@@ -900,7 +906,7 @@ class CJA:
|
|
|
900
906
|
return data
|
|
901
907
|
|
|
902
908
|
def getDataView(
|
|
903
|
-
self, dataViewId: str = None, full: bool = True, save: bool = False
|
|
909
|
+
self, dataViewId: str = None, full: bool = True, save: bool = False, **kwargs
|
|
904
910
|
) -> dict:
|
|
905
911
|
"""
|
|
906
912
|
Returns a specific Data View configuration from Configuration ID.
|
|
@@ -919,13 +925,13 @@ class CJA:
|
|
|
919
925
|
params[
|
|
920
926
|
"expansion"
|
|
921
927
|
] = "name,description,owner,isDeleted,parentDataGroupId,segmentList,currentTimezoneOffset,timezoneDesignator,modified,createdDate,organization,curationEnabled,recentRecordedAccess,sessionDefinition,curatedComponents,externalData,containerNames"
|
|
922
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
928
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
923
929
|
if save:
|
|
924
930
|
with open(f"{dataViewId}_{int(time.time())}.json", "w") as f:
|
|
925
931
|
f.write(json.dumps(res, indent=4))
|
|
926
932
|
return res
|
|
927
933
|
|
|
928
|
-
def getConnections(self,limit:int=1000,full:bool=True,output:str='df')-> JsonListOrDataFrameType:
|
|
934
|
+
def getConnections(self,limit:int=1000,full:bool=True,output:str='df',**kwargs)-> JsonListOrDataFrameType:
|
|
929
935
|
"""
|
|
930
936
|
Retrieve the connections associated to that company.
|
|
931
937
|
Arguments:
|
|
@@ -939,12 +945,12 @@ class CJA:
|
|
|
939
945
|
params = {"limit":limit,"page":0}
|
|
940
946
|
if full:
|
|
941
947
|
params["expansion"] ="granularBackfills,granularStreaming,backfillsSummaryConnection,name,description,isDeleted,isDisabled,dataSets,createdDate,modified,sandboxName,organization,backfillEnabled,modifiedBy,ownerFullName"
|
|
942
|
-
res = self.connector.getData(self.endpoint + path,params=params)
|
|
948
|
+
res = self.connector.getData(self.endpoint + path,params=params, **kwargs)
|
|
943
949
|
data = res.get('content',[])
|
|
944
950
|
lastpage = res.get('lastPage',True)
|
|
945
951
|
while lastpage != True:
|
|
946
952
|
params['page'] += 1
|
|
947
|
-
res = self.connector.getData(self.endpoint + path,params=params)
|
|
953
|
+
res = self.connector.getData(self.endpoint + path,params=params, **kwargs)
|
|
948
954
|
data += res.get('content',[])
|
|
949
955
|
lastpage = res.get('lastPage',True)
|
|
950
956
|
if output == "df":
|
|
@@ -952,7 +958,7 @@ class CJA:
|
|
|
952
958
|
return df
|
|
953
959
|
return data
|
|
954
960
|
|
|
955
|
-
def getConnection(self,connectionId:str=None)->dict:
|
|
961
|
+
def getConnection(self,connectionId:str=None,**kwargs)->dict:
|
|
956
962
|
"""
|
|
957
963
|
Returns the dictionary of a single connection based on its ID, without prefix.
|
|
958
964
|
Arguments:
|
|
@@ -962,7 +968,7 @@ class CJA:
|
|
|
962
968
|
raise ValueError("Require a connection ID")
|
|
963
969
|
path = f"/datagroups/connections/{connectionId}"
|
|
964
970
|
params = {'expansion':"granularBackfills,granularStreaming,backfillsSummaryConnection,name,description,isDeleted,isDisabled,dataSets,createdDate,modified,sandboxName,organization,backfillEnabled,modifiedBy,ownerFullName"}
|
|
965
|
-
res = self.connector.getData(self.endpoint + path,params=params)
|
|
971
|
+
res = self.connector.getData(self.endpoint + path,params=params, **kwargs)
|
|
966
972
|
return res
|
|
967
973
|
|
|
968
974
|
def validateDataView(self, data: Union[dict, IO]) -> dict:
|
|
@@ -982,21 +988,57 @@ class CJA:
|
|
|
982
988
|
res = self.connector.postData(self.endpoint + path, data=data)
|
|
983
989
|
return res
|
|
984
990
|
|
|
985
|
-
def createDataView(self,
|
|
991
|
+
def createDataView(self,
|
|
992
|
+
data: Union[dict, IO] = None,
|
|
993
|
+
name:str=None,
|
|
994
|
+
connectionId:str=None,
|
|
995
|
+
description:str="power by cjapy",
|
|
996
|
+
timeZone:str="US/Mountain",
|
|
997
|
+
minuteInactivity:int=30,
|
|
998
|
+
**kwargs) -> dict:
|
|
986
999
|
"""
|
|
987
1000
|
Create and stores the given Data View in the db.
|
|
988
1001
|
Arguments:
|
|
989
1002
|
data : REQUIRED : The dictionary or json file that holds the definition for the dataview to be created.
|
|
1003
|
+
name : OPTIONAL : If you want to pass the name of the data View (and not pass the whole definition)
|
|
1004
|
+
connectionId : OPTIONAL : If you want to pass the connectionId of the data View (and not pass the whole definition)
|
|
1005
|
+
timezone : OPTIONAL : The timezone to use in the data View (see here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
|
|
1006
|
+
common timezone: US/Montain, US/Pacific, US/Michigan, US/Central, Europe/London, Europe/Paris, Asia/Tokyo, Australia/Sydney
|
|
1007
|
+
minuteInactivity : OPTIONAL : number of minutes of inactivity before closing a session
|
|
990
1008
|
"""
|
|
991
1009
|
path = "/datagroups/dataviews/"
|
|
992
|
-
if data is None:
|
|
1010
|
+
if data is None and name is None and connectionId is None:
|
|
993
1011
|
raise ValueError("Require information to be passed for data view creation")
|
|
994
|
-
if
|
|
995
|
-
|
|
996
|
-
data =
|
|
1012
|
+
if data is not None:
|
|
1013
|
+
if ".json" in data:
|
|
1014
|
+
with open(data, "r", encoding=kwargs.get("encoding", "utf-8")) as f:
|
|
1015
|
+
data = json.load(f)
|
|
1016
|
+
data = data
|
|
1017
|
+
if data is None and name is not None and connectionId is not None:
|
|
1018
|
+
data = {
|
|
1019
|
+
"name": name,
|
|
1020
|
+
"description": description,
|
|
1021
|
+
"parentDataGroupId": connectionId,
|
|
1022
|
+
"timezoneDesignator": timeZone,
|
|
1023
|
+
"sessionDefinition": [
|
|
1024
|
+
{
|
|
1025
|
+
"numPeriods": minuteInactivity,
|
|
1026
|
+
"granularity": "MINUTE",
|
|
1027
|
+
"func": "INACTIVITY",
|
|
1028
|
+
"events": [
|
|
1029
|
+
"string"
|
|
1030
|
+
]
|
|
1031
|
+
}
|
|
1032
|
+
],
|
|
1033
|
+
"organization": self.connector.config['org_id'],
|
|
1034
|
+
"externalData": {
|
|
1035
|
+
"externalParentId": connectionId
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
}
|
|
997
1039
|
if self.loggingEnabled:
|
|
998
1040
|
self.logger.debug(f"createDataView start")
|
|
999
|
-
res = self.connector.postData(self.endpoint + path, data=data)
|
|
1041
|
+
res = self.connector.postData(self.endpoint + path, data=data, **kwargs)
|
|
1000
1042
|
return res
|
|
1001
1043
|
|
|
1002
1044
|
def deleteDataView(self, dataViewId: str = None) -> str:
|
|
@@ -1037,7 +1079,7 @@ class CJA:
|
|
|
1037
1079
|
res = self.connector.putData(self.endpoint + path, data=data)
|
|
1038
1080
|
return res
|
|
1039
1081
|
|
|
1040
|
-
def copyDataView(self, dataViewId: str = None) -> dict:
|
|
1082
|
+
def copyDataView(self, dataViewId: str = None, **kwargs) -> dict:
|
|
1041
1083
|
"""
|
|
1042
1084
|
Copy the setting of a specific data view.
|
|
1043
1085
|
Arguments:
|
|
@@ -1048,7 +1090,7 @@ class CJA:
|
|
|
1048
1090
|
if self.loggingEnabled:
|
|
1049
1091
|
self.logger.debug(f"copyDataView start, id: {dataViewId}")
|
|
1050
1092
|
path = f"/datagroups/dataviews/copy/{dataViewId}"
|
|
1051
|
-
res = self.connector.putData(self.endpoint + path)
|
|
1093
|
+
res = self.connector.putData(self.endpoint + path, **kwargs)
|
|
1052
1094
|
return res
|
|
1053
1095
|
|
|
1054
1096
|
def getFilters(
|
|
@@ -1064,6 +1106,7 @@ class CJA:
|
|
|
1064
1106
|
cached: bool = True,
|
|
1065
1107
|
cache: bool = True,
|
|
1066
1108
|
verbose: bool = False,
|
|
1109
|
+
**kwargs
|
|
1067
1110
|
) -> JsonListOrDataFrameType:
|
|
1068
1111
|
"""
|
|
1069
1112
|
Returns a list of filters used in CJA.
|
|
@@ -1103,14 +1146,14 @@ class CJA:
|
|
|
1103
1146
|
if filterByIds is not None:
|
|
1104
1147
|
params["filterByIds"] = filterByIds
|
|
1105
1148
|
res = self.connector.getData(
|
|
1106
|
-
self.endpoint + path, params=params, verbose=verbose
|
|
1149
|
+
self.endpoint + path, params=params, verbose=verbose, **kwargs
|
|
1107
1150
|
)
|
|
1108
1151
|
lastPage = res.get("lastPage", True)
|
|
1109
1152
|
data = res["content"]
|
|
1110
1153
|
while lastPage == False:
|
|
1111
1154
|
params["page"] += 1
|
|
1112
1155
|
res = self.connector.getData(
|
|
1113
|
-
self.endpoint + path, params=params, verbose=verbose
|
|
1156
|
+
self.endpoint + path, params=params, verbose=verbose, **kwargs
|
|
1114
1157
|
)
|
|
1115
1158
|
data += res["content"]
|
|
1116
1159
|
lastPage = res.get("lastPage", True)
|
|
@@ -1125,6 +1168,7 @@ class CJA:
|
|
|
1125
1168
|
self,
|
|
1126
1169
|
filterId: str = None,
|
|
1127
1170
|
full: bool = False,
|
|
1171
|
+
**kwargs
|
|
1128
1172
|
) -> dict:
|
|
1129
1173
|
"""
|
|
1130
1174
|
Returns a single filter definition by its ID.
|
|
@@ -1142,7 +1186,7 @@ class CJA:
|
|
|
1142
1186
|
params[
|
|
1143
1187
|
"expansion"
|
|
1144
1188
|
] = "compatibility,definition,internal,modified,isDeleted,definitionLastModified,createdDate,recentRecordedAccess,performanceScore,owner,dataId,ownerFullName,dataName,sharesFullName,approved,favorite,shares,tags,usageSummary,usageSummaryWithRelevancyScore"
|
|
1145
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
1189
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
1146
1190
|
return res
|
|
1147
1191
|
|
|
1148
1192
|
def deleteFilter(self, filterId: str = None) -> str:
|
|
@@ -1218,7 +1262,7 @@ class CJA:
|
|
|
1218
1262
|
if ".json" in data:
|
|
1219
1263
|
with open(data, "r", encoding=kwargs.get("encoding", "utf-8")) as f:
|
|
1220
1264
|
data = json.load(f.read())
|
|
1221
|
-
res = self.connector.putData(self.endpoint + path, data=data)
|
|
1265
|
+
res = self.connector.putData(self.endpoint + path, data=data, **kwargs)
|
|
1222
1266
|
return res
|
|
1223
1267
|
|
|
1224
1268
|
def getAuditLogs(
|
|
@@ -1573,7 +1617,7 @@ class CJA:
|
|
|
1573
1617
|
params["filterByIds"] = filterByIds
|
|
1574
1618
|
if ownerId:
|
|
1575
1619
|
params["ownerId"] = ownerId
|
|
1576
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
1620
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
1577
1621
|
if params.get('pagination','false') != 'true':
|
|
1578
1622
|
data = res
|
|
1579
1623
|
else:
|
|
@@ -1581,7 +1625,7 @@ class CJA:
|
|
|
1581
1625
|
data = res["content"]
|
|
1582
1626
|
while float(len(data)) < float(n_results) and lastPage == False:
|
|
1583
1627
|
params["page"] +=1
|
|
1584
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
1628
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
1585
1629
|
data += res["content"]
|
|
1586
1630
|
lastPage = res.get('lastPage',False)
|
|
1587
1631
|
if float(len(data)) >= float(n_results):
|
|
@@ -1622,7 +1666,7 @@ class CJA:
|
|
|
1622
1666
|
params = {
|
|
1623
1667
|
"expansion": "shares,tags,accessLevel,modified,externalReferences,definition"
|
|
1624
1668
|
}
|
|
1625
|
-
res = self.connector.getData(self.endpoint + path, params=params)
|
|
1669
|
+
res = self.connector.getData(self.endpoint + path, params=params, **kwargs)
|
|
1626
1670
|
if projectClass:
|
|
1627
1671
|
return Project(res, dvIdSuffix=dvIdSuffix)
|
|
1628
1672
|
if cache:
|
|
@@ -1726,7 +1770,7 @@ class CJA:
|
|
|
1726
1770
|
res = self.connector.deleteData(self.endpoint + path)
|
|
1727
1771
|
return res
|
|
1728
1772
|
|
|
1729
|
-
def createProject(self, projectDefinition: dict = None) -> dict:
|
|
1773
|
+
def createProject(self, projectDefinition: dict = None, **kwargs) -> dict:
|
|
1730
1774
|
"""
|
|
1731
1775
|
Create a project based on the definition provided in the argument.
|
|
1732
1776
|
Argument:
|
|
@@ -1737,7 +1781,7 @@ class CJA:
|
|
|
1737
1781
|
if self.loggingEnabled:
|
|
1738
1782
|
self.logger.debug(f"createProject start")
|
|
1739
1783
|
path = "/projects"
|
|
1740
|
-
res = self.connector.postData(self.endpoint + path, data=projectDefinition)
|
|
1784
|
+
res = self.connector.postData(self.endpoint + path, data=projectDefinition, **kwargs)
|
|
1741
1785
|
return res
|
|
1742
1786
|
|
|
1743
1787
|
def validateProject(self, projectDefinition: dict = None) -> dict:
|
|
@@ -1756,7 +1800,7 @@ class CJA:
|
|
|
1756
1800
|
return res
|
|
1757
1801
|
|
|
1758
1802
|
def updateProject(
|
|
1759
|
-
self, projectId: str = None, projectDefinition: dict = None
|
|
1803
|
+
self, projectId: str = None, projectDefinition: dict = None, **kwargs
|
|
1760
1804
|
) -> dict:
|
|
1761
1805
|
"""
|
|
1762
1806
|
Update a project based on the definition provided in the argument. (PUT Method)
|
|
@@ -1775,7 +1819,7 @@ class CJA:
|
|
|
1775
1819
|
"expansion": "shares,tags,accessLevel,modified,externalReferences,definition"
|
|
1776
1820
|
}
|
|
1777
1821
|
res = self.connector.putData(
|
|
1778
|
-
self.endpoint + path, data=projectDefinition, params=params
|
|
1822
|
+
self.endpoint + path, data=projectDefinition, params=params, **kwargs
|
|
1779
1823
|
)
|
|
1780
1824
|
return res
|
|
1781
1825
|
|
|
@@ -61,6 +61,7 @@ def createConfigFile(
|
|
|
61
61
|
def importConfigFile(
|
|
62
62
|
path: str = None,
|
|
63
63
|
auth_type: str = None,
|
|
64
|
+
client_secret_index: int = 0,
|
|
64
65
|
)-> None:
|
|
65
66
|
"""Reads the file denoted by the supplied `path` and retrieves the configuration information
|
|
66
67
|
from it.
|
|
@@ -68,6 +69,7 @@ def importConfigFile(
|
|
|
68
69
|
Arguments:
|
|
69
70
|
path: REQUIRED : path to the configuration file. Can be either a fully-qualified or relative.
|
|
70
71
|
auth_type : OPTIONAL : type of authentication, either "jwt" or "oauthV2". Detected based on keys present in config file.
|
|
72
|
+
client_secret_index : OPTIONAL : choose which of your client secrets that you want to use, specify the index, default 0.
|
|
71
73
|
|
|
72
74
|
Example of path value.
|
|
73
75
|
"config.json"
|
|
@@ -87,26 +89,48 @@ def importConfigFile(
|
|
|
87
89
|
## old naming for client_id
|
|
88
90
|
client_id = provided_config["api_key"]
|
|
89
91
|
elif "client_id" in provided_keys:
|
|
92
|
+
## old lowercase naming for client_id
|
|
90
93
|
client_id = provided_config["client_id"]
|
|
94
|
+
elif "CLIENT_ID" in provided_keys:
|
|
95
|
+
client_id = provided_config["CLIENT_ID"]
|
|
91
96
|
else:
|
|
92
97
|
raise RuntimeError(
|
|
93
|
-
f"Either an `api_key` or a `client_id` should be provided."
|
|
98
|
+
f"Either an `api_key` or a `client_id` or a `CLIENT_ID` should be provided."
|
|
94
99
|
)
|
|
100
|
+
|
|
101
|
+
if "secret" in provided_keys:
|
|
102
|
+
## old naming for client_secret
|
|
103
|
+
client_secret = provided_config["secret"]
|
|
104
|
+
elif "CLIENT_SECRETS" in provided_keys:
|
|
105
|
+
client_secret = provided_config["CLIENT_SECRETS"]
|
|
106
|
+
else:
|
|
107
|
+
raise RuntimeError(
|
|
108
|
+
f"Either an `secret` or a `CLIENT_SECRETS` should be provided."
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
if "scopes" in provided_keys:
|
|
112
|
+
## old naming for client_secret
|
|
113
|
+
scopes = provided_config["scopes"]
|
|
114
|
+
elif "SCOPES" in provided_keys:
|
|
115
|
+
scopes = provided_config["SCOPES"]
|
|
116
|
+
|
|
117
|
+
client_secret = client_secret[client_secret_index] if type(client_secret) == list else client_secret
|
|
95
118
|
if auth_type is None:
|
|
96
119
|
if 'scopes' in provided_keys:
|
|
97
120
|
auth_type = 'oauthV2'
|
|
98
121
|
elif 'tech_id' in provided_keys and "pathToKey" in provided_keys:
|
|
99
122
|
auth_type = 'jwt'
|
|
100
123
|
args = {
|
|
101
|
-
"org_id": provided_config["org_id"],
|
|
124
|
+
"org_id": provided_config["org_id"] if provided_config.get("org_id") is not None else provided_config["ORG_ID"],
|
|
102
125
|
"client_id": client_id,
|
|
103
|
-
"secret":
|
|
126
|
+
"secret": client_secret,
|
|
104
127
|
}
|
|
105
128
|
if auth_type == "jwt":
|
|
106
129
|
args["tech_id"] = provided_config["tech_id"]
|
|
107
130
|
args["path_to_key"] = provided_config["pathToKey"]
|
|
108
131
|
elif auth_type == "oauthV2":
|
|
109
|
-
|
|
132
|
+
scopes = ",".join(scopes) if type(scopes) == list else scopes
|
|
133
|
+
args["scopes"] = scopes.replace(' ','')
|
|
110
134
|
configure(**args)
|
|
111
135
|
|
|
112
136
|
|
|
@@ -147,7 +171,7 @@ def configure(
|
|
|
147
171
|
config_object["private_key"] = private_key
|
|
148
172
|
config_object["scopes"] = scopes
|
|
149
173
|
config_object["jwtTokenEndpoint"] = f"{config_object['imsEndpoint']}/ims/exchange/jwt"
|
|
150
|
-
config_object["oauthTokenEndpointV2"] = f"{config_object['imsEndpoint']}/ims/token/
|
|
174
|
+
config_object["oauthTokenEndpointV2"] = f"{config_object['imsEndpoint']}/ims/token/v3"
|
|
151
175
|
|
|
152
176
|
# ensure the reset of the state by overwriting possible values from previous import.
|
|
153
177
|
config_object["date_limit"] = 0
|
|
@@ -107,6 +107,9 @@ class AdobeRequest:
|
|
|
107
107
|
Abstraction for getting data
|
|
108
108
|
"""
|
|
109
109
|
internRetry = kwargs.get("retry", self.retry)
|
|
110
|
+
expansion = kwargs.get("expansion")
|
|
111
|
+
if expansion:
|
|
112
|
+
params["expansion"] = expansion
|
|
110
113
|
self._checkingDate()
|
|
111
114
|
if headers is None:
|
|
112
115
|
headers = self.header
|
|
@@ -175,6 +178,9 @@ class AdobeRequest:
|
|
|
175
178
|
"""
|
|
176
179
|
Abstraction for posting data
|
|
177
180
|
"""
|
|
181
|
+
expansion = kwargs.get("expansion")
|
|
182
|
+
if expansion:
|
|
183
|
+
params["expansion"] = expansion
|
|
178
184
|
self._checkingDate()
|
|
179
185
|
if headers is None:
|
|
180
186
|
headers = self.header
|
|
@@ -270,6 +276,9 @@ class AdobeRequest:
|
|
|
270
276
|
"""
|
|
271
277
|
Abstraction for putting data
|
|
272
278
|
"""
|
|
279
|
+
expansion = kwargs.get("expansion")
|
|
280
|
+
if expansion:
|
|
281
|
+
params["expansion"] = expansion
|
|
273
282
|
self._checkingDate()
|
|
274
283
|
if headers is None:
|
|
275
284
|
headers = self.header
|
|
@@ -281,6 +290,10 @@ class AdobeRequest:
|
|
|
281
290
|
res = requests.put(
|
|
282
291
|
endpoint, headers=headers, params=params, data=json.dumps(data)
|
|
283
292
|
)
|
|
293
|
+
elif params is None and data is None:
|
|
294
|
+
res = requests.put(
|
|
295
|
+
endpoint, headers=headers
|
|
296
|
+
)
|
|
284
297
|
if self.loggingEnabled:
|
|
285
298
|
self.logger.debug(f"request_URL : {res.request.url}")
|
|
286
299
|
self.logger.debug(f"status_code: {res.status_code}")
|
|
@@ -27,6 +27,8 @@ class Project:
|
|
|
27
27
|
self.template: bool = projectDict.get("companyTemplate", False)
|
|
28
28
|
self.type: str = projectDict.get('type',None)
|
|
29
29
|
self.version: str = None
|
|
30
|
+
self.curation: bool = False
|
|
31
|
+
self.reportType:str = None
|
|
30
32
|
if "definition" in projectDict.keys() and projectDict.get('type') == "project":
|
|
31
33
|
definition: dict = projectDict["definition"]
|
|
32
34
|
self.version: str = definition.get("version", None)
|
|
@@ -51,6 +53,7 @@ class Project:
|
|
|
51
53
|
)
|
|
52
54
|
else:
|
|
53
55
|
self.reportType = "mobile"
|
|
56
|
+
self.version: str = projectDict.get("definition",{}).get("version", None)
|
|
54
57
|
elif "definition" in projectDict.keys() and projectDict.get('type') == "guidedAnalysis":
|
|
55
58
|
self.reportType = "guidedAnalysis"
|
|
56
59
|
definition: dict = projectDict["definition"]
|
|
@@ -74,7 +77,8 @@ class Project:
|
|
|
74
77
|
+ len(self.elementsUsed["filters"])
|
|
75
78
|
+ len(self.elementsUsed["calculatedMetrics"])
|
|
76
79
|
)
|
|
77
|
-
|
|
80
|
+
else:
|
|
81
|
+
self.reportType = projectDict.get('type','unknown')
|
|
78
82
|
def __str__(self) -> str:
|
|
79
83
|
return json.dumps(self.to_dict(), indent=4)
|
|
80
84
|
|
|
@@ -6,7 +6,12 @@ The changes have been tracked starting version 0.1.0
|
|
|
6
6
|
## 0.2.2
|
|
7
7
|
|
|
8
8
|
* fixing issue on `Project` class for specific project with dynamic filtering
|
|
9
|
-
* supporting Guided Analysis on `Project` class
|
|
9
|
+
* supporting Guided Analysis on `Project` class\
|
|
10
|
+
Patch:
|
|
11
|
+
* Changing Oauth V2 to V3
|
|
12
|
+
* Accepting more elements as credentials
|
|
13
|
+
* Fixing some edge cases of `findComponentUsage`
|
|
14
|
+
* adding more parameters for `createDataView` methods
|
|
10
15
|
|
|
11
16
|
## 0.2.1
|
|
12
17
|
|
cjapy-0.2.2/cjapy/__version__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|